Compare commits

..

No commits in common. "19f9a4ed827ded827e269060ec611c6e04e63da1" and "148896423fa11f14c1302c49ecaf1c18ae39078f" have entirely different histories.

12 changed files with 158 additions and 208 deletions

View File

@ -28,37 +28,13 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.btnStopLaneIn = new System.Windows.Forms.Button();
this.btnStartLaneIn = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnStopLaneIn
//
this.btnStopLaneIn.Location = new System.Drawing.Point(840, 205);
this.btnStopLaneIn.Name = "btnStopLaneIn";
this.btnStopLaneIn.Size = new System.Drawing.Size(75, 23);
this.btnStopLaneIn.TabIndex = 0;
this.btnStopLaneIn.Text = "Stop";
this.btnStopLaneIn.UseVisualStyleBackColor = true;
this.btnStopLaneIn.Click += new System.EventHandler(this.btnStopLaneIn_Click);
//
// btnStartLaneIn
//
this.btnStartLaneIn.Location = new System.Drawing.Point(840, 246);
this.btnStartLaneIn.Name = "btnStartLaneIn";
this.btnStartLaneIn.Size = new System.Drawing.Size(75, 23);
this.btnStartLaneIn.TabIndex = 0;
this.btnStartLaneIn.Text = "Start";
this.btnStartLaneIn.UseVisualStyleBackColor = true;
this.btnStartLaneIn.Click += new System.EventHandler(this.btnStartLaneIn_Click);
//
// AIParkingApplicationForm // AIParkingApplicationForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1350, 729); this.ClientSize = new System.Drawing.Size(1350, 729);
this.Controls.Add(this.btnStartLaneIn);
this.Controls.Add(this.btnStopLaneIn);
this.MinimumSize = new System.Drawing.Size(1366, 768); this.MinimumSize = new System.Drawing.Size(1366, 768);
this.Name = "AIParkingApplicationForm"; this.Name = "AIParkingApplicationForm";
this.Text = "AIParking Application"; this.Text = "AIParking Application";
@ -67,9 +43,6 @@
} }
#endregion #endregion
private System.Windows.Forms.Button btnStopLaneIn;
private System.Windows.Forms.Button btnStartLaneIn;
} }
} }

View File

@ -5,18 +5,16 @@ namespace AIParkingApplication
public partial class AIParkingApplicationForm : Form public partial class AIParkingApplicationForm : Form
{ {
//@"C:\CongRa_1.mp4"; @"C:\HS_test.mp4"; @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov" //@"C:\CongRa_1.mp4"; @"C:\HS_test.mp4"; @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
private ApiController apiController;
private C3DeviceController c3Device;
private LaneIn laneIn;
public AIParkingApplicationForm() public AIParkingApplicationForm()
{ {
InitializeComponent(); InitializeComponent();
string serverBaseAddress = "http://localhost:80/"; string serverBaseAddress = "http://localhost:80/";
apiController = new ApiController(serverBaseAddress); ApiController apiController = new ApiController(serverBaseAddress);
c3Device = new C3DeviceController("192.168.1.200"); C3DeviceController c3Device = new C3DeviceController("192.168.1.200");
laneIn = new LaneIn(1, @"C:\HS_test.mp4", @"C:\HS_test.mp4", c3Device, apiController, true, false, true); LaneIn laneIn = new LaneIn(1, @"C:\HS_test.mp4", @"C:\HS_test.mp4", c3Device, apiController, true, false, true);
//LaneIn laneOut = new LaneIn();
Controls.Add(laneIn); Controls.Add(laneIn);
laneIn.Start();
//laneOut.Location = new System.Drawing.Point(550, 0); //laneOut.Location = new System.Drawing.Point(550, 0);
//Controls.Add(laneOut); //Controls.Add(laneOut);
@ -25,15 +23,5 @@ namespace AIParkingApplication
//Controls.Add(laneIn1); //Controls.Add(laneIn1);
//laneIn1.Start(); //laneIn1.Start();
} }
private void btnStopLaneIn_Click(object sender, System.EventArgs e)
{
laneIn.Stop();
}
private void btnStartLaneIn_Click(object sender, System.EventArgs e)
{
laneIn.Start();
}
} }
} }

View File

