Spaces:
Running
Running
TheKnight115
commited on
Update processor.py
Browse files- processor.py +6 -3
processor.py
CHANGED
@@ -56,6 +56,9 @@ model = YOLO('yolov8_Medium.pt') # Update the path as needed
|
|
56 |
# Define lane area coordinates (example coordinates)
|
57 |
red_lane = np.array([[2,1583],[1,1131],[1828,1141],[1912,1580]], np.int32)
|
58 |
|
|
|
|
|
|
|
59 |
# Dictionary to track violations per license plate
|
60 |
violations_dict = {}
|
61 |
|
@@ -198,7 +201,7 @@ def process_image(image_path, font_path, violation_image_path='violation.jpg'):
|
|
198 |
|
199 |
def process_video(video_path):
|
200 |
# Paths for saving violation images
|
201 |
-
violation_image_path = '
|
202 |
|
203 |
# Track emails already sent to avoid duplicate emails
|
204 |
sent_emails = {}
|
@@ -216,7 +219,7 @@ def process_video(video_path):
|
|
216 |
|
217 |
# Define codec and output video settings
|
218 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
219 |
-
output_video_path = '
|
220 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
221 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) # Frame width
|
222 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) # Frame height
|
@@ -287,7 +290,7 @@ def process_video(video_path):
|
|
287 |
# Perform OCR on the license plate
|
288 |
cv2.imwrite(violation_image_path, frame)
|
289 |
license_plate_pil = Image.fromarray(cv2.cvtColor(license_crop, cv2.COLOR_BGR2RGB))
|
290 |
-
temp_image_path = '
|
291 |
license_plate_pil.save(temp_image_path)
|
292 |
license_plate_text = model_ocr.chat(processor, temp_image_path, ocr_type='ocr')
|
293 |
filtered_text = filter_license_plate_text(license_plate_text)
|
|
|
56 |
# Define lane area coordinates (example coordinates)
|
57 |
red_lane = np.array([[2,1583],[1,1131],[1828,1141],[1912,1580]], np.int32)
|
58 |
|
59 |
+
# Path for Arabic font
|
60 |
+
font_path = "alfont_com_arial-1.ttf"
|
61 |
+
|
62 |
# Dictionary to track violations per license plate
|
63 |
violations_dict = {}
|
64 |
|
|
|
201 |
|
202 |
def process_video(video_path):
|
203 |
# Paths for saving violation images
|
204 |
+
violation_image_path = 'violation.jpg'
|
205 |
|
206 |
# Track emails already sent to avoid duplicate emails
|
207 |
sent_emails = {}
|
|
|
219 |
|
220 |
# Define codec and output video settings
|
221 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
222 |
+
output_video_path = 'output_violation.mp4'
|
223 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
224 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) # Frame width
|
225 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) # Frame height
|
|
|
290 |
# Perform OCR on the license plate
|
291 |
cv2.imwrite(violation_image_path, frame)
|
292 |
license_plate_pil = Image.fromarray(cv2.cvtColor(license_crop, cv2.COLOR_BGR2RGB))
|
293 |
+
temp_image_path = 'license_plate.png'
|
294 |
license_plate_pil.save(temp_image_path)
|
295 |
license_plate_text = model_ocr.chat(processor, temp_image_path, ocr_type='ocr')
|
296 |
filtered_text = filter_license_plate_text(license_plate_text)
|