小编sum*_*roy的帖子

适用于OCR的OpenCv pytesseract

如何使用opencv和pytesseract从图像中提取文本?

import cv2
Run Code Online (Sandbox Code Playgroud)

从PIL导入pytesseract导入图像从matplotlib导入numpy为np导入为plt pyplot

img = Image.open('test.jpg').convert('L')
img.show()
img.save('test','png')
img = cv2.imread('test.png',0)
edges = cv2.Canny(img,100,200)
#contour = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
#print pytesseract.image_to_string(Image.open(edges))
print pytesseract.image_to_string(edges)
Run Code Online (Sandbox Code Playgroud)

但这给了错误-

追溯(最近一次通话):文件pytesseract.image_to_string(edges)中的文件“ open.py”,第14行,文件“ /home/sroy8091/.local/lib/python2.7/site-packages/pytesseract/pytesseract”。 py“,第143行,如果len(image.split())== 4,则在image_to_string中:AttributeError:'NoneType'对象没有属性'split'

python opencv

2
推荐指数
1
解决办法
4973
查看次数

标签 统计

opencv ×1

python ×1