From f9fcca290257b83d7d0cc5ecbcc8bedcb48d9514 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Fri, 19 Jun 2020 14:46:15 +0700 Subject: [PATCH] PlateProcessor - ProcessPlate: Catch Exception Return Result with frame, Remove Cv2.Resize Frame. --- AIParkingApplication/LaneIn.cs | 2 ++ AIParkingApplication/PlateProcessor.cs | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 72825b6..8f3e3c8 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -61,6 +61,8 @@ namespace AIParkingApplication { try { + //TODO: check size before resizing + Cv2.Resize(videoFrame, videoFrame, new Size(1280, 720)); FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(videoFrame); if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString)) diff --git a/AIParkingApplication/PlateProcessor.cs b/AIParkingApplication/PlateProcessor.cs index 9279a9c..74157ac 100644 --- a/AIParkingApplication/PlateProcessor.cs +++ b/AIParkingApplication/PlateProcessor.cs @@ -64,10 +64,7 @@ namespace AIParkingApplication { try { - //TODO: check size before resizing - Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720)); FinalPlateResult plateResult; - if (isSupportLongPlate) { plateResult = await DetectPlateAndDoOcrEngineAsync(PlateType.Long, frame); @@ -87,7 +84,11 @@ namespace AIParkingApplication catch (Exception ex) { Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}"); - return new FinalPlateResult(); + return new FinalPlateResult + { + PlateString = string.Empty, + PlateImage = frame.ToBitmap() + }; } }