PlateDetector - Move weight file name to constant

This commit is contained in:
DucDangAnh 2020-06-18 17:36:10 +07:00
parent 267e6cfaa3
commit d1d1640a31

View File

@ -20,7 +20,7 @@ namespace AIParkingApplication
this.maxSizePlate = maxSizePlate; this.maxSizePlate = maxSizePlate;
this.scaleFactor = scaleFactor; this.scaleFactor = scaleFactor;
this.minNeighbors = minNeighbors; 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) public Mat DetectPlate(Mat frame)
@ -56,7 +56,6 @@ namespace AIParkingApplication
Console.WriteLine($"{i}\t{plateRects[i].Width}\t{plateRects[i].Height}"); Console.WriteLine($"{i}\t{plateRects[i].Width}\t{plateRects[i].Height}");
} }
Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}"); Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}");
Rect extendedRect = ExtendPlateRect(biggestPlateRect); Rect extendedRect = ExtendPlateRect(biggestPlateRect);
//TODO: check oversize frame //TODO: check oversize frame
Mat plateImage; Mat plateImage;
@ -66,9 +65,8 @@ namespace AIParkingApplication
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Error While Extending Plate Rect");
plateImage = frame[biggestPlateRect]; plateImage = frame[biggestPlateRect];
throw; Console.WriteLine($"Error While Extending Plate Rect: {ex.Message}");
} }
return plateImage; return plateImage;
} }
@ -82,6 +80,9 @@ namespace AIParkingApplication
public static class PlateDetectorConstant 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 const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03;
public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2; public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2;
public static Size MIN_SIZE_DEFAULT_SQUARE_PLATE = new Size(105, 100); public static Size MIN_SIZE_DEFAULT_SQUARE_PLATE = new Size(105, 100);