PlateProcessor - FinalPlateResult add Prop: PlateType. ApiController - Rename CardValidation -> CardInformation
This commit is contained in:
parent
6c93c0dcb7
commit
5bcea0ba3f
|
@ -73,7 +73,7 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CardValidation> GetCardInformation(string cardNumber)
|
public async Task<CardInformation> GetCardInformation(string cardNumber)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -83,13 +83,13 @@ namespace AIParkingApplication
|
||||||
};
|
};
|
||||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var cardValication = await response.Content.ReadAsAsync<CardValidation>();
|
var cardValication = await response.Content.ReadAsAsync<CardInformation>();
|
||||||
return cardValication;
|
return cardValication;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
||||||
return new CardValidation();
|
return new CardInformation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ namespace AIParkingApplication
|
||||||
public string CardNumber { get; set; }
|
public string CardNumber { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CardValidation
|
public class CardInformation
|
||||||
{
|
{
|
||||||
[JsonProperty("status")]
|
[JsonProperty("status")]
|
||||||
public bool IsValid { get; set; }
|
public bool IsValid { get; set; }
|
||||||
|
|
|
@ -80,21 +80,42 @@ namespace AIParkingApplication
|
||||||
pictureBoxPlateImage.Invoke(new Action(() =>
|
pictureBoxPlateImage.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
pictureBoxPlateImage.Image?.Dispose();
|
pictureBoxPlateImage.Image?.Dispose();
|
||||||
pictureBoxPlateImage.Image = result.PlateImage;
|
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var cardValidation = await apiController.GetCardInformation(cardNumber);
|
var cardInformation = await apiController.GetCardInformation(cardNumber);
|
||||||
|
|
||||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardValidation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
||||||
|
|
||||||
|
//TODO check saveLogResult
|
||||||
|
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
|
||||||
|
if (saveLogResult.Status)
|
||||||
|
{
|
||||||
if (isAutoOpenDoor)
|
if (isAutoOpenDoor)
|
||||||
{
|
{
|
||||||
if (this.doorId == doorId)
|
if (this.doorId == doorId)
|
||||||
{
|
{
|
||||||
c3Device.OpenDoor(doorId);
|
var openDoorResult = c3Device.OpenDoor(doorId);
|
||||||
|
if (openDoorResult.HasError)
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.BackColor = Color.Red;
|
||||||
|
lblRecogizePlateStatus.Text = "KHÔNG THỂ MỞ CỬA";
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.BackColor = Color.Red;
|
||||||
|
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ";
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblRecogizePlateStatus.Invoke(new Action(() =>
|
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||||
|
@ -145,8 +166,9 @@ namespace AIParkingApplication
|
||||||
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
|
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
|
||||||
return new FinalPlateResult
|
return new FinalPlateResult
|
||||||
{
|
{
|
||||||
PlateImage = frame.ToBitmap(),
|
PlateImage = frame,
|
||||||
PlateString = string.Empty
|
PlateString = string.Empty,
|
||||||
|
PlateType = PlateType.Square
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,24 +36,26 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
//TODO: Check if plateDetected empty
|
//TODO: Check if plateDetected empty
|
||||||
OcrResult plateOcrResultFromEngine = await Util.SendEngineRequestAsync(plateDetected, plateType);
|
OcrResult plateOcrResultFromEngine = await Util.SendEngineRequestAsync(plateDetected, plateType);
|
||||||
Bitmap finalPlateImage;
|
Mat finalPlateImage;
|
||||||
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.Ocr) && !string.IsNullOrEmpty(plateOcrResultFromEngine.Plate))
|
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.Ocr) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64))
|
||||||
{
|
{
|
||||||
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.Plate);
|
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.PlateImageBase64);
|
||||||
using (var ms = new MemoryStream(imageData))
|
using (var ms = new MemoryStream(imageData))
|
||||||
{
|
{
|
||||||
finalPlateImage = new Bitmap(ms);
|
Bitmap image = new Bitmap(ms);
|
||||||
|
finalPlateImage = BitmapConverter.ToMat(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
finalPlateImage = plateDetected.ToBitmap();
|
finalPlateImage = plateDetected;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FinalPlateResult
|
return new FinalPlateResult
|
||||||
{
|
{
|
||||||
PlateString = plateOcrResultFromEngine.Ocr,
|
PlateString = plateOcrResultFromEngine.Ocr,
|
||||||
PlateImage = finalPlateImage
|
PlateImage = finalPlateImage,
|
||||||
|
PlateType = plateType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,8 @@ namespace AIParkingApplication
|
||||||
return new FinalPlateResult
|
return new FinalPlateResult
|
||||||
{
|
{
|
||||||
PlateString = string.Empty,
|
PlateString = string.Empty,
|
||||||
PlateImage = frame.ToBitmap()
|
PlateImage = frame,
|
||||||
|
PlateType = PlateType.Square
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +108,7 @@ namespace AIParkingApplication
|
||||||
public class FinalPlateResult
|
public class FinalPlateResult
|
||||||
{
|
{
|
||||||
public string PlateString { get; set; }
|
public string PlateString { get; set; }
|
||||||
public Bitmap PlateImage { get; set; }
|
public Mat PlateImage { get; set; }
|
||||||
|
public PlateType PlateType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user