Pytesser设置字符白名单

编程入门 行业动态 更新时间:2024-10-26 20:28:28
本文介绍了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设置字符白名单

本文发布于:2023-11-27 06:48:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637024.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   名单   Pytesser

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!