LaneIn - Refactor C3Device_OnNewCardReceived

This commit is contained in:
DucDangAnh 2020-06-29 14:39:38 +07:00
parent ab14853d29
commit 5259eba6b5

View File

@ -68,25 +68,23 @@ namespace AIParkingApplication
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
var plateVideoFrame = plateCamera.CurrentFrame;
var overviewVideoFrame = overviewCamera.CurrentFrame;
pictureBoxOverviewImage.Invoke(new Action(() =>
{
pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
}));
var plateVideoFrame = plateCamera.CurrentFrame;
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
pictureBoxPlateImage.Invoke(new Action(() =>
{
pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
}));
var cardInformation = await apiController.GetCardInformation(cardNumber);
var overviewVideoFrame = overviewCamera.CurrentFrame;
pictureBoxOverviewImage.Invoke(new Action(() =>
{
pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
}));
var cardInformation = await apiController.GetCardInformation(cardNumber);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
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);
@ -94,15 +92,7 @@ namespace AIParkingApplication
{
if (isAutoOpenDoor && this.doorId == 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";
}));
}
OpenDoor(doorId);
}
}
else
@ -119,7 +109,7 @@ namespace AIParkingApplication
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.BackColor = Color.Red;
lblRecogizePlateStatus.Text = "XE ĐÃ TRONG BÃI";
lblRecogizePlateStatus.Text = "THẺ ĐÃ ĐƯỢC SỬ DỤNG - XE ĐÃ TRONG BÃI";
}));
}
}
@ -151,6 +141,18 @@ namespace AIParkingApplication
}));
}
private void OpenDoor(int doorId)
{
if (c3Device.OpenDoor(doorId).HasError)
{
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.BackColor = Color.Red;
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI TỚI THIẾT BỊ MỞ CỬA";
}));
}
}
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
{
try