Util - Add Extensition Methods: UpdateImage, UpdateLabel
This commit is contained in:
parent
d756d36082
commit
9668f8f3ac
|
@ -67,18 +67,10 @@ namespace AIParkingApplication
|
|||
|
||||
var plateVideoFrame = plateCamera.CurrentFrame;
|
||||
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
||||
pictureBoxPlateImage.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateImage.Image?.Dispose();
|
||||
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
|
||||
}));
|
||||
pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap());
|
||||
|
||||
var overviewVideoFrame = overviewCamera.CurrentFrame;
|
||||
pictureBoxOverviewImage.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxOverviewImage.Image?.Dispose();
|
||||
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
|
||||
}));
|
||||
pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.ToBitmap());
|
||||
|
||||
var cardInformation = await apiController.GetCardInformation(cardNumber);
|
||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
||||
|
@ -121,35 +113,18 @@ namespace AIParkingApplication
|
|||
|
||||
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
|
||||
{
|
||||
pictureBoxPlateVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateVideo.Image?.Dispose();
|
||||
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
|
||||
private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame)
|
||||
{
|
||||
pictureBoxOverviewVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxOverviewImage.Image?.Dispose();
|
||||
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
|
||||
private void ClearPlateAndOverviewImage()
|
||||
{
|
||||
pictureBoxPlateImage.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateImage.Image?.Dispose();
|
||||
pictureBoxPlateImage.Image = null;
|
||||
}));
|
||||
|
||||
pictureBoxOverviewImage.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxOverviewImage.Image?.Dispose();
|
||||
pictureBoxOverviewImage.Image = null;
|
||||
}));
|
||||
pictureBoxPlateImage.UpdateImage(null);
|
||||
pictureBoxOverviewImage.UpdateImage(null);
|
||||
}
|
||||
|
||||
private void OpenDoor(int doorId)
|
||||
|
@ -237,11 +212,7 @@ namespace AIParkingApplication
|
|||
{
|
||||
try
|
||||
{
|
||||
pictureBoxOverviewVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxOverviewVideo.Image?.Dispose();
|
||||
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -253,11 +224,7 @@ namespace AIParkingApplication
|
|||
{
|
||||
try
|
||||
{
|
||||
pictureBoxPlateVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateVideo.Image?.Dispose();
|
||||
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -117,4 +117,46 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="pictureBoxPlateImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="pictureBoxPlateVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="grbPlateCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="pictureBoxOverviewImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="pictureBoxOverviewVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="grbOverviewCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblLaneLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblCardType.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lblStatusInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -1,12 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Windows.Forms;
|
|||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Net.Http;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
|
@ -74,6 +76,24 @@ namespace AIParkingApplication
|
|||
return new OcrResult();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateImage(this PictureBox pictureBox, Bitmap image)
|
||||
{
|
||||
pictureBox.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBox.Image?.Dispose();
|
||||
pictureBox.Image = image;
|
||||
}));
|
||||
}
|
||||
|
||||
public static void UpdateLabel(this Label label, string text, Color color)
|
||||
{
|
||||
label.Invoke(new Action(() =>
|
||||
{
|
||||
label.BackColor = color;
|
||||
label.Text = text;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public class PlateRequestEngineModel
|
||||
|
|
Loading…
Reference in New Issue
Block a user