18 lines
565 B
Python
18 lines
565 B
Python
import easyocr
|
|
import logging
|
|
|
|
logger = logging.getLogger(" ocr ")
|
|
|
|
# Initialize the EasyOCR reader
|
|
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
|
|
|
def ocr_recognize(file_path):
|
|
# Use EasyOCR to detect text in the photo
|
|
result = reader.readtext(file_path)
|
|
logger.debug("OCR Result: %s", result)
|
|
|
|
# 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 |