在调用tesseract时,最重要的三个参数是 -l, -oem 和 -psm

-l 参数控制识别文本的语言。可以通过命令 tesseract --list-langs  查看已经安装的字库。

  支持中文:下载中文扩展 https://github.com/tesseract-ocr/tessdata, 把里面的 chi_sim.traineddata 复制到 **\Tesseract-OCR\tessdata 的路径。

-oem 参数控制OCR的引擎模式,控制由超正方体使用的算法类型。可以通过命令 tesseract --help-oem 查看可用的引擎模式, 一般有四种模式,默认第四种, 可以用 --oem 1表示只希望用深度学习LSTM引擎。 

  OCR Engine modes:
    0 Legacy engine only.
    1 Neural nets LSTM engine only.
    2 Legacy + LSTM engines.
    3 Default, based on what is available.

-psm 参数控制tesseract使用的自动页面分割模式。使用 tesseract --help-psm 查看模式, 我发现对于小文本,模式6和7运行良好,如果是大块文本,可以试试默认的3模式。  

  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.

使用:

img = Image.open('./img.png')
config = ("-l chi_sim --oem 1 --psm 7")
text = pytesseract.image_to_string(img, config=config)

python的tesseract库几个重要的命令的更多相关文章

  1. python 各种开源库

    测试开发 来源:https://www.jianshu.com/p/ea6f7fb69501 Web UI测试自动化 splinter - web UI测试工具,基于selnium封装. 链接 sel ...

  2. python 三方面库整理

    测试开发 Web UI测试自动化 splinter - web UI测试工具,基于selnium封装. selenium - web UI自动化测试. –推荐 mechanize- Python中有状 ...

  3. 使用python内置库pytesseract实现图片验证码的识别

    环境准备: 1.安装Tesseract模块 git文档地址:https://digi.bib.uni-mannheim.de/tesseract/ 下载后就是一个exe安装包,直接右击安装即可,安装完 ...

  4. Python的常用库

    读者您好.今天我将介绍20个属于我常用工具的Python库,我相信你看完之后也会觉得离不开它们.他们是: Requests.Kenneth Reitz写的最富盛名的http库.每个Python程序员都 ...

  5. Python底层socket库

    Python底层socket库将Unix关于网络通信的系统调用对象化处理,是底层函数的高级封装,socket()函数返回一个套接字,它的方法实现了各种套接字系统调用.read与write与Python ...

  6. 【C++实现python字符串函数库】strip、lstrip、rstrip方法

    [C++实现python字符串函数库]strip.lstrip.rstrip方法 这三个方法用于删除字符串首尾处指定的字符,默认删除空白符(包括'\n', '\r', '\t', ' '). s.st ...

  7. 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith

    [C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...

  8. 【C++实现python字符串函数库】一:分割函数:split、rsplit

    [C++实现python字符串函数库]split()与rsplit()方法 前言 本系列文章将介绍python提供的字符串函数,并尝试使用C++来实现这些函数.这些C++函数在这里做单独的分析,最后我 ...

  9. python使用cookielib库示例分享

    Python中cookielib库(python3中为http.cookiejar)为存储和管理cookie提供客户端支持,下面是使用示例 该模块主要功能是提供可存储cookie的对象.使用此模块捕获 ...

随机推荐

  1. JS中兼容问题的汇总

    获取非行内样式的兼容方式 function getStyle(obj,attr){ //获取非行间样式,obj是对象,attr是值 if(obj.currentStyle){ //针对ie获取非行间样 ...

  2. 2018-12-25-win10-uwp-显示SVG

    title author date CreateTime categories win10 uwp 显示SVG lindexi 2018-12-25 10:37:5 +0800 2018-2-13 1 ...

  3. tf.trainable_variables和tf.all_variables的对比

    tf.trainable_variables返回的是可以用来训练的变量列表 tf.all_variables返回的是所有变量的列表

  4. Linq 高级应用实例

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...

  5. ubuntu14彻底删除mysql!!!(精)

    解决方法: 删除mysql前 先删除一下 /var/lib/mysql 还有 /etc/mysql sudo rm /var/lib/mysql/ -R sudo rm /etc/mysql/ -R ...

  6. Linux架构之Rsync守护进程推和拉

    第三十三章 Rsync服务 33.1)Rsync基本概述 rsync是一款开源.快速.多功能.可实现全量及增量的本地或远程数据同步备份的优秀工具.rsync软件适用于Unix/linux/Window ...

  7. 快速排序的python实现

    def quick_sort(array, left, right): if left < right: base_index = division(array, left, right) qu ...

  8. cat 合并文件或查看文件内容

    1.命令功能 cat 合并文件或者查看文件内容. 2.语法格式 cat   option    file 参数说明 参数 参数说明 -n 打印文本,并显示每行行号并且空白行也同样包括 -b 与-n用法 ...

  9. hdu 4625 Dice(概率DP)

    Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submi ...

  10. luogu2046 海拔

    题目链接[NOI2010]海拔 首先有个性质就是海拔只会有\(0\)和\(1\)两种. 证明:海拔下降和人数乘积为总消耗,确定了海拔下降总数,如果有个地方可以使得单位消耗最小,那么全部消耗不会更劣. ...