TypeError:参数'src'的预期cv :: UMat

时间:2019-06-06 09:33:27

标签: python-3.x jupyter-notebook python-tesseract

“ pytesseract.image_to_string”行工作正常,但是一旦我添加“ cv2.INTER_CUBIC”代码(以增强图像和处理能力)并运行程序,我就会报错-预期的cv :: UMat参数'src'

我尝试安装numpy并卸载/重新安装OpenCV

尝试:
    从PIL导入图片 除了ImportError:
    导入图片 导入pytesseract 导入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'))

预期结果应为所有文本输出(从图像中提取文本)

0 个答案:

没有答案