ocr
This commit is contained in:
16
nlp/ocr.py
Normal file
16
nlp/ocr.py
Normal file
@@ -0,0 +1,16 @@
|
||||
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)
|
||||
|
||||
# Extract the recognized text from the result
|
||||
recognized_text = ' '.join([text for text, _, _ in result])
|
||||
logger.debug(f'recognized_text: {recognized_text}')
|
||||
return recognized_text
|
Reference in New Issue
Block a user