Moved ANPR system to image processing

This commit is contained in:
2025-06-12 11:48:20 +02:00
parent d422268a03
commit a92fbc9638
3 changed files with 48 additions and 12 deletions

View File

@@ -1,12 +1,11 @@
from ultralytics import YOLO
from ultralytics.engine.results import Boxes
from PIL import Image
import numpy as np
import easyocr
car_model = YOLO("yolov8n.pt")
plate_model = YOLO("license_plate_detector.pt")
reader = easyocr.Reader(["nl"])
ocr_reader = easyocr.Reader(["nl"])
img = Image.open("test.jpg")
@@ -42,5 +41,6 @@ for r in results:
lp_img = cropped_img.crop((x1, y1, x2, y2))
lp_img.save("license_plate.jpg")
lp_np = np.array(object=lp_img)
result = reader.readtext(image=lp_np)
result = ocr_reader.readtext(image=lp_np)
print(result)
print(result[0][1]) # type: ignore