python的tesseract库几个重要的命令
在调用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库几个重要的命令的更多相关文章
- python 各种开源库
测试开发 来源:https://www.jianshu.com/p/ea6f7fb69501 Web UI测试自动化 splinter - web UI测试工具,基于selnium封装. 链接 sel ...
- python 三方面库整理
测试开发 Web UI测试自动化 splinter - web UI测试工具,基于selnium封装. selenium - web UI自动化测试. –推荐 mechanize- Python中有状 ...
- 使用python内置库pytesseract实现图片验证码的识别
环境准备: 1.安装Tesseract模块 git文档地址:https://digi.bib.uni-mannheim.de/tesseract/ 下载后就是一个exe安装包,直接右击安装即可,安装完 ...
- Python的常用库
读者您好.今天我将介绍20个属于我常用工具的Python库,我相信你看完之后也会觉得离不开它们.他们是: Requests.Kenneth Reitz写的最富盛名的http库.每个Python程序员都 ...
- Python底层socket库
Python底层socket库将Unix关于网络通信的系统调用对象化处理,是底层函数的高级封装,socket()函数返回一个套接字,它的方法实现了各种套接字系统调用.read与write与Python ...
- 【C++实现python字符串函数库】strip、lstrip、rstrip方法
[C++实现python字符串函数库]strip.lstrip.rstrip方法 这三个方法用于删除字符串首尾处指定的字符,默认删除空白符(包括'\n', '\r', '\t', ' '). s.st ...
- 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith
[C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...
- 【C++实现python字符串函数库】一:分割函数:split、rsplit
[C++实现python字符串函数库]split()与rsplit()方法 前言 本系列文章将介绍python提供的字符串函数,并尝试使用C++来实现这些函数.这些C++函数在这里做单独的分析,最后我 ...
- python使用cookielib库示例分享
Python中cookielib库(python3中为http.cookiejar)为存储和管理cookie提供客户端支持,下面是使用示例 该模块主要功能是提供可存储cookie的对象.使用此模块捕获 ...
随机推荐
- C# 反射实现动态加载程序集
原文:https://blog.csdn.net/pengdayong77/article/details/47622235 在.Net 中,程序集(Assembly)中保存了元数据(MetaData ...
- 把int 类型转化为varchar并且去掉小数点同时以千分号‘,’分割
把int 类型转化为money 类型,再转化为varchar,去掉小数点同时以千分号‘,’分割. select '$' + left(Convert(VARCHAR, cast(10000 as mo ...
- Git 出现Branch master set up to track remote branch master问题 与忽略文件上传
错误:在push 到远程仓库是一直提示下列错误,检查了使用status检查了也没有发现错误,最后排查出来是当前分支为((no branch))即右上那个id (┬_┬)..... 原因:出现这个问题的 ...
- 只要三步,你就可以在github上发布网站了
今天,看到github推送了一个新的消息,Publishing with GitHub Pages, now as easy as 1, 2, 3.总结起来就是在github将你的文档或者发布网页将会 ...
- CSS3 (border-radius)深度探析
border-radius 为元素添加圆角边框 <div class = "demo"></div> .demo{ width:100px; height: ...
- weakHashMap 用法
WeakHashMap,此种Map的特点是: 当除了自身有对key的引用外,此key没有其他引用,那么GC之后此map会自动丢弃此值 当使用 WeakHashMap 时,即使没有显示的添加或删除任何元 ...
- AOS Clustering on one Server
原文链接:http://www.cnblogs.com/JackyXu1981/articles/1287910.html AOS Clustering on one Server AOS Clust ...
- Java List 类型转换
java的类型转换让人忍不住在开始编码前骂一声 FUCK! 1 子类转父类 up List<SubClass> subs = ...; List<? extends BaseCl ...
- css3 动画实例
animation 动画 animation-duration 代码实例: <!DOCTYPE html> <html> <head> <meta chars ...
- threading包的例子和queue包的例子
参考:https://www.cnblogs.com/tkqasn/p/5700281.html 参考:https://www.cnblogs.com/tkqasn/p/5700281.html th ...