From b8e88aaafe18752332b2777a1c68122bb98fe5a5 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Fri, 26 Jun 2020 17:46:45 +0700 Subject: [PATCH] LaneIn - Check card info then do recognize plate. ApiController: CardValidation IsValid change type. --- AIParkingApplication/ApiController.cs | 2 +- AIParkingApplication/LaneIn.cs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AIParkingApplication/ApiController.cs b/AIParkingApplication/ApiController.cs index 06256de..b1cd7b5 100644 --- a/AIParkingApplication/ApiController.cs +++ b/AIParkingApplication/ApiController.cs @@ -195,7 +195,7 @@ namespace AIParkingApplication public class CardValidation { [JsonProperty("status")] - public string IsValid { get; set; } + public bool IsValid { get; set; } [JsonProperty("type")] public string Direction { get; set; } diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 75812ca..b0a9041 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -62,9 +63,10 @@ namespace AIParkingApplication } } - private void C3Device_OnNewCardReceived(int doorId, string cardNumber) + private async void C3Device_OnNewCardReceived(int doorId, string cardNumber) { - Task.Factory.StartNew(async () => + var cardInfoResult = await apiController.CheckCard(cardNumber); + if (cardInfoResult.IsValid) { plateCamera.RequestCaptureOneFrame(); await Task.Delay(500); @@ -88,7 +90,15 @@ namespace AIParkingApplication c3Device.OpenDoor(doorId); } } - }); + } + else + { + lblRecogizePlateStatus.Invoke(new Action(() => + { + lblRecogizePlateStatus.BackColor = Color.Purple; + lblRecogizePlateStatus.Text = "THẺ KHÔNG HỢP LỆ"; + })); + } } private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame) @@ -130,7 +140,7 @@ namespace AIParkingApplication try { //TODO: check size before resizing - Cv2.Resize(frame, frame, new Size(1280, 720)); + Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720)); FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame); if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))