@ -94,12 +94,12 @@ namespace AIParkingApplication
} }
//Neu Dicrection la Out thi logID la logID lay ve khi check the //Neu Dicrection la Out thi logID la logID lay ve khi check the
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat plateFrameImage, Mat frameImage, string logID = "") public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat PlateFrameImage, Mat FrameImage, string logID = "")
{ {
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes()); string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes()); string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes());
string PlateFrameImageBase64 = Convert.ToBase64String(plateFrameImage.ToBytes()); string PlateFrameImageBase64 = Convert.ToBase64String(PlateFrameImage.ToBytes());
string FrameImageBase64 = Convert.ToBase64String(frameImage.ToBytes()); string FrameImageBase64 = Convert.ToBase64String(FrameImage.ToBytes());
try try
{ {
var request = new SaveLogModel var request = new SaveLogModel

View File

@ -20,9 +20,9 @@ namespace AIParkingApplication
{ {
this.streamUrl = streamUrl; this.streamUrl = streamUrl;
isFrameRequested = false; isFrameRequested = false;
videoCapture = new VideoCapture();
readStreamThread = new Thread(new ThreadStart(ReadVideoStream)); readStreamThread = new Thread(new ThreadStart(ReadVideoStream));
readStreamThread.IsBackground = true; readStreamThread.IsBackground = true;
videoCapture = new VideoCapture();
} }
~Camera() ~Camera()
@ -48,13 +48,13 @@ namespace AIParkingApplication
public void ReadVideoStream() public void ReadVideoStream()
{ {
Mat videoFrame = new Mat();
if (!videoCapture.Open(streamUrl)) if (!videoCapture.Open(streamUrl))
{ {
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH)); OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
return; return;
} }
Mat videoFrame = new Mat();
while (true) while (true)
{ {
Thread.Sleep(50); //Stream Thread Sleep Thread.Sleep(50); //Stream Thread Sleep
@ -69,10 +69,6 @@ namespace AIParkingApplication
isFrameRequested = false; isFrameRequested = false;
} }
} }
else
{
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
}
} }
} }

View File

@ -40,7 +40,7 @@
this.grbCardInformation = new System.Windows.Forms.GroupBox(); this.grbCardInformation = new System.Windows.Forms.GroupBox();
this.lblCardTime = new System.Windows.Forms.Label(); this.lblCardTime = new System.Windows.Forms.Label();
this.lblPlateString = new System.Windows.Forms.Label(); this.lblPlateString = new System.Windows.Forms.Label();
this.lblStatusInfo = new System.Windows.Forms.Label(); this.lblRecogizePlateStatus = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit();
this.grbPlateCamera.SuspendLayout(); this.grbPlateCamera.SuspendLayout();
@ -176,24 +176,24 @@
this.lblPlateString.TabIndex = 0; this.lblPlateString.TabIndex = 0;
this.lblPlateString.Text = "Biển số"; this.lblPlateString.Text = "Biển số";
// //
// lblStatusInfo // lblRecogizePlateStatus
// //
this.lblStatusInfo.BackColor = System.Drawing.Color.CornflowerBlue; this.lblRecogizePlateStatus.BackColor = System.Drawing.Color.CornflowerBlue;
this.lblStatusInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblRecogizePlateStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblStatusInfo.ForeColor = System.Drawing.SystemColors.Control; this.lblRecogizePlateStatus.ForeColor = System.Drawing.SystemColors.Control;
this.lblStatusInfo.Location = new System.Drawing.Point(1, 159); this.lblRecogizePlateStatus.Location = new System.Drawing.Point(1, 159);
this.lblStatusInfo.Margin = new System.Windows.Forms.Padding(0); this.lblRecogizePlateStatus.Margin = new System.Windows.Forms.Padding(0);
this.lblStatusInfo.Name = "lblStatusInfo"; this.lblRecogizePlateStatus.Name = "lblRecogizePlateStatus";
this.lblStatusInfo.Size = new System.Drawing.Size(440, 40); this.lblRecogizePlateStatus.Size = new System.Drawing.Size(440, 40);
this.lblStatusInfo.TabIndex = 15; this.lblRecogizePlateStatus.TabIndex = 15;
this.lblStatusInfo.Text = "XIN CHÀO"; this.lblRecogizePlateStatus.Text = "XIN CHÀO";
this.lblStatusInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblRecogizePlateStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// LaneIn // LaneIn
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lblStatusInfo); this.Controls.Add(this.lblRecogizePlateStatus);
this.Controls.Add(this.grbPlateCamera); this.Controls.Add(this.grbPlateCamera);
this.Controls.Add(this.grbOverviewCamera); this.Controls.Add(this.grbOverviewCamera);
this.Controls.Add(this.lblLaneLabel); this.Controls.Add(this.lblLaneLabel);
@ -201,7 +201,6 @@
this.Margin = new System.Windows.Forms.Padding(0); this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "LaneIn"; this.Name = "LaneIn";
this.Size = new System.Drawing.Size(442, 692); this.Size = new System.Drawing.Size(442, 692);
this.Load += new System.EventHandler(this.LaneIn_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).EndInit();
this.grbPlateCamera.ResumeLayout(false); this.grbPlateCamera.ResumeLayout(false);
@ -227,6 +226,6 @@
private System.Windows.Forms.GroupBox grbCardInformation; private System.Windows.Forms.GroupBox grbCardInformation;
private System.Windows.Forms.Label lblPlateString; private System.Windows.Forms.Label lblPlateString;
private System.Windows.Forms.Label lblCardTime; private System.Windows.Forms.Label lblCardTime;
private System.Windows.Forms.Label lblStatusInfo; private System.Windows.Forms.Label lblRecogizePlateStatus;
} }
} }

