Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 基于二值图像的Tesseract OCR_Python_Opencv_Ocr_Tesseract_Python Tesseract - Fatal编程技术网

Python 基于二值图像的Tesseract OCR

Python 基于二值图像的Tesseract OCR,python,opencv,ocr,tesseract,python-tesseract,Python,Opencv,Ocr,Tesseract,Python Tesseract,我有一个像这样的二值图像 我想在Python中使用tesseract ocr提取图像中的数字。我在图像上使用了像这样的pytesseract txt = pytesseract.image_to_string(img) 但是我没有得到任何好的结果 我可以在预处理或增强方面做些什么来帮助tesseract做得更好 我尝试使用East text Detector定位图像中的文本,但它无法识别文本 如何在python中执行此操作?我认为页面分割模式是一个重要因素 因为我们试图读取列值,所以可以使用

我有一个像这样的二值图像

我想在Python中使用tesseract ocr提取图像中的数字。我在图像上使用了像这样的
pytesseract

txt = pytesseract.image_to_string(img)
但是我没有得到任何好的结果

我可以在预处理或增强方面做些什么来帮助tesseract做得更好

我尝试使用
East text Detector
定位图像中的文本,但它无法识别文本


如何在python中执行此操作?

我认为页面分割模式是一个重要因素

因为我们试图读取列值,所以可以使用
--psm 4
()

导入cv2
导入pytesseract
img=cv2.imread(“k7bqx.jpg”)
gry=cv2.CVT颜色(img,cv2.COLOR\u BGR2GRAY)
txt=pytesseract.image_to_字符串(gry,config=“--psm 4”)
我们希望文本以
#

txt=sorted([t[:2]表示t在txt中,如果t中为“#”)
结果:

['3'、'7'、'9'、'
但是我们错过了4,5,我们可以应用
自适应阈值

结果:

['3'、'4'、'5'、'7'、'9'、'
不幸的是,
#2
#6
无法识别

代码:


导入cv2
导入pytesseract
img=cv2.imread(“k7bqx.jpg”)
gry=cv2.CVT颜色(img,cv2.COLOR\u BGR2GRAY)
thr=cv2.自适应阈值(gry,252,cv2.自适应阈值平均值,
cv2.THRESH_BINARY_INV,blockSize=131,C=100)
bnt=cv2。按位_非(thr)
txt=pytesseract.image_to_字符串(bnt,config=“--psm 4”)
txt=txt.strip().split(“\n”)
txt=已排序([t[:2]表示txt中的t,如果在t中为“#”)
打印(txt)