Compare commits
13 Commits
6284909fd8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d97908a22b | ||
|
|
9400402141 | ||
|
|
59208674e0 | ||
|
|
aa73bf8129 | ||
|
|
aa1aae8c6c | ||
|
|
1671d3b456 | ||
|
|
a3543084b7 | ||
|
|
89e766714a | ||
|
|
fd96643412 | ||
|
|
1418b1077e | ||
|
|
53aa3e31ea | ||
|
|
076290e141 | ||
|
|
c0c8b325d0 |
@@ -93,6 +93,9 @@
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<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">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -109,7 +112,6 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
@@ -125,6 +127,12 @@
|
||||
<Compile Include="AppConstant.cs" />
|
||||
<Compile Include="C3DeviceController.cs" />
|
||||
<Compile Include="Camera.cs" />
|
||||
<Compile Include="ConfigurationForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ConfigurationForm.Designer.cs">
|
||||
<DependentUpon>ConfigurationForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EngineApiController.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="ExtensitionMethods.cs" />
|
||||
@@ -175,6 +183,9 @@
|
||||
<EmbeddedResource Include="AIParkingApplicationForm.resx">
|
||||
<DependentUpon>AIParkingApplicationForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ConfigurationForm.resx">
|
||||
<DependentUpon>ConfigurationForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="LaneIn.resx">
|
||||
<DependentUpon>LaneIn.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -35,13 +35,15 @@
|
||||
this.toolStripMenuItemSwitchLaneInOut = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSwitchLaneOutOut = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSwitchLaneOutIn = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.setupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItemSwitchLane});
|
||||
this.toolStripMenuItemSwitchLane,
|
||||
this.setupToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1366, 24);
|
||||
@@ -62,31 +64,38 @@
|
||||
// toolStripMenuItemSwitchLaneInIn
|
||||
//
|
||||
this.toolStripMenuItemSwitchLaneInIn.Name = "toolStripMenuItemSwitchLaneInIn";
|
||||
this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(123, 22);
|
||||
this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(180, 22);
|
||||
this.toolStripMenuItemSwitchLaneInIn.Text = "Vào - Vào";
|
||||
this.toolStripMenuItemSwitchLaneInIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneInIn_Click);
|
||||
//
|
||||
// toolStripMenuItemSwitchLaneInOut
|
||||
//
|
||||
this.toolStripMenuItemSwitchLaneInOut.Name = "toolStripMenuItemSwitchLaneInOut";
|
||||
this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(123, 22);
|
||||
this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(180, 22);
|
||||
this.toolStripMenuItemSwitchLaneInOut.Text = "Vào - Ra";
|
||||
this.toolStripMenuItemSwitchLaneInOut.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneInOut_Click);
|
||||
//
|
||||
// toolStripMenuItemSwitchLaneOutOut
|
||||
//
|
||||
this.toolStripMenuItemSwitchLaneOutOut.Name = "toolStripMenuItemSwitchLaneOutOut";
|
||||
this.toolStripMenuItemSwitchLaneOutOut.Size = new System.Drawing.Size(123, 22);
|
||||
this.toolStripMenuItemSwitchLaneOutOut.Size = new System.Drawing.Size(180, 22);
|
||||
this.toolStripMenuItemSwitchLaneOutOut.Text = "Ra - Ra";
|
||||
this.toolStripMenuItemSwitchLaneOutOut.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneOutOut_Click);
|
||||
//
|
||||
// toolStripMenuItemSwitchLaneOutIn
|
||||
//
|
||||
this.toolStripMenuItemSwitchLaneOutIn.Name = "toolStripMenuItemSwitchLaneOutIn";
|
||||
this.toolStripMenuItemSwitchLaneOutIn.Size = new System.Drawing.Size(123, 22);
|
||||
this.toolStripMenuItemSwitchLaneOutIn.Size = new System.Drawing.Size(180, 22);
|
||||
this.toolStripMenuItemSwitchLaneOutIn.Text = "Ra - Vào";
|
||||
this.toolStripMenuItemSwitchLaneOutIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneOutIn_Click);
|
||||
//
|
||||
// setupToolStripMenuItem
|
||||
//
|
||||
this.setupToolStripMenuItem.Name = "setupToolStripMenuItem";
|
||||
this.setupToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.setupToolStripMenuItem.Text = "Cài đặt";
|
||||
this.setupToolStripMenuItem.Click += new System.EventHandler(this.setupToolStripMenuItem_Click);
|
||||
//
|
||||
// AIParkingApplicationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -116,6 +125,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneInOut;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutOut;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutIn;
|
||||
private System.Windows.Forms.ToolStripMenuItem setupToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace AIParkingApplication
|
||||
{
|
||||
public partial class AIParkingApplicationForm : Form
|
||||
{
|
||||
private const string CURRENT_LANE_SETTING_KEY = "CURRENT_LANE_SETTING";
|
||||
|
||||
private ApiController apiController;
|
||||
private IDoorControlAccess c3Device;
|
||||
private LaneIn laneIn12;
|
||||
@@ -79,22 +77,22 @@ namespace AIParkingApplication
|
||||
|
||||
private void InitAllLanes()
|
||||
{
|
||||
laneIn12 = new LaneIn(10, configOnWeb.CameraData1.Id.ToString(), configOnWeb.CameraData1.StreamUrl, configOnWeb.CameraData2.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||
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.BorderStyle = BorderStyle.FixedSingle;
|
||||
laneIn12.Hide();
|
||||
Controls.Add(laneIn12);
|
||||
|
||||
laneOut34 = new LaneOut(20, configOnWeb.CameraData3.Id.ToString(), configOnWeb.CameraData3.StreamUrl, configOnWeb.CameraData4.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||
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.BorderStyle = BorderStyle.FixedSingle;
|
||||
laneOut34.Hide();
|
||||
Controls.Add(laneOut34);
|
||||
|
||||
laneIn56 = new LaneIn(10, configOnWeb.CameraData5.Id.ToString(), configOnWeb.CameraData5.StreamUrl, configOnWeb.CameraData6.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||
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.BorderStyle = BorderStyle.FixedSingle;
|
||||
laneIn56.Hide();
|
||||
Controls.Add(laneIn56);
|
||||
|
||||
laneOut78 = new LaneOut(20, configOnWeb.CameraData7.Id.ToString(), configOnWeb.CameraData7.StreamUrl, configOnWeb.CameraData8.StreamUrl, c3Device, apiController, engineApiController, appLogger, true, false, true);
|
||||
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.BorderStyle = BorderStyle.FixedSingle;
|
||||
laneOut78.Hide();
|
||||
Controls.Add(laneOut78);
|
||||
@@ -154,7 +152,7 @@ namespace AIParkingApplication
|
||||
|
||||
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-IN");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-IN");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneInIn();
|
||||
@@ -163,7 +161,7 @@ namespace AIParkingApplication
|
||||
|
||||
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneInOut();
|
||||
@@ -172,7 +170,7 @@ namespace AIParkingApplication
|
||||
|
||||
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-IN");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-IN");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneOutIn();
|
||||
@@ -181,7 +179,7 @@ namespace AIParkingApplication
|
||||
|
||||
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-OUT");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-OUT");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneOutOut();
|
||||
@@ -227,7 +225,7 @@ namespace AIParkingApplication
|
||||
{
|
||||
try
|
||||
{
|
||||
string lanesConfig = ConfigurationManager.AppSettings[CURRENT_LANE_SETTING_KEY];
|
||||
string lanesConfig = ConfigurationManager.AppSettings[AppConstant.CURRENT_LANE_SETTING];
|
||||
if (!string.IsNullOrEmpty(lanesConfig))
|
||||
{
|
||||
string[] lanes = lanesConfig.Split('-');
|
||||
@@ -262,7 +260,7 @@ namespace AIParkingApplication
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
|
||||
UpdateLaneInOut();
|
||||
toolStripMenuItemSwitchLaneInOut.DisableSelected();
|
||||
appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT");
|
||||
@@ -271,7 +269,7 @@ namespace AIParkingApplication
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
||||
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
|
||||
UpdateLaneInOut();
|
||||
toolStripMenuItemSwitchLaneInOut.DisableSelected();
|
||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
|
||||
@@ -283,13 +281,13 @@ namespace AIParkingApplication
|
||||
{
|
||||
try
|
||||
{
|
||||
doorAccessControlDeviceIP = ConfigurationManager.AppSettings["DOOR_ACCESS_DEVICE_CONTROL_IP"].Trim();
|
||||
doorAccessControlDeviceIP = ConfigurationManager.AppSettings[AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP].Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
doorAccessControlDeviceIP = string.Empty;
|
||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||
appLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi(DOOR_ACCESS_DEVICE_CONTROL_IP)!\texMessage: {ex.Message}");
|
||||
appLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi({AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP})!\texMessage: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,5 +302,11 @@ namespace AIParkingApplication
|
||||
appLogger.Log(LogLevel.Info, $"Đóng ứng dụng");
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void setupToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var configurationForm = new ConfigurationForm(appLogger);
|
||||
configurationForm.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using OpenCvSharp;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
using NLog;
|
||||
using System.Drawing;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
@@ -150,6 +151,36 @@ 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()
|
||||
{
|
||||
if (httpClient != null && !isHttpClientDisposabled)
|
||||
@@ -487,6 +518,7 @@ namespace AIParkingApplication
|
||||
public int Logs { get; set; }
|
||||
}
|
||||
|
||||
|
||||
#region LaneConfig
|
||||
public class LaneConfig
|
||||
{
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
<add key="CURRENT_LANE_SETTING" value="IN-OUT" />
|
||||
<add key="AUTO_LOGIN" value="false" />
|
||||
<add key="USE_PRINTER" value="false" />
|
||||
<add key="AUTO_OPEN_DOOR_1" value="true" />
|
||||
<add key="AUTO_OPEN_DOOR_2" value="true" />
|
||||
<add key="ALLOW_CHANGE_ROI_RECT" value="true" />
|
||||
<add key="AUTO_RUN_AT_STARTUP" value="false" />
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
@@ -18,6 +22,10 @@
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</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>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
||||
@@ -6,11 +6,25 @@
|
||||
public const string ERROR_TITLE = "Lỗi";
|
||||
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
|
||||
|
||||
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
|
||||
public const string CAMERA_FAILED_IMAGE_PATH = @".\Images\CantConnectCamera.jpg";
|
||||
public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico";
|
||||
|
||||
public const string APPLICATION_LOGGER_NAME = "ApplicationLogger";
|
||||
public const string PING_SERVER_LOGGER_NAME = "PingServerLogger";
|
||||
public const string PING_DOOR_DEVICE_CONTROL_ACCESS_LOGGER_NAME = "PingDoorDeviceControlAccessLogger";
|
||||
|
||||
#region App Config Key
|
||||
public const string DOOR_ACCESS_DEVICE_CONTROL_IP = "DOOR_ACCESS_DEVICE_CONTROL_IP";
|
||||
public const string DEFAULT_USERNAME = "DEFAULT_USERNAME";
|
||||
public const string DEFAULT_PASSWORD = "DEFAULT_PASSWORD";
|
||||
public const string DEFAULT_WEB_SERVER = "DEFAULT_WEB_SERVER";
|
||||
public const string CURRENT_LANE_SETTING = "CURRENT_LANE_SETTING";
|
||||
public const string AUTO_LOGIN = "AUTO_LOGIN";
|
||||
public const string USE_PRINTER = "USE_PRINTER";
|
||||
public const string AUTO_OPEN_DOOR_1 = "AUTO_OPEN_DOOR_1";
|
||||
public const string AUTO_OPEN_DOOR_2 = "AUTO_OPEN_DOOR_2";
|
||||
public const string ALLOW_CHANGE_ROI_RECT = "ALLOW_CHANGE_ROI_RECT";
|
||||
public const string AUTO_RUN_AT_STARTUP = "AUTO_RUN_AT_STARTUP";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using OpenCvSharp;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace AIParkingApplication
|
||||
{
|
||||
if (!videoCapture.Open(streamUrl))
|
||||
{
|
||||
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
|
||||
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace AIParkingApplication
|
||||
}
|
||||
else
|
||||
{
|
||||
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
|
||||
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
290
AIParkingApplication/ConfigurationForm.Designer.cs
generated
Normal file
290
AIParkingApplication/ConfigurationForm.Designer.cs
generated
Normal file
@@ -0,0 +1,290 @@
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
partial class ConfigurationForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblDoorDeviceControlAccessIPStatus = new System.Windows.Forms.Label();
|
||||
this.btnCheckDoorDeviceControlAccessIP = new System.Windows.Forms.Button();
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.btnSaveSettings = new System.Windows.Forms.Button();
|
||||
this.chkAllowChangeROIRect = new System.Windows.Forms.CheckBox();
|
||||
this.chkAllowAutoDoor2 = new System.Windows.Forms.CheckBox();
|
||||
this.chkAllowAutoDoor1 = new System.Windows.Forms.CheckBox();
|
||||
this.lblAllowChangeROIRect = new System.Windows.Forms.Label();
|
||||
this.lblAllowAutoOpenDoorIn = new System.Windows.Forms.Label();
|
||||
this.txtDoorDeviceControlAccessIP = new System.Windows.Forms.TextBox();
|
||||
this.lblDoorDeviceControlAccessIP = new System.Windows.Forms.Label();
|
||||
this.lblAllowUsePrinter = new System.Windows.Forms.Label();
|
||||
this.chkAllowUsePrinter = new System.Windows.Forms.CheckBox();
|
||||
this.lblAllowAutoLogin = new System.Windows.Forms.Label();
|
||||
this.chkAllowAutoLogin = new System.Windows.Forms.CheckBox();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSavedSettingStatus = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.lblAllowAutoRun = new System.Windows.Forms.Label();
|
||||
this.chkAllowAutoRunAtStartUp = new System.Windows.Forms.CheckBox();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblDoorDeviceControlAccessIPStatus
|
||||
//
|
||||
this.lblDoorDeviceControlAccessIPStatus.AutoSize = true;
|
||||
this.lblDoorDeviceControlAccessIPStatus.Location = new System.Drawing.Point(412, 9);
|
||||
this.lblDoorDeviceControlAccessIPStatus.Name = "lblDoorDeviceControlAccessIPStatus";
|
||||
this.lblDoorDeviceControlAccessIPStatus.Size = new System.Drawing.Size(58, 13);
|
||||
this.lblDoorDeviceControlAccessIPStatus.TabIndex = 17;
|
||||
this.lblDoorDeviceControlAccessIPStatus.Text = "Trạng thái:";
|
||||
//
|
||||
// btnCheckDoorDeviceControlAccessIP
|
||||
//
|
||||
this.btnCheckDoorDeviceControlAccessIP.Location = new System.Drawing.Point(330, 3);
|
||||
this.btnCheckDoorDeviceControlAccessIP.Name = "btnCheckDoorDeviceControlAccessIP";
|
||||
this.btnCheckDoorDeviceControlAccessIP.Size = new System.Drawing.Size(75, 24);
|
||||
this.btnCheckDoorDeviceControlAccessIP.TabIndex = 2;
|
||||
this.btnCheckDoorDeviceControlAccessIP.Text = "Kiểm tra";
|
||||
this.btnCheckDoorDeviceControlAccessIP.UseVisualStyleBackColor = true;
|
||||
this.btnCheckDoorDeviceControlAccessIP.Click += new System.EventHandler(this.btnCheckDoorDeviceControlAccessIP_Click);
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.Location = new System.Drawing.Point(528, 207);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(106, 41);
|
||||
this.btnClose.TabIndex = 7;
|
||||
this.btnClose.Text = "Đóng";
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||
//
|
||||
// btnSaveSettings
|
||||
//
|
||||
this.btnSaveSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnSaveSettings.Location = new System.Drawing.Point(416, 207);
|
||||
this.btnSaveSettings.Name = "btnSaveSettings";
|
||||
this.btnSaveSettings.Size = new System.Drawing.Size(106, 41);
|
||||
this.btnSaveSettings.TabIndex = 0;
|
||||
this.btnSaveSettings.Text = "Lưu";
|
||||
this.btnSaveSettings.UseVisualStyleBackColor = true;
|
||||
this.btnSaveSettings.Click += new System.EventHandler(this.btnSaveSettings_Click);
|
||||
//
|
||||
// chkAllowChangeROIRect
|
||||
//
|
||||
this.chkAllowChangeROIRect.AutoSize = true;
|
||||
this.chkAllowChangeROIRect.Location = new System.Drawing.Point(252, 95);
|
||||
this.chkAllowChangeROIRect.Name = "chkAllowChangeROIRect";
|
||||
this.chkAllowChangeROIRect.Size = new System.Drawing.Size(72, 17);
|
||||
this.chkAllowChangeROIRect.TabIndex = 5;
|
||||
this.chkAllowChangeROIRect.Text = "Cho phép";
|
||||
this.chkAllowChangeROIRect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkAllowAutoDoor2
|
||||
//
|
||||
this.chkAllowAutoDoor2.AutoSize = true;
|
||||
this.chkAllowAutoDoor2.Location = new System.Drawing.Point(252, 37);
|
||||
this.chkAllowAutoDoor2.Name = "chkAllowAutoDoor2";
|
||||
this.chkAllowAutoDoor2.Size = new System.Drawing.Size(68, 17);
|
||||
this.chkAllowAutoDoor2.TabIndex = 4;
|
||||
this.chkAllowAutoDoor2.Text = "Cửa số 2";
|
||||
this.chkAllowAutoDoor2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkAllowAutoDoor1
|
||||
//
|
||||
this.chkAllowAutoDoor1.AutoSize = true;
|
||||
this.chkAllowAutoDoor1.Location = new System.Drawing.Point(141, 37);
|
||||
this.chkAllowAutoDoor1.Name = "chkAllowAutoDoor1";
|
||||
this.chkAllowAutoDoor1.Size = new System.Drawing.Size(68, 17);
|
||||
this.chkAllowAutoDoor1.TabIndex = 3;
|
||||
this.chkAllowAutoDoor1.Text = "Cửa số 1";
|
||||
this.chkAllowAutoDoor1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblAllowChangeROIRect
|
||||
//
|
||||
this.lblAllowChangeROIRect.AutoSize = true;
|
||||
this.lblAllowChangeROIRect.Location = new System.Drawing.Point(11, 96);
|
||||
this.lblAllowChangeROIRect.Name = "lblAllowChangeROIRect";
|
||||
this.lblAllowChangeROIRect.Size = new System.Drawing.Size(211, 13);
|
||||
this.lblAllowChangeROIRect.TabIndex = 9;
|
||||
this.lblAllowChangeROIRect.Text = "Cho phép thay đổi vùng nhận diện biển số:";
|
||||
//
|
||||
// lblAllowAutoOpenDoorIn
|
||||
//
|
||||
this.lblAllowAutoOpenDoorIn.AutoSize = true;
|
||||
this.lblAllowAutoOpenDoorIn.Location = new System.Drawing.Point(11, 39);
|
||||
this.lblAllowAutoOpenDoorIn.Name = "lblAllowAutoOpenDoorIn";
|
||||
this.lblAllowAutoOpenDoorIn.Size = new System.Drawing.Size(89, 13);
|
||||
this.lblAllowAutoOpenDoorIn.TabIndex = 10;
|
||||
this.lblAllowAutoOpenDoorIn.Text = "Tự động mở cửa:";
|
||||
//
|
||||
// txtDoorDeviceControlAccessIP
|
||||
//
|
||||
this.txtDoorDeviceControlAccessIP.Location = new System.Drawing.Point(141, 5);
|
||||
this.txtDoorDeviceControlAccessIP.Name = "txtDoorDeviceControlAccessIP";
|
||||
this.txtDoorDeviceControlAccessIP.Size = new System.Drawing.Size(183, 20);
|
||||
this.txtDoorDeviceControlAccessIP.TabIndex = 1;
|
||||
//
|
||||
// lblDoorDeviceControlAccessIP
|
||||
//
|
||||
this.lblDoorDeviceControlAccessIP.AutoSize = true;
|
||||
this.lblDoorDeviceControlAccessIP.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblDoorDeviceControlAccessIP.Name = "lblDoorDeviceControlAccessIP";
|
||||
this.lblDoorDeviceControlAccessIP.Size = new System.Drawing.Size(96, 13);
|
||||
this.lblDoorDeviceControlAccessIP.TabIndex = 7;
|
||||
this.lblDoorDeviceControlAccessIP.Text = "IP Thiết bị mở cửa:";
|
||||
//
|
||||
// lblAllowUsePrinter
|
||||
//
|
||||
this.lblAllowUsePrinter.AutoSize = true;
|
||||
this.lblAllowUsePrinter.Location = new System.Drawing.Point(11, 67);
|
||||
this.lblAllowUsePrinter.Name = "lblAllowUsePrinter";
|
||||
this.lblAllowUsePrinter.Size = new System.Drawing.Size(83, 13);
|
||||
this.lblAllowUsePrinter.TabIndex = 9;
|
||||
this.lblAllowUsePrinter.Text = "Sử dụng máy in:";
|
||||
//
|
||||
// chkAllowUsePrinter
|
||||
//
|
||||
this.chkAllowUsePrinter.AutoSize = true;
|
||||
this.chkAllowUsePrinter.Location = new System.Drawing.Point(141, 66);
|
||||
this.chkAllowUsePrinter.Name = "chkAllowUsePrinter";
|
||||
this.chkAllowUsePrinter.Size = new System.Drawing.Size(66, 17);
|
||||
this.chkAllowUsePrinter.TabIndex = 5;
|
||||
this.chkAllowUsePrinter.Text = "Sử dụng";
|
||||
this.chkAllowUsePrinter.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblAllowAutoLogin
|
||||
//
|
||||
this.lblAllowAutoLogin.AutoSize = true;
|
||||
this.lblAllowAutoLogin.Location = new System.Drawing.Point(11, 129);
|
||||
this.lblAllowAutoLogin.Name = "lblAllowAutoLogin";
|
||||
this.lblAllowAutoLogin.Size = new System.Drawing.Size(106, 13);
|
||||
this.lblAllowAutoLogin.TabIndex = 9;
|
||||
this.lblAllowAutoLogin.Text = "Tự động đăng nhập:";
|
||||
//
|
||||
// chkAllowAutoLogin
|
||||
//
|
||||
this.chkAllowAutoLogin.AutoSize = true;
|
||||
this.chkAllowAutoLogin.Location = new System.Drawing.Point(141, 128);
|
||||
this.chkAllowAutoLogin.Name = "chkAllowAutoLogin";
|
||||
this.chkAllowAutoLogin.Size = new System.Drawing.Size(66, 17);
|
||||
this.chkAllowAutoLogin.TabIndex = 5;
|
||||
this.chkAllowAutoLogin.Text = "Sử dụng";
|
||||
this.chkAllowAutoLogin.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSavedSettingStatus});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 259);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(646, 22);
|
||||
this.statusStrip.TabIndex = 18;
|
||||
this.statusStrip.Text = "statusStrip";
|
||||
//
|
||||
// toolStripStatusLabelSavedSettingStatus
|
||||
//
|
||||
this.toolStripStatusLabelSavedSettingStatus.Name = "toolStripStatusLabelSavedSettingStatus";
|
||||
this.toolStripStatusLabelSavedSettingStatus.Size = new System.Drawing.Size(110, 17);
|
||||
this.toolStripStatusLabelSavedSettingStatus.Text = "Cấu hình ứng dụng";
|
||||
//
|
||||
// lblAllowAutoRun
|
||||
//
|
||||
this.lblAllowAutoRun.AutoSize = true;
|
||||
this.lblAllowAutoRun.Location = new System.Drawing.Point(11, 161);
|
||||
this.lblAllowAutoRun.Name = "lblAllowAutoRun";
|
||||
this.lblAllowAutoRun.Size = new System.Drawing.Size(122, 13);
|
||||
this.lblAllowAutoRun.TabIndex = 9;
|
||||
this.lblAllowAutoRun.Text = "Tự khởi động ứng dụng:";
|
||||
//
|
||||
// chkAllowAutoRunAtStartUp
|
||||
//
|
||||
this.chkAllowAutoRunAtStartUp.AutoSize = true;
|
||||
this.chkAllowAutoRunAtStartUp.Location = new System.Drawing.Point(141, 160);
|
||||
this.chkAllowAutoRunAtStartUp.Name = "chkAllowAutoRunAtStartUp";
|
||||
this.chkAllowAutoRunAtStartUp.Size = new System.Drawing.Size(66, 17);
|
||||
this.chkAllowAutoRunAtStartUp.TabIndex = 5;
|
||||
this.chkAllowAutoRunAtStartUp.Text = "Sử dụng";
|
||||
this.chkAllowAutoRunAtStartUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ConfigurationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(646, 281);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Controls.Add(this.lblDoorDeviceControlAccessIPStatus);
|
||||
this.Controls.Add(this.btnCheckDoorDeviceControlAccessIP);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.btnSaveSettings);
|
||||
this.Controls.Add(this.chkAllowAutoRunAtStartUp);
|
||||
this.Controls.Add(this.chkAllowAutoLogin);
|
||||
this.Controls.Add(this.chkAllowUsePrinter);
|
||||
this.Controls.Add(this.chkAllowChangeROIRect);
|
||||
this.Controls.Add(this.lblAllowAutoRun);
|
||||
this.Controls.Add(this.chkAllowAutoDoor2);
|
||||
this.Controls.Add(this.lblAllowAutoLogin);
|
||||
this.Controls.Add(this.chkAllowAutoDoor1);
|
||||
this.Controls.Add(this.lblAllowUsePrinter);
|
||||
this.Controls.Add(this.lblAllowChangeROIRect);
|
||||
this.Controls.Add(this.lblAllowAutoOpenDoorIn);
|
||||
this.Controls.Add(this.txtDoorDeviceControlAccessIP);
|
||||
this.Controls.Add(this.lblDoorDeviceControlAccessIP);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximumSize = new System.Drawing.Size(662, 320);
|
||||
this.MinimumSize = new System.Drawing.Size(662, 320);
|
||||
this.Name = "ConfigurationForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Cấu hình ứng dụng";
|
||||
this.Load += new System.EventHandler(this.ConfigurationForm_Load);
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label lblDoorDeviceControlAccessIPStatus;
|
||||
private System.Windows.Forms.Button btnCheckDoorDeviceControlAccessIP;
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.Button btnSaveSettings;
|
||||
private System.Windows.Forms.CheckBox chkAllowChangeROIRect;
|
||||
private System.Windows.Forms.CheckBox chkAllowAutoDoor2;
|
||||
private System.Windows.Forms.CheckBox chkAllowAutoDoor1;
|
||||
private System.Windows.Forms.Label lblAllowChangeROIRect;
|
||||
private System.Windows.Forms.Label lblAllowAutoOpenDoorIn;
|
||||
private System.Windows.Forms.TextBox txtDoorDeviceControlAccessIP;
|
||||
private System.Windows.Forms.Label lblDoorDeviceControlAccessIP;
|
||||
private System.Windows.Forms.Label lblAllowUsePrinter;
|
||||
private System.Windows.Forms.CheckBox chkAllowUsePrinter;
|
||||
private System.Windows.Forms.Label lblAllowAutoLogin;
|
||||
private System.Windows.Forms.CheckBox chkAllowAutoLogin;
|
||||
private System.Windows.Forms.StatusStrip statusStrip;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSavedSettingStatus;
|
||||
private System.Windows.Forms.Label lblAllowAutoRun;
|
||||
private System.Windows.Forms.CheckBox chkAllowAutoRunAtStartUp;
|
||||
}
|
||||
}
|
||||
108
AIParkingApplication/ConfigurationForm.cs
Normal file
108
AIParkingApplication/ConfigurationForm.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
public partial class ConfigurationForm : Form
|
||||
{
|
||||
private Logger appLogger;
|
||||
private string doorAccessControlDeviceIP;
|
||||
private bool allowAutoOpenDoor1;
|
||||
private bool allowAutoOpenDoor2;
|
||||
private bool allowUsePrinter;
|
||||
private bool allowChangeROIRect;
|
||||
private bool allowAutoLogin;
|
||||
private bool allowAutoRunAtStartUp;
|
||||
|
||||
public ConfigurationForm(Logger appLogger)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.appLogger = appLogger;
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnSaveSettings_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text);
|
||||
if (!isValidIPAddress)
|
||||
{
|
||||
MessageBox.Show("Nhập đúng IP thiết bị mở cửa!");
|
||||
return;
|
||||
}
|
||||
Util.UpsertAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, txtDoorDeviceControlAccessIP.Text);
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_1, chkAllowAutoDoor1.Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_2, chkAllowAutoDoor2.Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.USE_PRINTER, chkAllowUsePrinter.Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, chkAllowChangeROIRect.Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, chkAllowAutoLogin.Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, chkAllowAutoRunAtStartUp.Checked.ToString().ToLower());
|
||||
if (chkAllowAutoRunAtStartUp.Checked)
|
||||
{
|
||||
Util.AddApplicationToStartup();
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.RemoveApplicationFromStartup();
|
||||
}
|
||||
toolStripStatusLabelSavedSettingStatus.Text = $"{DateTime.Now.GetTimeFormatted()} Đã lưu cài đặt";
|
||||
}
|
||||
|
||||
private void ConfigurationForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadConfiguration();
|
||||
txtDoorDeviceControlAccessIP.Text = doorAccessControlDeviceIP;
|
||||
chkAllowAutoDoor1.Checked = allowAutoOpenDoor1;
|
||||
chkAllowAutoDoor2.Checked = allowAutoOpenDoor2;
|
||||
chkAllowUsePrinter.Checked = allowUsePrinter;
|
||||
chkAllowChangeROIRect.Checked = allowChangeROIRect;
|
||||
chkAllowAutoLogin.Checked = allowAutoLogin;
|
||||
chkAllowAutoRunAtStartUp.Checked = allowAutoRunAtStartUp;
|
||||
}
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
doorAccessControlDeviceIP = ReadConfigurationFromAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, string.Empty);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_1, "false"), out allowAutoOpenDoor1);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_2, "false"), out allowAutoOpenDoor2);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.USE_PRINTER, "false"), out allowUsePrinter);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, "false"), out allowChangeROIRect);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_LOGIN, "false"), out allowAutoLogin);
|
||||
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, "false"), out allowAutoRunAtStartUp);
|
||||
}
|
||||
|
||||
private string ReadConfigurationFromAppSettings(string configurationKey, string defaultValueIfReadFailed)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ConfigurationManager.AppSettings[configurationKey].Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.UpsertAppSettings(configurationKey, defaultValueIfReadFailed);
|
||||
Console.WriteLine($"ReadDoorDeviceControlAccessConfiguration. ex: {ex.Message}");
|
||||
appLogger.Log(LogLevel.Info, $"ConfigurationForm - ReadConfigurationFromAppSettings. Key: {configurationKey} - DefaultValue: {defaultValueIfReadFailed}. ex: {ex.Message}");
|
||||
return defaultValueIfReadFailed;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheckDoorDeviceControlAccessIP_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblDoorDeviceControlAccessIPStatus.Text = string.Empty;
|
||||
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text);
|
||||
if (!isValidIPAddress)
|
||||
{
|
||||
lblDoorDeviceControlAccessIPStatus.Text = "Không đúng định dạng IP";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblDoorDeviceControlAccessIPStatus.Text = "OK";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
AIParkingApplication/ConfigurationForm.resx
Normal file
123
AIParkingApplication/ConfigurationForm.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
4
AIParkingApplication/LaneIn.Designer.cs
generated
4
AIParkingApplication/LaneIn.Designer.cs
generated
@@ -69,6 +69,10 @@
|
||||
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBoxPlateVideo.TabIndex = 0;
|
||||
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
|
||||
//
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
@@ -25,6 +27,12 @@ namespace AIParkingApplication
|
||||
private ApiController apiController;
|
||||
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,
|
||||
string cameraId,
|
||||
string plateStream,
|
||||
@@ -33,6 +41,7 @@ namespace AIParkingApplication
|
||||
ApiController apiController,
|
||||
EngineApiController engineApiController,
|
||||
Logger appLogger,
|
||||
string roiConfig,
|
||||
bool isSupportSquarePlate = true,
|
||||
bool isSupportLongPlate = false,
|
||||
bool isAutoOpenDoor = true,
|
||||
@@ -51,6 +60,7 @@ namespace AIParkingApplication
|
||||
this.apiController = apiController;
|
||||
this.doorControlAccess = doorControlAccess;
|
||||
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
|
||||
}
|
||||
|
||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||
@@ -146,18 +156,21 @@ namespace AIParkingApplication
|
||||
}
|
||||
|
||||
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var starTime = DateTime.Now;
|
||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||
roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
|
||||
Mat frameRoi = frame[roiBoxRect];
|
||||
try
|
||||
{
|
||||
|
||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
|
||||
|
||||
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
overviewCamera.RequestCaptureOneFrame();
|
||||
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||
finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
|
||||
Console.WriteLine("ProcessFrameImage Retry Mode");
|
||||
}
|
||||
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
|
||||
@@ -169,7 +182,7 @@ namespace AIParkingApplication
|
||||
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: ex: {ex.Message}");
|
||||
return new FinalPlateResult
|
||||
{
|
||||
PlateImage = frame,
|
||||
PlateImage = frameRoi,
|
||||
PlateString = string.Empty,
|
||||
PlateType = PlateType.Square
|
||||
};
|
||||
@@ -235,5 +248,44 @@ namespace AIParkingApplication
|
||||
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
||||
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,6 +153,12 @@
|
||||
<metadata name="lblPlateString.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>
|
||||
|
||||
4
AIParkingApplication/LaneOut.Designer.cs
generated
4
AIParkingApplication/LaneOut.Designer.cs
generated
@@ -182,6 +182,10 @@
|
||||
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBoxPlateVideo.TabIndex = 0;
|
||||
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
|
||||
//
|
||||
|
||||
@@ -27,6 +27,12 @@ namespace AIParkingApplication
|
||||
private Logger appLogger;
|
||||
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,
|
||||
string cameraId,
|
||||
string plateStream,
|
||||
@@ -35,6 +41,7 @@ namespace AIParkingApplication
|
||||
ApiController apiController,
|
||||
EngineApiController engineApiController,
|
||||
Logger appLogger,
|
||||
string roiConfig,
|
||||
bool isSupportSquarePlate = true,
|
||||
bool isSupportLongPlate = false,
|
||||
bool isAutoOpenDoor = true,
|
||||
@@ -55,6 +62,7 @@ namespace AIParkingApplication
|
||||
printer = new Printer(appLogger);
|
||||
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||
ReadUsePrinterConfig();
|
||||
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
|
||||
}
|
||||
|
||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||
@@ -148,12 +156,12 @@ namespace AIParkingApplication
|
||||
{
|
||||
try
|
||||
{
|
||||
bool.TryParse(ConfigurationManager.AppSettings["USE_PRINTER"], out isUsePrinter);
|
||||
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.USE_PRINTER], out isUsePrinter);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.UpsertAppSettings("USE_PRINTER", "false");
|
||||
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER. ex: {ex.Message }");
|
||||
Util.UpsertAppSettings(AppConstant.USE_PRINTER, "false");
|
||||
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: {AppConstant.USE_PRINTER}. ex: {ex.Message }");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,11 +198,14 @@ namespace AIParkingApplication
|
||||
}
|
||||
|
||||
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var starTime = DateTime.Now;
|
||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||
Rect roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
|
||||
Mat frameRoi = frame[roiBoxRect];
|
||||
try
|
||||
{
|
||||
|
||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||
|
||||
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||
@@ -315,5 +326,44 @@ namespace AIParkingApplication
|
||||
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
|
||||
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,6 +126,12 @@
|
||||
<metadata name="pictureBoxPlateImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</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">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
@@ -147,6 +153,24 @@
|
||||
<metadata name="lblCardNumber.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="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">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
@@ -20,9 +19,10 @@ namespace AIParkingApplication
|
||||
applicationLogger = LogManager.GetLogger(AppConstant.APPLICATION_LOGGER_NAME);
|
||||
applicationLogger.Log(LogLevel.Info, new string('-', 20));
|
||||
isAutoLogin = false;
|
||||
if (File.Exists(AppConstant.DEFAULT_LOGO_IMAGE))
|
||||
string defaultLogoImagePath = Application.StartupPath + AppConstant.DEFAULT_LOGO_IMAGE;
|
||||
if (File.Exists(defaultLogoImagePath))
|
||||
{
|
||||
pictureBoxImageLogo.Image = new Bitmap(AppConstant.DEFAULT_LOGO_IMAGE);
|
||||
pictureBoxImageLogo.Image = new Bitmap(defaultLogoImagePath);
|
||||
}
|
||||
txtUsername.Focus();
|
||||
lblLoginStatus.Text = string.Empty;
|
||||
@@ -98,9 +98,9 @@ namespace AIParkingApplication
|
||||
|
||||
if (loginResult.IsLoginSuccess)
|
||||
{
|
||||
Util.UpsertAppSettings("DEFAULT_USERNAME", txtUsername.Text);
|
||||
Util.UpsertAppSettings("DEFAULT_PASSWORD", txtPassword.Text);
|
||||
Util.UpsertAppSettings("DEFAULT_WEB_SERVER", txtServerAddress.Text);
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, txtUsername.Text);
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, txtPassword.Text);
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, txtServerAddress.Text);
|
||||
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show();
|
||||
Hide();
|
||||
applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}");
|
||||
@@ -116,10 +116,10 @@ namespace AIParkingApplication
|
||||
{
|
||||
try
|
||||
{
|
||||
txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
|
||||
txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
|
||||
txtServerAddress.Text = ConfigurationManager.AppSettings["DEFAULT_WEB_SERVER"];
|
||||
bool.TryParse(ConfigurationManager.AppSettings["AUTO_LOGIN"], out isAutoLogin);
|
||||
txtUsername.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_USERNAME];
|
||||
txtPassword.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_PASSWORD];
|
||||
txtServerAddress.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_WEB_SERVER];
|
||||
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.AUTO_LOGIN], out isAutoLogin);
|
||||
if (isAutoLogin)
|
||||
{
|
||||
chkAutoLogin.Checked = true;
|
||||
@@ -130,13 +130,13 @@ namespace AIParkingApplication
|
||||
{
|
||||
txtUsername.Text = string.Empty;
|
||||
txtPassword.Text = string.Empty;
|
||||
Util.UpsertAppSettings("DEFAULT_USERNAME", string.Empty);
|
||||
Util.UpsertAppSettings("DEFAULT_PASSWORD", string.Empty);
|
||||
Util.UpsertAppSettings("AUTO_LOGIN", "false");
|
||||
Util.UpsertAppSettings("DEFAULT_WEB_SERVER", "127.0.0.1:80");
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, string.Empty);
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, string.Empty);
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, "false");
|
||||
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, "127.0.0.1:80");
|
||||
chkAutoLogin.Checked = false;
|
||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||
applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD");
|
||||
applicationLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình tài khoản mặc định: {AppConstant.DEFAULT_USERNAME}, {AppConstant.DEFAULT_PASSWORD}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace AIParkingApplication
|
||||
|
||||
private void chkAutoLogin_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Util.UpsertAppSettings("AUTO_LOGIN", (sender as CheckBox).Checked.ToString().ToLower());
|
||||
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, (sender as CheckBox).Checked.ToString().ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
@@ -20,7 +21,8 @@ namespace AIParkingApplication
|
||||
this.maxSizePlate = maxSizePlate;
|
||||
this.scaleFactor = scaleFactor;
|
||||
this.minNeighbors = minNeighbors;
|
||||
plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
|
||||
string plateWeightPath = Application.StartupPath + (this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
|
||||
plateCascadeClassifier = new CascadeClassifier(plateWeightPath);
|
||||
}
|
||||
|
||||
~PlateDetector()
|
||||
@@ -87,8 +89,8 @@ namespace AIParkingApplication
|
||||
|
||||
public static class PlateDetectorConstant
|
||||
{
|
||||
public const string SQUARE_PLATE_WEIGHT_FILENAME = "plate.xml";
|
||||
public const string LONG_PLATE_WEIGHT_FILENAME = "plateLong.xml";
|
||||
public const string SQUARE_PLATE_WEIGHT_FILENAME = @".\plate.xml";
|
||||
public const string LONG_PLATE_WEIGHT_FILENAME = @".\plateLong.xml";
|
||||
|
||||
public const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03;
|
||||
public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2;
|
||||
|
||||
1
AIParkingApplication/Sidebar.Designer.cs
generated
1
AIParkingApplication/Sidebar.Designer.cs
generated
@@ -36,6 +36,7 @@
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Name = "Sidebar";
|
||||
this.Size = new System.Drawing.Size(192, 692);
|
||||
this.Load += new System.EventHandler(this.Sidebar_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,20 @@ namespace AIParkingApplication
|
||||
public partial class Sidebar : UserControl
|
||||
{
|
||||
private Statistic statistic;
|
||||
private string logoImagePath;
|
||||
private ApiController apiController;
|
||||
|
||||
public Sidebar(ApiController apiController, string logoImagePath = AppConstant.DEFAULT_LOGO_IMAGE)
|
||||
{
|
||||
InitializeComponent();
|
||||
if (File.Exists(logoImagePath))
|
||||
this.apiController = apiController;
|
||||
this.logoImagePath = logoImagePath;
|
||||
}
|
||||
|
||||
private void Sidebar_Load(object sender, EventArgs e)
|
||||
{
|
||||
string defaultLogoImagePath = Application.StartupPath + logoImagePath;
|
||||
if (File.Exists(defaultLogoImagePath))
|
||||
{
|
||||
PictureBox pictureBoxImageLogo;
|
||||
pictureBoxImageLogo = new PictureBox();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
@@ -7,6 +9,7 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
@@ -135,6 +138,46 @@ namespace AIParkingApplication
|
||||
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 static void AddApplicationToStartup()
|
||||
{
|
||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
||||
{
|
||||
key.SetValue("AIParkingApplication", "\"" + Application.ExecutablePath + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveApplicationFromStartup()
|
||||
{
|
||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
||||
{
|
||||
key.DeleteValue("AIParkingApplication", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PlateRequestEngineModel
|
||||
@@ -165,4 +208,22 @@ namespace AIParkingApplication
|
||||
public const string HTTP_POST_METHOD = "POST";
|
||||
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,5 +8,6 @@
|
||||
<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.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" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user