View File

@ -51,34 +51,38 @@ namespace AIParkingApplication
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed; overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
plateProcessor = new PlateProcessor(this.isSupportSquarePlate, this.isSupportLongPlate); plateProcessor = new PlateProcessor(this.isSupportSquarePlate, this.isSupportLongPlate);
if (!this.c3Device.Connect().HasError)
{
_ = this.c3Device.GetLogToReceiveNewCard();
}
} }
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber) private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
{ {
ClearPlateAndOverviewImage();
var cardInfoResult = await apiController.GetCardInformation(cardNumber); var cardInfoResult = await apiController.GetCardInformation(cardNumber);
if (!cardInfoResult.IsValid) if (cardInfoResult.IsValid)
{ {
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple); if (cardInfoResult.Direction == "in")
return;
}
if (cardInfoResult.Direction != "in")
{ {
lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red);
return;
}
plateCamera.RequestCaptureOneFrame(); plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame(); overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200); await Task.Delay(200);
var plateVideoFrame = plateCamera.CurrentFrame; var plateVideoFrame = plateCamera.CurrentFrame;
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode); FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap()); pictureBoxPlateImage.Invoke(new Action(() =>
{
pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
}));
var overviewVideoFrame = overviewCamera.CurrentFrame; var overviewVideoFrame = overviewCamera.CurrentFrame;
pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.ToBitmap()); pictureBoxOverviewImage.Invoke(new Action(() =>
{
pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
}));
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));
@ -93,31 +97,59 @@ namespace AIParkingApplication
} }
else else
{ {
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red); lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.BackColor = Color.Red;
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ";
}));
}
}
else
{
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.BackColor = Color.Red;
lblRecogizePlateStatus.Text = "THẺ ĐÃ ĐƯỢC SỬ DỤNG";
}));
}
}
else
{
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.BackColor = Color.Purple;
lblRecogizePlateStatus.Text = "THẺ KHÔNG HỢP LỆ";
}));
} }
} }
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame) private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{ {
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap()); pictureBoxPlateVideo.Invoke(new Action(() =>
{
pictureBoxPlateVideo.Image?.Dispose();
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
}));
} }
private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame) private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{ {
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap()); pictureBoxOverviewVideo.Invoke(new Action(() =>
}
private void ClearPlateAndOverviewImage()
{ {
pictureBoxPlateImage.UpdateImage(null); pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewImage.UpdateImage(null); pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
}));
} }
private void OpenDoor(int doorId) private void OpenDoor(int doorId)
{ {
if (c3Device.OpenDoor(doorId).HasError) if (c3Device.OpenDoor(doorId).HasError)
{ {
lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red); 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";
}));
} }
} }
@ -125,6 +157,7 @@ namespace AIParkingApplication
{ {
try try
{ {
//TODO: check size before resizing
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720)); Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame); FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
@ -163,18 +196,42 @@ namespace AIParkingApplication
private void ShowCardInfoOnUI(string cardNumber, string plateString, string cardType, string cardTime) private void ShowCardInfoOnUI(string cardNumber, string plateString, string cardType, string cardTime)
{ {
lblCardNumber.UpdateLabel($"Số thẻ: {cardNumber}", lblCardNumber.BackColor); lblCardNumber.Invoke(new Action(() =>
lblPlateString.UpdateLabel($"Biển số: {plateString}", lblPlateString.BackColor); {
lblCardType.UpdateLabel($"Loại thẻ: {cardType}", lblCardType.BackColor); lblCardNumber.Text = $"Số thẻ: {cardNumber}";
lblCardTime.UpdateLabel($"Thời gian: {cardTime}", lblCardTime.BackColor); }));
lblStatusInfo.UpdateLabel(string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} VÀO", string.IsNullOrEmpty(plateString) ? Color.Red : Color.Green);
lblPlateString.Invoke(new Action(() =>
{
lblPlateString.Text = $"Biển số: {plateString}";
}));
lblCardType.Invoke(new Action(() =>
{
lblCardType.Text = $"Loại thẻ: {cardType}";
}));
lblCardTime.Invoke(new Action(() =>
{
lblCardTime.Text = $"Thời gian: {cardTime}";
}));
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.Text = string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} VÀO";
lblRecogizePlateStatus.BackColor = string.IsNullOrEmpty(plateString) ? System.Drawing.Color.Red : System.Drawing.Color.Green;
}));
} }
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame) private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)
{ {
try try
{ {
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap()); pictureBoxOverviewVideo.Invoke(new Action(() =>
{
pictureBoxOverviewVideo.Image?.Dispose();
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
}));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -186,29 +243,16 @@ namespace AIParkingApplication
{ {
try try
{ {
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap()); pictureBoxPlateVideo.Invoke(new Action(() =>
{
pictureBoxPlateVideo.Image?.Dispose();
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
}));
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}"); Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
} }
} }
private void ConnectToDoorAccessControl()
{
if (!this.c3Device.Connect().HasError)
{
_ = this.c3Device.GetLogToReceiveNewCard();
}
else
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI TỚI C3200", Color.Purple);
}
}
private void LaneIn_Load(object sender, EventArgs e)
{
ConnectToDoorAccessControl();
}
} }
} }

