Thêm tính năng vẽ ROI vào khung cam bắt biển

This commit is contained in:
Le Chau 2020-07-17 13:59:09 +07:00
parent 2c6e326008
commit c0c8b325d0
6 changed files with 124 additions and 0 deletions

View File

@ -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
//

View File

@ -25,6 +25,11 @@ namespace AIParkingApplication
private ApiController apiController;
private Logger appLogger;
private System.Drawing.Point StartPoint { get; set; }
private System.Drawing.Point CurrentCursorPosition { get; set; }
private Rectangle roiBox;
private bool IsDrawBox { get; set; }
public LaneIn(int doorId,
string cameraId,
string plateStream,
@ -235,5 +240,43 @@ namespace AIParkingApplication
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
ConnectToDoorAccessControl();
}
private void pictureBoxPlateVideo_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
StartPoint = e.Location;
roiBox = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
IsDrawBox = true;
}
}
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
{
if (IsDrawBox)
{
CurrentCursorPosition = e.Location;
roiBox.Width = CurrentCursorPosition.X - StartPoint.X;
roiBox.Height = CurrentCursorPosition.Y - StartPoint.Y;
}
Refresh();
}
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
{
if (StartPoint.X + roiBox.Width > pictureBoxPlateVideo.Width || StartPoint.Y + roiBox.Height > pictureBoxPlateVideo.Height)
{
roiBox.X = roiBox.Y = 0;
roiBox.Width = pictureBoxPlateVideo.Width;
roiBox.Height = pictureBoxPlateVideo.Height;
}
IsDrawBox = false;
}
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 4);
e.Graphics.DrawRectangle(redPen, roiBox);
}
}
}

View File

@ -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>

View File

@ -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
//

View File

@ -27,6 +27,11 @@ namespace AIParkingApplication
private Logger appLogger;
private bool isUsePrinter;
private System.Drawing.Point StartPoint { get; set; }
private System.Drawing.Point CurrentCursorPosition { get; set; }
private Rectangle roiBox;
private bool IsDrawBox { get; set; }
public LaneOut(int doorId,
string cameraId,
string plateStream,
@ -315,5 +320,43 @@ 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;
roiBox = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
IsDrawBox = true;
}
}
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
{
if (IsDrawBox)
{
CurrentCursorPosition = e.Location;
roiBox.Width = CurrentCursorPosition.X - StartPoint.X;
roiBox.Height = CurrentCursorPosition.Y - StartPoint.Y;
}
Refresh();
}
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
{
if (StartPoint.X + roiBox.Width > pictureBoxPlateVideo.Width || StartPoint.Y + roiBox.Height > pictureBoxPlateVideo.Height)
{
roiBox.X = roiBox.Y = 0;
roiBox.Width = pictureBoxPlateVideo.Width;
roiBox.Height = pictureBoxPlateVideo.Height;
}
IsDrawBox = false;
}
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 4);
e.Graphics.DrawRectangle(redPen, roiBox);
}
}
}

View File

@ -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>