PlateProcessor - Update IsPlateStringValid to check valid plate string. LaneIn - Add option Retry Mode.
This commit is contained in:
parent
88b2e3524e
commit
13d591ada3
|
@ -7,7 +7,7 @@ namespace AIParkingApplication
|
||||||
public AIParkingApplicationForm()
|
public AIParkingApplicationForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
LaneIn laneIn = new LaneIn();
|
LaneIn laneIn = new LaneIn(@"C:\HS_test.mp4", @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", true, true); //@"C:\CongRa_1.mp4";
|
||||||
//LaneIn laneOut = new LaneIn();
|
//LaneIn laneOut = new LaneIn();
|
||||||
Controls.Add(laneIn);
|
Controls.Add(laneIn);
|
||||||
//laneOut.Location = new System.Drawing.Point(550, 0);
|
//laneOut.Location = new System.Drawing.Point(550, 0);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using OpenCvSharp.Extensions;
|
using OpenCvSharp.Extensions;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
@ -11,17 +12,16 @@ namespace AIParkingApplication
|
||||||
private Camera overviewCamera;
|
private Camera overviewCamera;
|
||||||
private Camera plateCamera;
|
private Camera plateCamera;
|
||||||
private PlateProcessor plateProcessor;
|
private PlateProcessor plateProcessor;
|
||||||
|
private bool isRetryMode;
|
||||||
|
private bool isRetryModeUntilOk;
|
||||||
|
|
||||||
public LaneIn()
|
public LaneIn(string plateStream, string overviewStream, bool isRetryMode = false, bool isRetryModeUntilOk = false)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
string overviewCameraVideo = @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
|
this.isRetryMode = isRetryMode;
|
||||||
//string overviewCameraVideo = @"C:\HS_test.mp4";
|
this.isRetryModeUntilOk = isRetryModeUntilOk;
|
||||||
string plateCameraVideo = @"C:\HS_test.mp4";
|
overviewCamera = new Camera(overviewStream);
|
||||||
//string plateCameraVideo = @"C:\CongRa_1.mp4";
|
plateCamera = new Camera(plateStream);
|
||||||
|
|
||||||
overviewCamera = new Camera(overviewCameraVideo);
|
|
||||||
plateCamera = new Camera(plateCameraVideo);
|
|
||||||
|
|
||||||
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
|
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
|
||||||
plateCamera.OnOneVideoFrameRequested += PlateCamera_OnOneVideoFrameRequested;
|
plateCamera.OnOneVideoFrameRequested += PlateCamera_OnOneVideoFrameRequested;
|
||||||
|
@ -57,7 +57,21 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
|
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
|
||||||
|
|
||||||
|
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||||
|
{
|
||||||
|
if (isRetryModeUntilOk)
|
||||||
|
{
|
||||||
|
CaptureAllCamera();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("PlateCamera_OnOneVideoFrameRequested Retry Mode");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lblPlateString.Invoke(new Action(() =>
|
lblPlateString.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace AIParkingApplication
|
||||||
if (isSupportLongPlate)
|
if (isSupportLongPlate)
|
||||||
{
|
{
|
||||||
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame);
|
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame);
|
||||||
if (string.IsNullOrEmpty(plateResult.PlateString))
|
if (!IsPlateStringValid(plateResult.PlateString))
|
||||||
{
|
{
|
||||||
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
|
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
|
||||||
}
|
}
|
||||||
|
@ -97,17 +97,16 @@ namespace AIParkingApplication
|
||||||
return plateString;
|
return plateString;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Complete this
|
public bool IsPlateStringValid(string plateString, int minPlateStringLength = 4)
|
||||||
private bool IsPlateStringValid(string plateString)
|
|
||||||
{
|
{
|
||||||
bool isValid = true;
|
bool isValid = !string.IsNullOrEmpty(plateString) && plateString.Length > minPlateStringLength;
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class FinalPlateResult
|
public class FinalPlateResult
|
||||||
{
|
{
|
||||||
public string PlateString { get; set; }
|
public string PlateString { get; set; }
|
||||||
public Bitmap PlateImage { get; set; }
|
public Bitmap PlateImage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user