Я пытаюсь извлечь текст из изображения, используя OpenCV через python, но получаю неверный результат и, в основном, получаю специальные символы, пожалуйста, исправьте, что здесь не так
import cv2
import numpy as np
import pytesseract
from PIL import Image
import os
def get_string(img_path):
# Read image with opencv
img = cv2.imread(img_path)
# Convert to gray
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Apply dilation and erosion to remove some noise
kernel = np.ones((1, 1), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
# Write image after removed noise
cv2.imwrite(src_path + "removed_noise.png", img)
# Write the image after apply opencv to do some ...
cv2.imwrite(src_path + "thres.png", img)
# Recognize text with tesseract for python
result = pytesseract.image_to_string(Image.open(src_path + "thres.png"))
return result
print('--- Start recognize text from image ---')
print(get_string("image_full_path.png"))
Пробовал Googling, но ничего не помогло.Может ли какой-то один указывать на правильный вывод кода:
i } i er Oe a Pee pe be a
i j rye Se) PEE eet et ae ec?
j } a « o cy ” a @
: i : } Cand RET RE Petr eet PI ret
nif wad
fs | : : } wert
| ; a] |
wee | a
— th | cE i
ae | i
“ oe i j EYE }
en ct
. a f ae " i
- — ; - i! }