mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-30 11:19:57 +00:00
No empty logs and fixes some errors
This commit is contained in:
@@ -20,11 +20,15 @@ async def process_image(image: bytes) -> str:
|
||||
if r.boxes:
|
||||
for box in r.boxes:
|
||||
cls_name = r.names[int(box.cls[0])]
|
||||
if cls_name == "car":
|
||||
if cls_name in ["car", "truck"]:
|
||||
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
||||
size = (x2 - x1) ** 2 + (y2 - y1) ** 2
|
||||
cars.append((size, (x1, y1, x2, y2)))
|
||||
else:
|
||||
return ""
|
||||
|
||||
if cars == []:
|
||||
return ""
|
||||
# Get the biggest car box
|
||||
size, corners = max(cars, key=lambda x: x[0])
|
||||
|
||||
@@ -45,5 +49,7 @@ async def process_image(image: bytes) -> str:
|
||||
lp_np = np.array(object=lp_img)
|
||||
result = ocr_reader.readtext(image=lp_np)
|
||||
print(result)
|
||||
else:
|
||||
return ""
|
||||
|
||||
return str(result[0][1]) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user