No empty logs and fixes some errors

This commit is contained in:
2025-06-18 15:05:47 +02:00
parent fbdfe86eee
commit d074c9bf27
7 changed files with 35 additions and 21 deletions

View File

@@ -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