Added reporting for a failed OCR match

This commit is contained in:
Riley Housden 2022-08-22 14:35:13 -04:00
parent cf73726614
commit b16ff88a79
2 changed files with 13 additions and 3 deletions

View file

@ -67,7 +67,7 @@ def get_room_data(img: bytes) -> list[Room]:
rooms: list[Room] = []
start_time: datetime | None = None
end_time: datetime | None = None
img_string = image_to_string(Image.open(BytesIO(img)))
img_string = get_image_string(img)
img_string = correct_newlines(img_string)
img_string = correct_commas(img_string)
matches = re.finditer(RE_STRING, img_string)
@ -85,3 +85,6 @@ def get_room_data(img: bytes) -> list[Room]:
if len(rooms) == 0:
raise NoMatchException
return rooms
def get_image_string(img: bytes) -> str:
return image_to_string(Image.open(BytesIO(img)))