Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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_Numbers_Ocr_Tesseract - Fatal编程技术网

具有Python和tesseract编号的OCR不适用于特定示例图像

具有Python和tesseract编号的OCR不适用于特定示例图像,python,numbers,ocr,tesseract,Python,Numbers,Ocr,Tesseract,我试图使用tesseract在这个帧中写入数字,但我的代码不起作用 有什么帮助吗 从PIL导入图像 导入pytesseract 从wand.image导入图像作为Img 导入nltk 从nltk.tokenize导入单词\u tokenize 从nltk.tag导入pos_标记 将numpy作为np导入 导入操作系统 进口cv2 demo=Image.open(“/Users/Desktop/Image\u frames/frame37.png”) text=pytesseract.imag

我试图使用tesseract在这个帧中写入数字,但我的代码不起作用

有什么帮助吗

从PIL导入图像
导入pytesseract
从wand.image导入图像作为Img
导入nltk
从nltk.tokenize导入单词\u tokenize
从nltk.tag导入pos_标记
将numpy作为np导入
导入操作系统
进口cv2
demo=Image.open(“/Users/Desktop/Image\u frames/frame37.png”)
text=pytesseract.image\u to\u字符串(演示)

打印(文本)
在使用页面分割模式(例如PSM 11)时,我得到了不错的效果,还可以通过剪切图像来切断彩色区域

import pytesseract
import cv2

img_cv = cv2.imread("/Users/Desktop/image_frames/frame37.png")

img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
height, width = img_rgb.shape[:2]
img_cut = img_rgb[0:height, int(width/1.2):width]

text = pytesseract.image_to_string(img_cut,lang='eng', config='--psm 11 --oem 1')

print(text)
给你:

100
26
20
-30
♀

有错误吗?输出错误?请提供更多的信息,因为它不会给我文本识别。当我尝试使用普通的白色背景和黑色文本时,效果很好。您的示例图像看起来可以在特定区域搜索文本。您是否尝试将图像转换为黑白或灰度?这非常有用,有进一步学习或种族歧视的教科书或网站吗?