View File

@ -117,46 +117,4 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="pictureBoxPlateImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxPlateVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbPlateCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxOverviewImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxOverviewVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbOverviewCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblLaneLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardType.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblStatusInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -1,4 +1,12 @@
using System.Windows.Forms; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIParkingApplication namespace AIParkingApplication
{ {

View File

@ -71,6 +71,7 @@ namespace AIParkingApplication
} }
Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}"); Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}");
Rect extendedRect = ExtendPlateRect(biggestPlateRect); Rect extendedRect = ExtendPlateRect(biggestPlateRect);
//TODO: check oversize frame
Mat plateImage; Mat plateImage;
try try
{ {

View File

@ -1,4 +1,5 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View File

@ -3,6 +3,7 @@ using System.Windows.Forms;
using System.Threading; using System.Threading;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Http; using System.Net.Http;
using System.Xml.Serialization;
namespace AIParkingApplication namespace AIParkingApplication
{ {

View File

@ -2,18 +2,14 @@
using OpenCvSharp; using OpenCvSharp;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Net.Http; using System.Net.Http;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIParkingApplication namespace AIParkingApplication
{ {
public static class Util public static class Util
{ {
private static HttpClient httpClientEngine = new HttpClient { BaseAddress = new Uri("http://localhost:8080/"), Timeout = TimeSpan.FromMilliseconds(5000) };
public static bool IsPingable(string destinationIPAddress, out long pingTime, int timeOut = UtilConstant.PING_TIMEOUT_MS) public static bool IsPingable(string destinationIPAddress, out long pingTime, int timeOut = UtilConstant.PING_TIMEOUT_MS)
{ {
var pingTask = Task.Factory.StartNew(async () => var pingTask = Task.Factory.StartNew(async () =>
@ -58,6 +54,8 @@ namespace AIParkingApplication
{ {
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes()); string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
try try
{
using (var client = new HttpClient { BaseAddress = new Uri("http://localhost:8080/"), Timeout = TimeSpan.FromMilliseconds(5000) })
{ {
var request = new PlateRequestEngineModel var request = new PlateRequestEngineModel
{ {
@ -65,35 +63,18 @@ namespace AIParkingApplication
Mode = plateType == PlateType.Square ? "square" : "long", Mode = plateType == PlateType.Square ? "square" : "long",
Display = "full" Display = "full"
}; };
HttpResponseMessage response = await httpClientEngine.PostAsJsonAsync("/get-from-frame", request); HttpResponseMessage response = await client.PostAsJsonAsync("/get-from-frame", request);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var ocrResult = await response.Content.ReadAsAsync<OcrResult>(); var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
return ocrResult; return ocrResult;
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"SendEngineRequest : {ex.Message}"); Console.WriteLine($"SendEngineRequest : {ex.Message}");
return new OcrResult(); return new OcrResult();
} }
} }
public static void UpdateImage(this PictureBox pictureBox, Bitmap image)
{
pictureBox.Invoke(new Action(() =>
{
pictureBox.Image?.Dispose();
pictureBox.Image = image;
}));
}
public static void UpdateLabel(this Label label, string text, Color color)
{
label.Invoke(new Action(() =>
{
label.BackColor = color;
label.Text = text;
}));
}
} }
public class PlateRequestEngineModel public class PlateRequestEngineModel