每当我使用pytesseract.它会导致一个错误


import pytesseract
import cv2
img = cv2.imread('ocrtest.jpg')   
img = cv2.resize(img, (600,400))
print(pytesseract.image_to_string(img))
cv2.imshow('Result', img)
cv2.waitKey(0)

每当我添加第5行- print(pytesseract.image_to_string(img))行-时,就会出现这个巨大的错误,说file not found error,并在最底部说tesseract not found。我使用的是Anaconda Jupyter笔记本,pytesseract是在Anaconda文件中下载的,而不是我桌面上的Jupyter笔记本文件。这是问题所在吗?如果没有添加该行,代码将正确运行并打开映像文件。jpg格式的图片在桌面文件夹中下载。

opencv中的narray不支持pytesseract文本提取。使用枕头代替opencv-python.

import pytesseract
from PIL import Image
img = Image.open("ocrtest.jpg")
resized_img = img.resize((600,400))
print(pytesseract.image_to_string(resized_img))
img.show()

希望这对你有帮助。

相关内容

最新更新