From d1d1640a31b725bab3c42dfb1ff12345bb4e5c43 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Thu, 18 Jun 2020 17:36:10 +0700 Subject: [PATCH] PlateDetector - Move weight file name to constant --- AIParkingApplication/PlateDetector.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/AIParkingApplication/PlateDetector.cs b/AIParkingApplication/PlateDetector.cs index ade8e29..b6ff168 100644 --- a/AIParkingApplication/PlateDetector.cs +++ b/AIParkingApplication/PlateDetector.cs @@ -20,7 +20,7 @@ namespace AIParkingApplication this.maxSizePlate = maxSizePlate; this.scaleFactor = scaleFactor; this.minNeighbors = minNeighbors; - plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? "plate.xml" : "plateLong.xml"); + plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME); } public Mat DetectPlate(Mat frame) @@ -56,7 +56,6 @@ namespace AIParkingApplication Console.WriteLine($"{i}\t{plateRects[i].Width}\t{plateRects[i].Height}"); } Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}"); - Rect extendedRect = ExtendPlateRect(biggestPlateRect); //TODO: check oversize frame Mat plateImage; @@ -66,9 +65,8 @@ namespace AIParkingApplication } catch (Exception ex) { - Console.WriteLine("Error While Extending Plate Rect"); plateImage = frame[biggestPlateRect]; - throw; + Console.WriteLine($"Error While Extending Plate Rect: {ex.Message}"); } return plateImage; } @@ -82,6 +80,9 @@ namespace AIParkingApplication public static class PlateDetectorConstant { + public const string SQUARE_PLATE_WEIGHT_FILENAME = "plate.xml"; + public const string LONG_PLATE_WEIGHT_FILENAME = "plateLong.xml"; + public const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03; public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2; public static Size MIN_SIZE_DEFAULT_SQUARE_PLATE = new Size(105, 100);