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++对象构造时,构造函数运行时并不知道VT的存在
class A {public: A() { init(); } virtual void init() { printf("A::init\n"); }}; class B : ...
- 攻防世界--re1-100
测试文件:https://adworld.xctf.org.cn/media/task/attachments/dc14f9a05f2846249336a84aecaf18a2.zip 1.准备 获取 ...
- Mysql日期和字符的相互转换
今天从网上查到了一些关于MySQL数据库的日期转换函数的转换的用法,在这里记录一下: mysql日期和字符相互转换 date_format(date,'%Y-%m-%d') ------------- ...
- Vue 实现文件的上传
要把文件上传的web,需要分几步? 答:三步 第一步:创建一个上传文件的标签 <input type="file" id="fileExport" @ch ...
- over partition by
参考资料: 1.https://www.cnblogs.com/cjm123/p/8033639.html
- hdu 4625 Dice(概率DP)
Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submi ...
- keras 下载预训练模型报错SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
import ssl ssl._create_default_https_context = ssl._create_unverified_context https://stackoverflow. ...
- [python 学习] python 多线程
1. # -*- coding: utf-8 -*- import threading import time import random def go(name): for i in range(2 ...
- Counter的数据统计功能
Counter是dict的子类,一般用于统计,默认排序是从大到小 from collections import Counter # 输入iterable对象即可 str_counter = Coun ...
- Flask学习笔记01之环境搭建
使用pycharm搭建Flask运行环境 1. 打开pycharm ,创建一个新的工程 2. 选择创建Flask项目 3. Flask项目创建成功,结构如下 4. 运行项目 5. 发送请求 over!