Util - Add method: ConvertFromBase64Image(string base64ImageString). LaneOut - Rename pictureBoxOverviewImageIn, pictureBoxPlateImageIn. ApiController - Rename CardIP -> CardId, Plate -> PlateString

This commit is contained in:
DucDangAnh 2020-07-01 09:53:24 +07:00
parent 3913dd41e7
commit c84d277f15
6 changed files with 57 additions and 35 deletions

View File

@ -155,7 +155,7 @@ namespace AIParkingApplication
public string Direction { get; set; } public string Direction { get; set; }
[JsonProperty("cardID")] [JsonProperty("cardID")]
public string CardIP { get; set; } public string CardId { get; set; }
[JsonProperty("cardRealID")] [JsonProperty("cardRealID")]
public int CardRealID { get; set; } public int CardRealID { get; set; }
@ -173,7 +173,7 @@ namespace AIParkingApplication
public bool AutoOpenDoor { get; set; } public bool AutoOpenDoor { get; set; }
[JsonProperty("plate")] [JsonProperty("plate")]
public string Plate { get; set; } public string PlateString { get; set; }
[JsonProperty("time")] [JsonProperty("time")]
public string TimeIn { get; set; } public string TimeIn { get; set; }

View File

@ -29,8 +29,8 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.grbPlateRefernce = new System.Windows.Forms.GroupBox(); this.grbPlateRefernce = new System.Windows.Forms.GroupBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox(); this.pictureBoxOverviewImageIn = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox(); this.pictureBoxPlateImageIn = new System.Windows.Forms.PictureBox();
this.grbCardInformation = new System.Windows.Forms.GroupBox(); this.grbCardInformation = new System.Windows.Forms.GroupBox();
this.lblCardType = new System.Windows.Forms.Label(); this.lblCardType = new System.Windows.Forms.Label();
this.lblCardTime = new System.Windows.Forms.Label(); this.lblCardTime = new System.Windows.Forms.Label();
@ -46,8 +46,8 @@
this.lblStatusInfo = new System.Windows.Forms.Label(); this.lblStatusInfo = new System.Windows.Forms.Label();
this.lblMoneyAmount = new System.Windows.Forms.Label(); this.lblMoneyAmount = new System.Windows.Forms.Label();
this.grbPlateRefernce.SuspendLayout(); this.grbPlateRefernce.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).BeginInit();
this.grbCardInformation.SuspendLayout(); this.grbCardInformation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit();
@ -59,8 +59,8 @@
// //
// grbPlateRefernce // grbPlateRefernce
// //
this.grbPlateRefernce.Controls.Add(this.pictureBox6); this.grbPlateRefernce.Controls.Add(this.pictureBoxOverviewImageIn);
this.grbPlateRefernce.Controls.Add(this.pictureBox5); 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.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.Location = new System.Drawing.Point(453, 208);
this.grbPlateRefernce.Name = "grbPlateRefernce"; this.grbPlateRefernce.Name = "grbPlateRefernce";
@ -69,23 +69,25 @@
this.grbPlateRefernce.TabStop = false; this.grbPlateRefernce.TabStop = false;
this.grbPlateRefernce.Text = "Tham chiếu vào"; this.grbPlateRefernce.Text = "Tham chiếu vào";
// //
// pictureBox6 // pictureBoxOverviewImageIn
// //
this.pictureBox6.Anchor = System.Windows.Forms.AnchorStyles.Left; this.pictureBoxOverviewImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.pictureBox6.Location = new System.Drawing.Point(13, 270); this.pictureBoxOverviewImageIn.Location = new System.Drawing.Point(13, 270);
this.pictureBox6.Name = "pictureBox6"; this.pictureBoxOverviewImageIn.Name = "pictureBoxOverviewImageIn";
this.pictureBox6.Size = new System.Drawing.Size(200, 200); this.pictureBoxOverviewImageIn.Size = new System.Drawing.Size(200, 200);
this.pictureBox6.TabIndex = 0; this.pictureBoxOverviewImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox6.TabStop = false; this.pictureBoxOverviewImageIn.TabIndex = 0;
this.pictureBoxOverviewImageIn.TabStop = false;
// //
// pictureBox5 // pictureBoxPlateImageIn
// //
this.pictureBox5.Anchor = System.Windows.Forms.AnchorStyles.Left; this.pictureBoxPlateImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.pictureBox5.Location = new System.Drawing.Point(13, 23); this.pictureBoxPlateImageIn.Location = new System.Drawing.Point(13, 23);
this.pictureBox5.Name = "pictureBox5"; this.pictureBoxPlateImageIn.Name = "pictureBoxPlateImageIn";
this.pictureBox5.Size = new System.Drawing.Size(200, 200); this.pictureBoxPlateImageIn.Size = new System.Drawing.Size(200, 200);
this.pictureBox5.TabIndex = 0; this.pictureBoxPlateImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox5.TabStop = false; this.pictureBoxPlateImageIn.TabIndex = 0;
this.pictureBoxPlateImageIn.TabStop = false;
// //
// grbCardInformation // grbCardInformation
// //
@ -249,8 +251,8 @@
this.Name = "LaneOut"; this.Name = "LaneOut";
this.Size = new System.Drawing.Size(680, 692); this.Size = new System.Drawing.Size(680, 692);
this.grbPlateRefernce.ResumeLayout(false); this.grbPlateRefernce.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).EndInit();
this.grbCardInformation.ResumeLayout(false); this.grbCardInformation.ResumeLayout(false);
this.grbCardInformation.PerformLayout(); this.grbCardInformation.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit();
@ -265,8 +267,8 @@
#endregion #endregion
private System.Windows.Forms.GroupBox grbPlateRefernce; private System.Windows.Forms.GroupBox grbPlateRefernce;
private System.Windows.Forms.PictureBox pictureBox6; private System.Windows.Forms.PictureBox pictureBoxOverviewImageIn;
private System.Windows.Forms.PictureBox pictureBox5; private System.Windows.Forms.PictureBox pictureBoxPlateImageIn;
private System.Windows.Forms.GroupBox grbCardInformation; private System.Windows.Forms.GroupBox grbCardInformation;
private System.Windows.Forms.Label lblCardType; private System.Windows.Forms.Label lblCardType;
private System.Windows.Forms.Label lblCardTime; private System.Windows.Forms.Label lblCardTime;

