diff --git a/AIParkingApplication/ApiController.cs b/AIParkingApplication/ApiController.cs index 8ed216a..4ad551c 100644 --- a/AIParkingApplication/ApiController.cs +++ b/AIParkingApplication/ApiController.cs @@ -155,7 +155,7 @@ namespace AIParkingApplication public string Direction { get; set; } [JsonProperty("cardID")] - public string CardIP { get; set; } + public string CardId { get; set; } [JsonProperty("cardRealID")] public int CardRealID { get; set; } @@ -173,7 +173,7 @@ namespace AIParkingApplication public bool AutoOpenDoor { get; set; } [JsonProperty("plate")] - public string Plate { get; set; } + public string PlateString { get; set; } [JsonProperty("time")] public string TimeIn { get; set; } diff --git a/AIParkingApplication/LaneOut.Designer.cs b/AIParkingApplication/LaneOut.Designer.cs index 7914804..f8bcf17 100644 --- a/AIParkingApplication/LaneOut.Designer.cs +++ b/AIParkingApplication/LaneOut.Designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.grbPlateRefernce = new System.Windows.Forms.GroupBox(); - this.pictureBox6 = new System.Windows.Forms.PictureBox(); - this.pictureBox5 = new System.Windows.Forms.PictureBox(); + this.pictureBoxOverviewImageIn = new System.Windows.Forms.PictureBox(); + this.pictureBoxPlateImageIn = new System.Windows.Forms.PictureBox(); this.grbCardInformation = new System.Windows.Forms.GroupBox(); this.lblCardType = new System.Windows.Forms.Label(); this.lblCardTime = new System.Windows.Forms.Label(); @@ -46,8 +46,8 @@ this.lblStatusInfo = new System.Windows.Forms.Label(); this.lblMoneyAmount = new System.Windows.Forms.Label(); this.grbPlateRefernce.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).BeginInit(); this.grbCardInformation.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit(); @@ -59,8 +59,8 @@ // // grbPlateRefernce // - this.grbPlateRefernce.Controls.Add(this.pictureBox6); - this.grbPlateRefernce.Controls.Add(this.pictureBox5); + this.grbPlateRefernce.Controls.Add(this.pictureBoxOverviewImageIn); + this.grbPlateRefernce.Controls.Add(this.pictureBoxPlateImageIn); this.grbPlateRefernce.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.grbPlateRefernce.Location = new System.Drawing.Point(453, 208); this.grbPlateRefernce.Name = "grbPlateRefernce"; @@ -69,23 +69,25 @@ this.grbPlateRefernce.TabStop = false; this.grbPlateRefernce.Text = "Tham chiếu vào"; // - // pictureBox6 + // pictureBoxOverviewImageIn // - this.pictureBox6.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.pictureBox6.Location = new System.Drawing.Point(13, 270); - this.pictureBox6.Name = "pictureBox6"; - this.pictureBox6.Size = new System.Drawing.Size(200, 200); - this.pictureBox6.TabIndex = 0; - this.pictureBox6.TabStop = false; + this.pictureBoxOverviewImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.pictureBoxOverviewImageIn.Location = new System.Drawing.Point(13, 270); + this.pictureBoxOverviewImageIn.Name = "pictureBoxOverviewImageIn"; + this.pictureBoxOverviewImageIn.Size = new System.Drawing.Size(200, 200); + this.pictureBoxOverviewImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBoxOverviewImageIn.TabIndex = 0; + this.pictureBoxOverviewImageIn.TabStop = false; // - // pictureBox5 + // pictureBoxPlateImageIn // - this.pictureBox5.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.pictureBox5.Location = new System.Drawing.Point(13, 23); - this.pictureBox5.Name = "pictureBox5"; - this.pictureBox5.Size = new System.Drawing.Size(200, 200); - this.pictureBox5.TabIndex = 0; - this.pictureBox5.TabStop = false; + this.pictureBoxPlateImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.pictureBoxPlateImageIn.Location = new System.Drawing.Point(13, 23); + this.pictureBoxPlateImageIn.Name = "pictureBoxPlateImageIn"; + this.pictureBoxPlateImageIn.Size = new System.Drawing.Size(200, 200); + this.pictureBoxPlateImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBoxPlateImageIn.TabIndex = 0; + this.pictureBoxPlateImageIn.TabStop = false; // // grbCardInformation // @@ -249,8 +251,8 @@ this.Name = "LaneOut"; this.Size = new System.Drawing.Size(680, 692); this.grbPlateRefernce.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).EndInit(); this.grbCardInformation.ResumeLayout(false); this.grbCardInformation.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit(); @@ -265,8 +267,8 @@ #endregion private System.Windows.Forms.GroupBox grbPlateRefernce; - private System.Windows.Forms.PictureBox pictureBox6; - private System.Windows.Forms.PictureBox pictureBox5; + private System.Windows.Forms.PictureBox pictureBoxOverviewImageIn; + private System.Windows.Forms.PictureBox pictureBoxPlateImageIn; private System.Windows.Forms.GroupBox grbCardInformation; private System.Windows.Forms.Label lblCardType; private System.Windows.Forms.Label lblCardTime; diff --git a/AIParkingApplication/LaneOut.cs b/AIParkingApplication/LaneOut.cs index 8a71451..a708b98 100644 --- a/AIParkingApplication/LaneOut.cs +++ b/AIParkingApplication/LaneOut.cs @@ -60,6 +60,7 @@ namespace AIParkingApplication return; } ClearPlateAndOverviewImage(); + ClearPlateAndOverviewImageIn(); var cardInfoResult = await apiController.GetCardInformation(cardNumber); if (!cardInfoResult.IsValid) { @@ -73,6 +74,12 @@ namespace AIParkingApplication return; } + Bitmap plateImageIn = Util.ConvertFromBase64Image(cardInfoResult.PlateImageBase64); + Bitmap overviewImageIn = Util.ConvertFromBase64Image(cardInfoResult.FrameImageBase64); + + pictureBoxPlateImageIn.UpdateImage(plateImageIn); + pictureBoxOverviewImageIn.UpdateImage(overviewImageIn); + plateCamera.RequestCaptureOneFrame(); overviewCamera.RequestCaptureOneFrame(); await Task.Delay(200); @@ -87,7 +94,7 @@ namespace AIParkingApplication 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); + var saveLogResult = await apiController.SaveLog(LaneDirection.Out, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame, cardInformation.LogID.ToString()); if (saveLogResult.Status) { if (isAutoOpenDoor) @@ -117,6 +124,12 @@ namespace AIParkingApplication pictureBoxOverviewImage.UpdateImage(null); } + private void ClearPlateAndOverviewImageIn() + { + pictureBoxPlateImageIn.UpdateImage(null); + pictureBoxOverviewImageIn.UpdateImage(null); + } + private void OpenDoor(int doorId) { if (doorControlAccess.OpenDoor(doorId).HasError) diff --git a/AIParkingApplication/LaneOut.resx b/AIParkingApplication/LaneOut.resx index 377c98b..7aa0f8e 100644 --- a/AIParkingApplication/LaneOut.resx +++ b/AIParkingApplication/LaneOut.resx @@ -120,10 +120,10 @@ True - + True - + True diff --git a/AIParkingApplication/PlateProcessor.cs b/AIParkingApplication/PlateProcessor.cs index baf83ff..294268d 100644 --- a/AIParkingApplication/PlateProcessor.cs +++ b/AIParkingApplication/PlateProcessor.cs @@ -39,12 +39,8 @@ namespace AIParkingApplication Mat finalPlateImage; if (!string.IsNullOrEmpty(plateOcrResultFromEngine.PlateString) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64)) { - byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.PlateImageBase64); - using (var ms = new MemoryStream(imageData)) - { - Bitmap image = new Bitmap(ms); - finalPlateImage = BitmapConverter.ToMat(image); - } + Bitmap plateBitmapImage = Util.ConvertFromBase64Image(plateOcrResultFromEngine.PlateImageBase64); + finalPlateImage = BitmapConverter.ToMat(plateBitmapImage); } else { diff --git a/AIParkingApplication/Util.cs b/AIParkingApplication/Util.cs index ef6feee..66ad6d8 100644 --- a/AIParkingApplication/Util.cs +++ b/AIParkingApplication/Util.cs @@ -3,6 +3,7 @@ using OpenCvSharp; using System; using System.Diagnostics; using System.Drawing; +using System.IO; using System.Net.Http; using System.Net.NetworkInformation; using System.Threading.Tasks; @@ -112,6 +113,16 @@ namespace AIParkingApplication label.Text = text; })); } + + public static Bitmap ConvertFromBase64Image(string base64ImageString) + { + byte[] imageData = Convert.FromBase64String(base64ImageString); + using (var memoryStream = new MemoryStream(imageData)) + { + Bitmap image = new Bitmap(memoryStream); + return image; + } + } } public class PlateRequestEngineModel