PlateProcessor - Add Try Catch In Method DetectPlateAndDoOcrEngineAsync
This commit is contained in:
@@ -32,7 +32,6 @@ namespace AIParkingApplication
|
||||
|
||||
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);
|
||||
|
||||
//TODO: check size before resizing
|
||||
@@ -63,25 +62,33 @@ namespace AIParkingApplication
|
||||
|
||||
public async Task<FinalPlateResult> ProcessPlate(Mat frame)
|
||||
{
|
||||
//TODO: check size before resizing
|
||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||
FinalPlateResult plateResult;
|
||||
|
||||
if (isSupportLongPlate)
|
||||
try
|
||||
{
|
||||
plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame);
|
||||
if (string.IsNullOrEmpty(plateResult.PlateString))
|
||||
//TODO: check size before resizing
|
||||
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);
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user