View File

@ -60,6 +60,7 @@ namespace AIParkingApplication
return; return;
} }
ClearPlateAndOverviewImage(); ClearPlateAndOverviewImage();
ClearPlateAndOverviewImageIn();
var cardInfoResult = await apiController.GetCardInformation(cardNumber); var cardInfoResult = await apiController.GetCardInformation(cardNumber);
if (!cardInfoResult.IsValid) if (!cardInfoResult.IsValid)
{ {
@ -73,6 +74,12 @@ namespace AIParkingApplication
return; return;
} }
Bitmap plateImageIn = Util.ConvertFromBase64Image(cardInfoResult.PlateImageBase64);
Bitmap overviewImageIn = Util.ConvertFromBase64Image(cardInfoResult.FrameImageBase64);
pictureBoxPlateImageIn.UpdateImage(plateImageIn);
pictureBoxOverviewImageIn.UpdateImage(overviewImageIn);
plateCamera.RequestCaptureOneFrame(); plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame(); overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200); await Task.Delay(200);
@ -87,7 +94,7 @@ namespace AIParkingApplication
var cardInformation = await apiController.GetCardInformation(cardNumber); var cardInformation = await apiController.GetCardInformation(cardNumber);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)); 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 (saveLogResult.Status)
{ {
if (isAutoOpenDoor) if (isAutoOpenDoor)
@ -117,6 +124,12 @@ namespace AIParkingApplication
pictureBoxOverviewImage.UpdateImage(null); pictureBoxOverviewImage.UpdateImage(null);
} }
private void ClearPlateAndOverviewImageIn()
{
pictureBoxPlateImageIn.UpdateImage(null);
pictureBoxOverviewImageIn.UpdateImage(null);
}
private void OpenDoor(int doorId) private void OpenDoor(int doorId)
{ {
if (doorControlAccess.OpenDoor(doorId).HasError) if (doorControlAccess.OpenDoor(doorId).HasError)

View File

@ -120,10 +120,10 @@
<metadata name="grbPlateRefernce.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="grbPlateRefernce.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="pictureBox6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="pictureBoxOverviewImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="pictureBox5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="pictureBoxPlateImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -39,12 +39,8 @@ namespace AIParkingApplication
Mat finalPlateImage; Mat finalPlateImage;
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.PlateString) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64)) if (!string.IsNullOrEmpty(plateOcrResultFromEngine.PlateString) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64))
{ {
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.PlateImageBase64); Bitmap plateBitmapImage = Util.ConvertFromBase64Image(plateOcrResultFromEngine.PlateImageBase64);
using (var ms = new MemoryStream(imageData)) finalPlateImage = BitmapConverter.ToMat(plateBitmapImage);
{
Bitmap image = new Bitmap(ms);
finalPlateImage = BitmapConverter.ToMat(image);
}
} }
else else
{ {

View File

@ -3,6 +3,7 @@ using OpenCvSharp;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -112,6 +113,16 @@ namespace AIParkingApplication
label.Text = text; 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 public class PlateRequestEngineModel