pytesseract 仅使用 tesseract 4.0 数字不起作用 [英] pytesseract using tesseract 4.0 numbers only not working

查看:21
本文介绍了pytesseract 仅使用 tesseract 4.0 数字不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人试图在 python 中调用最新版本的 tesseract 4.0 来获取数字吗?

Any one tried to get numbers only calling the latest version of tesseract 4.0 in python?

以下在 3.05 中工作,但在 4.0 中仍然返回字符,我尝试删除所有配置文件但数字文件,但仍然无法正常工作;任何帮助都会很棒:

The below worked in 3.05 but still returns characters in 4.0, I tried removing all config files but the digits file and still didn't work; any help would be great:

im 是日期的图像,黑色文本白色背景:

im is an image of a date, black text white background:

import pytesseract
im =  imageOfDate
im = pytesseract.image_to_string(im, config='outputbase digits')
print(im)

推荐答案

您可以将 tessedit_char_whitelist 中的数字指定为 config option.

You can specify the numbers in the tessedit_char_whitelist as below as a config option.

ocr_result = pytesseract.image_to_string(image, lang='eng', boxes=False, \
           config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')

希望对您有所帮助.

这篇关于pytesseract 仅使用 tesseract 4.0 数字不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