当前位置: 首页 > 面试题库 >

Pytesseract OCR多个配置选项

楚望
2023-03-14
问题内容

我在pytesseract遇到问题。我需要将Tesseract配置为可以接受单个数字,同时也只能接受数字,因为数字0经常与’O’混淆。

像这样:

target = pytesseract.image_to_string(im,config='-psm 7',config='outputbase digits')

问题答案:

tesseract-4.0.0a支持下面psm。如果要具有单个字符识别,请设置psm = 10。并且如果您的文本仅包含数字,则可以设置tessedit_char_whitelist=0123456789

Page segmentation modes:
  0    Orientation and script detection (OSD) only.
  1    Automatic page segmentation with OSD.
  2    Automatic page segmentation, but no OSD, or OCR.
  3    Fully automatic page segmentation, but no OSD. (Default)
  4    Assume a single column of text of variable sizes.
  5    Assume a single uniform block of vertically aligned text.
  6    Assume a single uniform block of text.
  7    Treat the image as a single text line.
  8    Treat the image as a single word.
  9    Treat the image as a single word in a circle.
 10    Treat the image as a single character.
 11    Sparse text. Find as much text as possible in no particular order.
 12    Sparse text with OSD.
 13    Raw line. Treat the image as a single text line,
                        bypassing hacks that are Tesseract-specific.

这是image_to_string带有多个参数的示例用法。

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

希望这可以帮助。



 类似资料:
  • 问题内容: 我目前正在构建一个库以对我的一些代码进行模块化,并且我遇到了Hibernate的问题。 在我的主应用程序中,我有一个hibernate配置来获取运行所需的信息,但是我的库中也需要hibernate,因为我想要的某些对象可以在其他应用程序中使用。 当我启动两个hibernate设置的tomcat服务器时,出现错误,指出无法解析bean,并且说我的查询中缺少位置参数的bean。但是,当我仅

  • 1-我有一个带有Spring Boot的API,我需要配置两个DBMS(MySQL和Postgres)。 2-对于每个DBMS,我需要配置不同的配置文件。(Dev,Prod) 遵循我的MySQL配置类: 我以为我的出口是: 重要: 当我将配置文件配置为连接到我的MySQL Dev数据库时,我只想连接到它。我想要同样的结果,当它是MySQL的Prod的基础时。 当我将配置文件配置为连接到我的Post

  • 我们可以配置多个HttpSecurity实例,就像我们可以有多个块抑郁。关键在于对WebSecurityConfigurationAdapter进行多次扩展。例如下面是一个对/api/开头的URL进行的不同的设置。 @EnableWebSecurity public class MultiHttpSecurityConfig { @Autowired public void con

  • Spring Cloud Stream支持常规配置选项以及绑定和绑定器的配置。一些绑定器允许额外的绑定属性来支持中间件特定的功能。 可以通过Spring Boot支持的任何机制将配置选项提供给Spring Cloud Stream应用程序。这包括应用程序参数,环境变量和YAML或.properties文件。 Spring Cloud Stream Properties spring.cloud.s

  • 本文向大家介绍git配置多个SSH Key,包括了git配置多个SSH Key的使用技巧和注意事项,需要的朋友参考一下 当有多个git账号时,比如: 一个github,国际认可的仓库 一个gitee码云,国内仓库,速度快 这两者如果邮箱不同的话,在生成第二个key的时候会覆盖第一个的key,导致一个用不了。 解决办法就是: 生成两个(或多个)不同的公私密钥对,用config文件管理它们。 1 步骤

  • 因此,我希望使用CI活动记录获得最终输出,作为产品列表及其详细信息。