TypeError: Ожидается cv :: UMat для аргумента 'src' - PullRequest
0 голосов
/ 06 июня 2019

Строка "pytesseract.image_to_string" работает нормально, но как только я добавляю код "cv2.INTER_CUBIC" (для улучшения изображения и обработки) и запускаю программу, я получаю сообщение об ошибке - Ожидается cv :: UMat для аргумента'src'

Я пытался установить numpy и удалить / переустановить OpenCV

try:
из PIL import Image, кроме ImportError:
import Image import pytesseract import cv2

def ocr_core (img):

img = cv2.resize(img, None, fx=1.5, fy=1.5, interpolation=cv2.INTER_CUBIC)
# 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)
# Apply threshold to get image with only black and white
img = apply_threshold(img, method)

"""
This function will handle the core OCR processing of images.
"""
text = pytesseract.image_to_string(Image.open(img)) 
return text

print (ocr_core ('sample_img_1.png'))

Ожидаемым результатом должен быть весь текстовый вывод (извлеченный текст из изображения)

...