mirror of
https://github.com/MarcZierle/photo-log-backend.git
synced 2025-01-01 12:27:58 +00:00
16 lines
550 B
Python
Executable File
16 lines
550 B
Python
Executable File
################################################################
|
|
##### OCR
|
|
################################################################
|
|
|
|
|
|
gray = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
|
|
gray = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
|
|
gray = cv2.medianBlur(gray, 3)
|
|
|
|
cv2.imwrite("debug_out/bin.png", gray)
|
|
|
|
img = Image.fromarray(cropped_image)
|
|
|
|
tessdata_dir_config = r'--tessdata-dir "./ocr_langs"'
|
|
text = pytesseract.image_to_string(gray, lang='deu-best', config=tessdata_dir_config)
|
|
print(text) |