diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 2916962..ce53358 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -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 ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode) { try