tesseract无法识别一个数字图像

时间:2018-03-26 20:20:11

标签: tesseract

我正在使用pyse的tesseract。它可识别几乎所有带有2个或更多数字或字符的图像。 但是tesseract只能用一个数字来识别图像。 我尝试使用命令行,它给了我"空页"作为回应。

我不想用"只有数字"来训练tesseract。因为我也认识到了人物。

有什么问题?

在图像下方,未被tesseract识别。

enter image description here

代码:

 #getPng(pathImg, '3') -> creates the path to the figure.
 pytesseract.image_to_string( Image.open(getPng(pathImg, '3')) 

4 个答案:

答案 0 :(得分:2)

如果添加参数--psm 13,它应该有效,因为它会将其视为原始文本行,而不会搜索页面和段落。

所以试试:

pytesseract.image_to_string(PATH, config="--psm 13") 

答案 1 :(得分:0)

尝试将图像转换为灰度图像,然后转换为二进制图像,然后很可能会读取。 如果图像不重复,则您需要阅读2个字母。因此,您只需提取单个字母

答案 2 :(得分:0)

基于ceccoemi answer,您可以尝试其他页面细分模式--psm标志)。

对于这种特殊情况,我建议使用--psm 7(单行文本)或--psm 10(单字符):

psm7 = pytesseract.image_to_string(Image.open(getPng(pathImg, '3'), config='--psm 7')
psm10 = pytesseract.image_to_string(Image.open(getPng(pathImg, '3'), config='--psm 10')

有关这些模式的更多信息,请参见tesseract wiki

答案 3 :(得分:0)

您可以将-l osd用于这样的一位数字。

tesseract VYO0C.png stdout -l osd --oem 3 --psm 6
2
相关问题