本文介绍了Pytesser设置字符白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何为Pytesseract设置角色白名单吗?我希望它仅输出A-z和0-9.这可能吗?我有以下内容:
Does anyone know how to set the character whitelist for Pytesseract? I want it to only output A-z and 0-9. Is this possible? I have the following:
img = Image.open('test.jpg') result = pytesseract.image_to_string(img, config='-psm 6')我将其他字符(例如/)设为1,所以我想限制可能出现的字符的选项.
I'm getting other characters like / for a 1 so I would like to limit the options of possible characters.
推荐答案您可以在下面的行中完成此操作.或者,您可以为tesseract设置配置文件以执行相同的操作> tesseract正在寻找的限制字符
You can accomplish that with the below line. Or you can setup the config file for tesseract to do the same thing Limit characters tesseract is looking for
pytesseract.image_to_string(question_img, config="-c tessedit_char_whitelist=0123456789abcdefghijklmnopqrstuvwxyz -psm 6")我确信还有其他方法可以使它起作用,但这对我来说是有效的.
I am sure there are other ways to get it work, but this is what worked for me.
更多推荐
Pytesser设置字符白名单
发布评论