谷歌开源OCR,tesseract-ocr使用笔记
2024-08-27 05:37:49
官方教程地址:https://github.com/tesseract-ocr/tesseract/wiki/Compiling
测试版本为
root@9a2a063f9534:/tesseract/testing# tesseract -v
tesseract 4.00.00dev--gcdc3533
leptonica-1.74.
libjpeg 8d (libjpeg-turbo 1.4.) : libpng 1.2. : libtiff 4.0. : zlib 1.2. Found AVX2
Found AVX
Found SSE
一、Docker + Ubuntu
git clone git@github.com:tesseract-ocr/tesseract.git
cd tesseract
docker pull ubuntu:latest
docker build -t google-ocr:latest .
docker run -itd --name ocr google-ocr:latest /bin/bash
docker exec -it ocr /bin/bash
进入环境后,需要训练功能要执行下面第二条
apt-get install -y g++ autoconf automake libtool autoconf-archive pkg-config libpng-dev libjpeg8-dev libtiff5-dev zlib1g-dev git
#training
apt-get install -y libicu-dev libpango1.-dev libcairo2-dev
Leptonica
Tesseract Leptonica Ubuntu
4.00 1.74. Must build from source
官网给出必须源码安装,所以去找源码安
cd /tmp
git clone https://github.com/DanBloomberg/leptonica.git
cd leptonica
autoreconf -vi
./autobuild
./configure
make
make install
安装主体ocr
cd /tesseract
./autogen.sh
LIBLEPT_HEADERSDIR=/usr/include
./configure --with-extra-libraries=/usr/local/lib
make install
测试安装是否成功
tesseract
tesseract -v
下载字库模型,选自己需要的就行了
字库地址:https://github.com/tesseract-ocr/tessdata
手册地址:https://github.com/tesseract-ocr/tesseract/wiki/Data-Files
将字库放入指定路径
export TESSDATA_PREFIX=/tesseract/tessdata
cp xxx.traindata /tesseract/
执行测试
cd /tesseract/testing
#english
tesseract phototest.tif result -l eng
#chinese
tesseract chi.jpg result1 -l chi_sim
检查输出
cat result.txt
cat result1.txt
可通过训练提高精度,训练方法见官方文档,这个我没试过。
附录:
python 调用接口:https://www.pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/
python 官方调用依赖:https://github.com/madmaze/pytesseract
最新文章
- 关于SubSonic3.0插件使用Json反序列化获得的实体进行更新操作时,只能执行添加而不能执行修改(编辑)操作的处理
- [Scala] akka actor编程(一)
- JavaScript中面向对象的的深拷贝和浅拷贝
- Hive get table rows count batch
- 利用HTML5 Geolocation API在百度地图中显示你的位置
- hibernate的dao操作不能提交到数据库问题的解决
- 利用C语言强行点击置灰的按钮
- 怎样在万网加入Lync Online SRV记录
- Appium 1.6.4 环境搭建流程(Java, Android+IOS, Windows+Mac)
- 让你的Dapper像EF一样调用 开源~!
- SPOJ DQUERY树状数组离线or主席树
- Jackson工具
- 一款超人气代码格式化工具prettier
- Nagios 监控 Mysql
- Why you should use async tasks in .NET 4.5 and Entity Framework 6
- Jmeter-接口功能测试
- 缩放到被选择的部分: ICommand Cmd = new ControlsZoomToSelectedCommandClass();
- IntelliJ IDEA 自动导入包 快捷方式 关闭重复代码提示
- mysq 数据库基本管理
- Android的JNI调用(三)