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()
|
||||
{
|
||||
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();
|
||||
Controls.Add(laneIn);
|
||||
//laneOut.Location = new System.Drawing.Point(550, 0);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -11,17 +12,16 @@ namespace AIParkingApplication
|
|||
private Camera overviewCamera;
|
||||
private Camera plateCamera;
|
||||
private PlateProcessor plateProcessor;
|
||||
private bool isRetryMode;
|
||||
private bool isRetryModeUntilOk;
|
||||
|
||||
public LaneIn()
|
||||
public LaneIn(string plateStream, string overviewStream, bool isRetryMode = false, bool isRetryModeUntilOk = false)
|
||||
{
|
||||
InitializeComponent();
|
||||
string overviewCameraVideo = @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
|
||||
//string overviewCameraVideo = @"C:\HS_test.mp4";
|
||||
string plateCameraVideo = @"C:\HS_test.mp4";
|
||||
//string plateCameraVideo = @"C:\CongRa_1.mp4";
|
||||
|
||||
overviewCamera = new Camera(overviewCameraVideo);
|
||||
plateCamera = new Camera(plateCameraVideo);
|
||||
this.isRetryMode = isRetryMode;
|
||||
this.isRetryModeUntilOk = isRetryModeUntilOk;
|
||||
overviewCamera = new Camera(overviewStream);
|
||||
plateCamera = new Camera(plateStream);
|
||||
|
||||
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
|
||||
plateCamera.OnOneVideoFrameRequested += PlateCamera_OnOneVideoFrameRequested;
|
||||
|
@ -57,7 +57,21 @@ namespace AIParkingApplication
|
|||
{
|
||||
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(() =>
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace AIParkingApplication
|
|||
if (isSupportLongPlate)
|
||||
{
|
||||
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame);
|
||||
if (string.IsNullOrEmpty(plateResult.PlateString))
|
||||
if (!IsPlateStringValid(plateResult.PlateString))
|
||||
{
|
||||
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
|
||||
}
|
||||
|
@ -97,17 +97,16 @@ namespace AIParkingApplication
|
|||
return plateString;
|
||||
}
|
||||
|
||||
//TODO: Complete this
|
||||
private bool IsPlateStringValid(string plateString)
|
||||
public bool IsPlateStringValid(string plateString, int minPlateStringLength = 4)
|
||||
{
|
||||
bool isValid = true;
|
||||
bool isValid = !string.IsNullOrEmpty(plateString) && plateString.Length > minPlateStringLength;
|
||||
return isValid;
|
||||
}
|
||||
}
|
||||
|
||||
public class FinalPlateResult
|
||||
{
|
||||
public string PlateString { get; set; }
|
||||
public Bitmap PlateImage { get; set; }
|
||||
}
|
||||
public class FinalPlateResult
|
||||
{
|
||||
public string PlateString { get; set; }
|
||||
public Bitmap PlateImage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user