normalized-log-fix10

This commit is contained in:
Untone 2024-09-28 11:33:55 +03:00
parent 494cc5766f
commit d9e9c547ef

View File

@ -7,12 +7,15 @@ logger = logging.getLogger(" ocr ")
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
def ocr_recognize(file_path):
sum_text = ""
# Use EasyOCR to detect text in the photo
result = reader.readtext(file_path)
logger.debug("OCR Result: %s", result)
results = reader.readtext(file_path)
for result in results:
[_coords, ocr_text, ocr_accuracy] = result
logger.debug("OCR Result: %s", ocr_text)
if ocr_accuracy.item() > 0.5:
sum_text += ocr_text
# Extract recognized text
recognized_text = ' '.join([text[1] for text in result if isinstance(text, tuple) and len(text) > 1])
logger.debug(f'Recognized Text: {recognized_text}')
return recognized_text
logger.debug(f'Recognized Text: {sum_text}')
return sum_text