mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-30 03:09:58 +00:00
Moved ANPR system to image processing
This commit is contained in:
6
ANPR.py
6
ANPR.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user