hans

hans

【OCR】源码编译安装tesseracr-ocr并简单说一下接口——Ubuntu14.04


一、源码编译安装:#

安装前建议你备份一下 /usr/include/ 目录下 opencv 和 opencv2 两个目录。

反正我每次安装完 tesseract 后,我的 opencv 头文件不是没了就是出问题。

github 地址: https://github.com/tesseract-ocr/tesseract/releases

建议下载安装 4.0 版本,有 LSTM,准确率和速度都不错。

其次建议下载安装 3.05 版本,也是此时的最新版本,没有 LSTM。

安装介绍地址: [ https://github.com/tesseract-
ocr/tesseract/blob/master/INSTALL.GIT.md ](https://github.com/tesseract-
ocr/tesseract/blob/master/INSTALL.GIT.md)

懒得打开上面安装链接的看下面就好。

  1. 先安装各种依赖

    sudo apt-get install g++ # or clang++ (presumably)
    sudo apt-get install autoconf automake libtool
    sudo apt-get install autoconf-archive
    sudo apt-get install pkg-config
    sudo apt-get install libpng12-dev
    sudo apt-get install libjpeg8-dev
    sudo apt-get install libtiff5-dev
    sudo apt-get install zlib1g-dev

如果你要安装训练工具的话,还要安装下面三个依赖

2. 然后安装 Leptonica

这个软件有很多版本,先给你下载地址,然后给你版本对照表。

官网地址: http://www.leptonica.org/

1668714209762.jpg

必须源码编译安装,默认安装目录在 /usr/local/ 下

  1. 安装 tesseract

    ./autogen.sh
    ./configure
    make
    sudo make install
    sudo ldconfig
    make training
    sudo make training-install

二、部分 API 介绍#

预训练模型地址: https://github.com/tesseract-ocr/tessdata

预训练模型可以放到任意位置,也可以放到默认位置:/usr/local/share/tessdata/

这个方法基本原理我当时也没深研究。

我理解大概就是先把图片转化为灰度图。

然后以当前点为中心,判断周围一圈的点是否不为白色。

如果这个点不是白色,那么继续以这个点为中心点向外扩张。

通过上面简单原理,我们可以知道。

输入图片越小运行速度越快

输入图片越干净输出越准确

字符不能有过大旋转角度(作者肯定不会 360 度旋转训练模型,他也确实没这么做)

下面是 API 例子:

API 头文件地址: https://github.com/tesseract-ocr/tesseract/blob/master/api/baseapi.h

先这样吧,这个工具功能蛮强大的。还需要时间慢慢研究。

顺便提一嘴我做卡片识别的思路。

关键技术是 opencv 的 findContours () 配合 finetune 后的 mnist,数字识别效果拔群。

以上部分内容参考自: https://github.com/tesseract-ocr/tesseract

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.