Compare commits
No commits in common. "1418b1077ec72d1ca8ce2fb0c300fbad15b075ed" and "6284909fd83af2d68f76716863ac80b616b9c1d4" have entirely different histories.
1418b1077e
...
6284909fd8
|
@ -93,9 +93,6 @@
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.IO.Compression" />
|
<Reference Include="System.IO.Compression" />
|
||||||
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -112,6 +109,7 @@
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -79,22 +79,22 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void InitAllLanes()
|
private void InitAllLanes()
|
||||||
{
|
{
|
||||||
laneIn12 = new LaneIn(10, configOnWeb.CameraData1.Id.ToString(), configOnWeb.CameraData1.StreamUrl, configOnWeb.CameraData2.StreamUrl, c3Device, apiController, engineApiController, appLogger, configOnWeb.CameraData1.Roi_config, true, false, true);
|
laneIn12 = new LaneIn(10, configOnWeb.CameraData1.Id.ToString(), configOnWeb.CameraData1.StreamUrl, configOnWeb.CameraData2.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||||
laneIn12.BorderStyle = BorderStyle.FixedSingle;
|
laneIn12.BorderStyle = BorderStyle.FixedSingle;
|
||||||
laneIn12.Hide();
|
laneIn12.Hide();
|
||||||
Controls.Add(laneIn12);
|
Controls.Add(laneIn12);
|
||||||
|
|
||||||
laneOut34 = new LaneOut(20, configOnWeb.CameraData3.Id.ToString(), configOnWeb.CameraData3.StreamUrl, configOnWeb.CameraData4.StreamUrl, c3Device, apiController, engineApiController, appLogger, configOnWeb.CameraData3.Roi_config, true, false, true);
|
laneOut34 = new LaneOut(20, configOnWeb.CameraData3.Id.ToString(), configOnWeb.CameraData3.StreamUrl, configOnWeb.CameraData4.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||||
laneOut34.BorderStyle = BorderStyle.FixedSingle;
|
laneOut34.BorderStyle = BorderStyle.FixedSingle;
|
||||||
laneOut34.Hide();
|
laneOut34.Hide();
|
||||||
Controls.Add(laneOut34);
|
Controls.Add(laneOut34);
|
||||||
|
|
||||||
laneIn56 = new LaneIn(10, configOnWeb.CameraData5.Id.ToString(), configOnWeb.CameraData5.StreamUrl, configOnWeb.CameraData6.StreamUrl, c3Device, apiController, engineApiController, appLogger, configOnWeb.CameraData5.Roi_config, true, false, true);
|
laneIn56 = new LaneIn(10, configOnWeb.CameraData5.Id.ToString(), configOnWeb.CameraData5.StreamUrl, configOnWeb.CameraData6.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||||
laneIn56.BorderStyle = BorderStyle.FixedSingle;
|
laneIn56.BorderStyle = BorderStyle.FixedSingle;
|
||||||
laneIn56.Hide();
|
laneIn56.Hide();
|
||||||
Controls.Add(laneIn56);
|
Controls.Add(laneIn56);
|
||||||
|
|
||||||
laneOut78 = new LaneOut(20, configOnWeb.CameraData7.Id.ToString(), configOnWeb.CameraData7.StreamUrl, configOnWeb.CameraData8.StreamUrl, c3Device, apiController, engineApiController, appLogger, configOnWeb.CameraData7.Roi_config, true, false, true);
|
laneOut78 = new LaneOut(20, configOnWeb.CameraData7.Id.ToString(), configOnWeb.CameraData7.StreamUrl, configOnWeb.CameraData8.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||||
laneOut78.BorderStyle = BorderStyle.FixedSingle;
|
laneOut78.BorderStyle = BorderStyle.FixedSingle;
|
||||||
laneOut78.Hide();
|
laneOut78.Hide();
|
||||||
Controls.Add(laneOut78);
|
Controls.Add(laneOut78);
|
||||||
|
|
|
@ -5,7 +5,6 @@ using OpenCvSharp;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using NLog;
|
using NLog;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace AIParkingApplication
|
namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
|
@ -151,36 +150,6 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void SaveRoiToServer(Rectangle roiRegion, string cameraId)
|
|
||||||
{
|
|
||||||
int requestCounter = 1;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var request = new RoiConfig
|
|
||||||
{
|
|
||||||
CameraID = cameraId,
|
|
||||||
X = roiRegion.X,
|
|
||||||
Y = roiRegion.Y,
|
|
||||||
Width = roiRegion.Width,
|
|
||||||
Height = roiRegion.Height
|
|
||||||
};
|
|
||||||
HttpResponseMessage response;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
response = await httpClient.PostAsJsonAsync("/api/update-roi", request);
|
|
||||||
response.EnsureSuccessStatusCode();
|
|
||||||
requestCounter += 1;
|
|
||||||
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
|
|
||||||
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"SaveRoiConfig Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
|
||||||
appLogger.Log(LogLevel.Error, string.Format("Không thể lưu ROI Config | exMessage: " + ex.Message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (httpClient != null && !isHttpClientDisposabled)
|
if (httpClient != null && !isHttpClientDisposabled)
|
||||||
|
@ -518,7 +487,6 @@ namespace AIParkingApplication
|
||||||
public int Logs { get; set; }
|
public int Logs { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region LaneConfig
|
#region LaneConfig
|
||||||
public class LaneConfig
|
public class LaneConfig
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
<dependentAssembly>
|
|
||||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
|
|
||||||
</dependentAssembly>
|
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
4
AIParkingApplication/LaneIn.Designer.cs
generated
4
AIParkingApplication/LaneIn.Designer.cs
generated
|
@ -69,10 +69,6 @@
|
||||||
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
this.pictureBoxPlateVideo.TabIndex = 0;
|
this.pictureBoxPlateVideo.TabIndex = 0;
|
||||||
this.pictureBoxPlateVideo.TabStop = false;
|
this.pictureBoxPlateVideo.TabStop = false;
|
||||||
this.pictureBoxPlateVideo.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxPlateVideo_Paint);
|
|
||||||
this.pictureBoxPlateVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseDown);
|
|
||||||
this.pictureBoxPlateVideo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseMove);
|
|
||||||
this.pictureBoxPlateVideo.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseUp);
|
|
||||||
//
|
//
|
||||||
// grbPlateCamera
|
// grbPlateCamera
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Printing;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using OpenCvSharp.Extensions;
|
using OpenCvSharp.Extensions;
|
||||||
|
@ -27,12 +25,6 @@ namespace AIParkingApplication
|
||||||
private ApiController apiController;
|
private ApiController apiController;
|
||||||
private Logger appLogger;
|
private Logger appLogger;
|
||||||
|
|
||||||
private System.Drawing.Point StartPoint { get; set; }
|
|
||||||
private System.Drawing.Point CurrentCursorPosition { get; set; }
|
|
||||||
private Rectangle pictureBoxRoi;
|
|
||||||
private bool IsDrawBox { get; set; }
|
|
||||||
private Rect roiBoxRect;
|
|
||||||
|
|
||||||
public LaneIn(int doorId,
|
public LaneIn(int doorId,
|
||||||
string cameraId,
|
string cameraId,
|
||||||
string plateStream,
|
string plateStream,
|
||||||
|
@ -41,7 +33,6 @@ namespace AIParkingApplication
|
||||||
ApiController apiController,
|
ApiController apiController,
|
||||||
EngineApiController engineApiController,
|
EngineApiController engineApiController,
|
||||||
Logger appLogger,
|
Logger appLogger,
|
||||||
string roiConfig,
|
|
||||||
bool isSupportSquarePlate = true,
|
bool isSupportSquarePlate = true,
|
||||||
bool isSupportLongPlate = false,
|
bool isSupportLongPlate = false,
|
||||||
bool isAutoOpenDoor = true,
|
bool isAutoOpenDoor = true,
|
||||||
|
@ -60,7 +51,6 @@ namespace AIParkingApplication
|
||||||
this.apiController = apiController;
|
this.apiController = apiController;
|
||||||
this.doorControlAccess = doorControlAccess;
|
this.doorControlAccess = doorControlAccess;
|
||||||
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||||
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||||
|
@ -157,20 +147,17 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
||||||
{
|
{
|
||||||
var starTime = DateTime.Now;
|
|
||||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
|
||||||
roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
|
|
||||||
Mat frameRoi = frame[roiBoxRect];
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var starTime = DateTime.Now;
|
||||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
|
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||||
|
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
|
|
||||||
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
|
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
Console.WriteLine("ProcessFrameImage Retry Mode");
|
Console.WriteLine("ProcessFrameImage Retry Mode");
|
||||||
}
|
}
|
||||||
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
|
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
|
||||||
|
@ -182,7 +169,7 @@ namespace AIParkingApplication
|
||||||
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: ex: {ex.Message}");
|
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: ex: {ex.Message}");
|
||||||
return new FinalPlateResult
|
return new FinalPlateResult
|
||||||
{
|
{
|
||||||
PlateImage = frameRoi,
|
PlateImage = frame,
|
||||||
PlateString = string.Empty,
|
PlateString = string.Empty,
|
||||||
PlateType = PlateType.Square
|
PlateType = PlateType.Square
|
||||||
};
|
};
|
||||||
|
@ -248,44 +235,5 @@ namespace AIParkingApplication
|
||||||
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
||||||
ConnectToDoorAccessControl();
|
ConnectToDoorAccessControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button == MouseButtons.Left)
|
|
||||||
{
|
|
||||||
StartPoint = e.Location;
|
|
||||||
pictureBoxRoi = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
|
|
||||||
IsDrawBox = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (IsDrawBox)
|
|
||||||
{
|
|
||||||
CurrentCursorPosition = e.Location;
|
|
||||||
pictureBoxRoi.Width = CurrentCursorPosition.X - StartPoint.X;
|
|
||||||
pictureBoxRoi.Height = CurrentCursorPosition.Y - StartPoint.Y;
|
|
||||||
}
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
IsDrawBox = false;
|
|
||||||
if (StartPoint.X + pictureBoxRoi.Width > pictureBoxPlateVideo.Width || StartPoint.Y + pictureBoxRoi.Height > pictureBoxPlateVideo.Height)
|
|
||||||
{
|
|
||||||
pictureBoxRoi.X = pictureBoxRoi.Y = 0;
|
|
||||||
pictureBoxRoi.Width = pictureBoxPlateVideo.Width;
|
|
||||||
pictureBoxRoi.Height = pictureBoxPlateVideo.Height;
|
|
||||||
}
|
|
||||||
apiController.SaveRoiToServer(pictureBoxRoi, cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
|
|
||||||
{
|
|
||||||
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
|
|
||||||
e.Graphics.DrawRectangle(redPen, pictureBoxRoi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -153,12 +153,6 @@
|
||||||
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</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">
|
<metadata name="lblStatusInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|
4
AIParkingApplication/LaneOut.Designer.cs
generated
4
AIParkingApplication/LaneOut.Designer.cs
generated
|
@ -182,10 +182,6 @@
|
||||||
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
this.pictureBoxPlateVideo.TabIndex = 0;
|
this.pictureBoxPlateVideo.TabIndex = 0;
|
||||||
this.pictureBoxPlateVideo.TabStop = false;
|
this.pictureBoxPlateVideo.TabStop = false;
|
||||||
this.pictureBoxPlateVideo.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxPlateVideo_Paint);
|
|
||||||
this.pictureBoxPlateVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseDown);
|
|
||||||
this.pictureBoxPlateVideo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseMove);
|
|
||||||
this.pictureBoxPlateVideo.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseUp);
|
|
||||||
//
|
//
|
||||||
// grbPlateCamera
|
// grbPlateCamera
|
||||||
//
|
//
|
||||||
|
|
|
@ -27,12 +27,6 @@ namespace AIParkingApplication
|
||||||
private Logger appLogger;
|
private Logger appLogger;
|
||||||
private bool isUsePrinter;
|
private bool isUsePrinter;
|
||||||
|
|
||||||
private System.Drawing.Point StartPoint { get; set; }
|
|
||||||
private System.Drawing.Point CurrentCursorPosition { get; set; }
|
|
||||||
private Rectangle pictureBoxRoi;
|
|
||||||
private bool IsDrawBox { get; set; }
|
|
||||||
private Rect roiBoxRect;
|
|
||||||
|
|
||||||
public LaneOut(int doorId,
|
public LaneOut(int doorId,
|
||||||
string cameraId,
|
string cameraId,
|
||||||
string plateStream,
|
string plateStream,
|
||||||
|
@ -41,7 +35,6 @@ namespace AIParkingApplication
|
||||||
ApiController apiController,
|
ApiController apiController,
|
||||||
EngineApiController engineApiController,
|
EngineApiController engineApiController,
|
||||||
Logger appLogger,
|
Logger appLogger,
|
||||||
string roiConfig,
|
|
||||||
bool isSupportSquarePlate = true,
|
bool isSupportSquarePlate = true,
|
||||||
bool isSupportLongPlate = false,
|
bool isSupportLongPlate = false,
|
||||||
bool isAutoOpenDoor = true,
|
bool isAutoOpenDoor = true,
|
||||||
|
@ -62,7 +55,6 @@ namespace AIParkingApplication
|
||||||
printer = new Printer(appLogger);
|
printer = new Printer(appLogger);
|
||||||
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||||
ReadUsePrinterConfig();
|
ReadUsePrinterConfig();
|
||||||
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||||
|
@ -199,13 +191,10 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
||||||
{
|
{
|
||||||
var starTime = DateTime.Now;
|
|
||||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
|
||||||
Rect roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
|
|
||||||
Mat frameRoi = frame[roiBoxRect];
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var starTime = DateTime.Now;
|
||||||
|
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
|
|
||||||
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||||
|
@ -326,44 +315,5 @@ namespace AIParkingApplication
|
||||||
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
|
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
|
||||||
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button == MouseButtons.Left)
|
|
||||||
{
|
|
||||||
StartPoint = e.Location;
|
|
||||||
pictureBoxRoi = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
|
|
||||||
IsDrawBox = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (IsDrawBox)
|
|
||||||
{
|
|
||||||
CurrentCursorPosition = e.Location;
|
|
||||||
pictureBoxRoi.Width = CurrentCursorPosition.X - StartPoint.X;
|
|
||||||
pictureBoxRoi.Height = CurrentCursorPosition.Y - StartPoint.Y;
|
|
||||||
}
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
IsDrawBox = false;
|
|
||||||
if (StartPoint.X + pictureBoxRoi.Width > pictureBoxPlateVideo.Width || StartPoint.Y + pictureBoxRoi.Height > pictureBoxPlateVideo.Height)
|
|
||||||
{
|
|
||||||
pictureBoxRoi.X = pictureBoxRoi.Y = 0;
|
|
||||||
pictureBoxRoi.Width = pictureBoxPlateVideo.Width;
|
|
||||||
pictureBoxRoi.Height = pictureBoxPlateVideo.Height;
|
|
||||||
}
|
|
||||||
apiController.SaveRoiToServer(pictureBoxRoi, cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
|
|
||||||
{
|
|
||||||
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
|
|
||||||
e.Graphics.DrawRectangle(redPen, pictureBoxRoi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,12 +126,6 @@
|
||||||
<metadata name="pictureBoxPlateImageIn.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="pictureBoxOverviewImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="pictureBoxPlateImageIn.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">
|
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -153,24 +147,6 @@
|
||||||
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="lblCardType.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="lblCardTimeOut.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="lblMoneyAmount.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="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="pictureBoxPlateImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="pictureBoxPlateImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OpenCvSharp;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -8,7 +7,6 @@ using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AIParkingApplication
|
namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
|
@ -137,30 +135,6 @@ namespace AIParkingApplication
|
||||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tAddOrUpdateAppSettings\t{ex.Message}");
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tAddOrUpdateAppSettings\t{ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rect ConvertRectangleToRect(Rectangle pictureBoxRoi, PictureBox pictureBoxPlateVideo)
|
|
||||||
{
|
|
||||||
Rect temp = new Rect
|
|
||||||
{
|
|
||||||
X = pictureBoxRoi.X * 1280 / pictureBoxPlateVideo.Width,
|
|
||||||
Y = pictureBoxRoi.Y * 720 / pictureBoxPlateVideo.Height,
|
|
||||||
Width = pictureBoxRoi.Width * 1280 / pictureBoxPlateVideo.Width,
|
|
||||||
Height = pictureBoxRoi.Height * 720 / pictureBoxPlateVideo.Height
|
|
||||||
};
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Rectangle ConvertStringToRectangle(string input)
|
|
||||||
{
|
|
||||||
var roi = JsonConvert.DeserializeObject<RoiConfig>(input);
|
|
||||||
return new Rectangle
|
|
||||||
{
|
|
||||||
X = roi.X,
|
|
||||||
Y = roi.Y,
|
|
||||||
Height = roi.Height,
|
|
||||||
Width = roi.Width
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlateRequestEngineModel
|
public class PlateRequestEngineModel
|
||||||
|
@ -191,22 +165,4 @@ namespace AIParkingApplication
|
||||||
public const string HTTP_POST_METHOD = "POST";
|
public const string HTTP_POST_METHOD = "POST";
|
||||||
public const string HTTP_POST_CONTENTTYPE = "application/json";
|
public const string HTTP_POST_CONTENTTYPE = "application/json";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RoiConfig
|
|
||||||
{
|
|
||||||
[JsonProperty("x")]
|
|
||||||
public int X { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("y")]
|
|
||||||
public int Y { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("width")]
|
|
||||||
public int Width { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("height")]
|
|
||||||
public int Height { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("camera_id")]
|
|
||||||
public string CameraID { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,5 @@
|
||||||
<package id="OpenCvSharp4" version="4.3.0.20200524" targetFramework="net461" />
|
<package id="OpenCvSharp4" version="4.3.0.20200524" targetFramework="net461" />
|
||||||
<package id="OpenCvSharp4.runtime.win" version="4.3.0.20200524" targetFramework="net461" />
|
<package id="OpenCvSharp4.runtime.win" version="4.3.0.20200524" targetFramework="net461" />
|
||||||
<package id="OpenCvSharp4.Windows" version="4.3.0.20200524" targetFramework="net461" />
|
<package id="OpenCvSharp4.Windows" version="4.3.0.20200524" targetFramework="net461" />
|
||||||
<package id="System.Net.Http" version="4.3.4" targetFramework="net461" />
|
|
||||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
|
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user