Update app.py
Browse files
app.py
CHANGED
|
@@ -67,16 +67,23 @@ def classify_plate_color(plate_img):
|
|
| 67 |
img = np.array(plate_img)
|
| 68 |
hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
return "EV"
|
| 75 |
-
elif yellow > green:
|
| 76 |
return "Commercial"
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
|
| 81 |
def read_plate(plate_img):
|
| 82 |
try:
|
|
|
|
| 67 |
img = np.array(plate_img)
|
| 68 |
hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
|
| 69 |
|
| 70 |
+
# Color masks
|
| 71 |
+
green_mask = cv2.inRange(hsv, (35, 40, 40), (85, 255, 255))
|
| 72 |
+
yellow_mask = cv2.inRange(hsv, (15, 50, 50), (35, 255, 255))
|
| 73 |
+
white_mask = cv2.inRange(hsv, (0, 0, 200), (180, 40, 255))
|
| 74 |
|
| 75 |
+
green = np.sum(green_mask)
|
| 76 |
+
yellow = np.sum(yellow_mask)
|
| 77 |
+
white = np.sum(white_mask)
|
| 78 |
+
|
| 79 |
+
if green > yellow and green > white:
|
| 80 |
return "EV"
|
| 81 |
+
elif yellow > green and yellow > white:
|
| 82 |
return "Commercial"
|
| 83 |
+
elif white > green and white > yellow:
|
| 84 |
+
return "Personal"
|
| 85 |
+
else:
|
| 86 |
+
return "Unknown"
|
| 87 |
|
| 88 |
def read_plate(plate_img):
|
| 89 |
try:
|