PlateProcessor - Add Try Catch In Method DetectPlateAndDoOcrEngineAsync

This commit is contained in:
DucDangAnh 2020-06-19 10:30:32 +07:00
parent e3ebc951fb
commit 88b2e3524e

View File

@ -32,7 +32,6 @@ namespace AIParkingApplication
private async Task<FinalPlateResult> DetectPlateAndDoOcrEngineAsync(PlateType plateType, Mat frame) private async Task<FinalPlateResult> DetectPlateAndDoOcrEngineAsync(PlateType plateType, Mat frame)
{ {
//TODO: check size before resizing
Mat plateDetected = plateType == PlateType.Square ? squarePlateDetector.DetectPlate(frame) : longPlateDetector.DetectPlate(frame); Mat plateDetected = plateType == PlateType.Square ? squarePlateDetector.DetectPlate(frame) : longPlateDetector.DetectPlate(frame);
//TODO: check size before resizing //TODO: check size before resizing
@ -63,25 +62,33 @@ namespace AIParkingApplication
public async Task<FinalPlateResult> ProcessPlate(Mat frame) public async Task<FinalPlateResult> ProcessPlate(Mat frame)
{ {
//TODO: check size before resizing try
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
FinalPlateResult plateResult;
if (isSupportLongPlate)
{ {
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame); //TODO: check size before resizing
if (string.IsNullOrEmpty(plateResult.PlateString)) Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
FinalPlateResult plateResult;
if (isSupportLongPlate)
{ {
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame);
if (string.IsNullOrEmpty(plateResult.PlateString))
{
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
}
}
else
{
Console.WriteLine("Recall Square Plates");
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame); plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
} }
}
else
{
Console.WriteLine("Recall Square Plates");
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Square, frame);
}
return plateResult; return plateResult;
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
return new FinalPlateResult();
}
} }
//TODO: Complete this //TODO: Complete this