ubuntu linux 1604 编译安装tesseract-ocr 4.0
主要参考官方的编译,梳理一下整个流程
Linux
The build instructions for Linux also apply to other UNIX like operating systems.
Dependencies
- A compiler for C and C++: GCC or Clang
- GNU Autotools: autoconf, automake, libtool
- autoconf-archive
- pkg-config
- Leptonica
- libpng, libjpeg, libtiff
Ubuntu
If they are not already installed, you need the following libraries (Ubuntu 16.04/14.04):
一、安装依赖:
sudo apt-get install g++ autoconf automake libtool autoconf-archive pkg-config libpng12-dev libjpeg8-dev libtiff5-dev zlib1g-dev libleptonica-dev -y
或者一条一条复制:
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
if you plan to install the training tools, you also need the following libraries:
安装训练所依赖的库:
sudo apt-get install libicu-dev libpango1.0-dev libcairo2-dev
或者:
sudo apt-get install libicu-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libcairo2-dev
Leptonica
You also need to install Leptonica. Ensure that the development headers for Leptonica are installed before compiling Tesseract.
Tesseract versions and the minimum version of Leptonica required:
二、安装leptonica,
因为tesseract依赖这个库,否则在configure的时候会提示
最新的tesseract 4.0 及3.05 需要从Leptonica 源代码编译
git clone https://github.com/DanBloomberg/leptonica.git
cd leptonica
./configure
make -j8 && make install
| Tesseract | Leptonica | Ubuntu |
|---|---|---|
| 4.00 | 1.74.2 | Must build from source |
| 3.05 | 1.74.0 | Must build from source |
| 3.04 | 1.71 | Ubuntu 16.04 |
| 3.03 | 1.70 | Ubuntu 14.04 |
| 3.02 | 1.69 | Ubuntu 12.04 |
| 3.01 | 1.67 |
One option is to install the distro's Leptonica package:
sudo apt-get install libleptonica-dev
but if you are using an oldish version of Linux, the Leptonica version may be too old, so you will need to build from source.
The sources are at https://github.com/DanBloomberg/leptonica . The instructions for building are given in Leptonica README.
Note that if building Leptonica from source, you may need to ensure that /usr/local/lib is in your library path. This is a standard Linux bug, and the information at Stackoverflow is very helpful.
Installing Tesseract from Git
Please follow instructions in https://github.com/tesseract-ocr/tesseract/wiki/Compiling--GitInstallation
Also read Install Instructions
三、编译tesseract
clone源代码 :
git clone https://github.com/tesseract-ocr/tesseract.git tesseract-ocr
cd tesseract-ocr
./autogen.sh
autoreconf -i
./configure
这时会提示:
Configuration is done.
You can now build and install tesseract by running:
$ make
$ sudo make install
Training tools can be built and installed with:
$ make training
$ sudo make training-install
继续编译,先编译tesseract,在编译安装 training
make
sudo make install
make training
make training-install
sudo ldconfig
到这就完成了真个编译过程,这个时候 在命令行中 输入tesseract 会提示怎么用。
四、配置字体库
tesseract/tessdata是一个配置目录可以以此为基础把所有用的语言包放在这里面
cd tesseract的父目录
cp -r tesseract/tessdata/ tessdata/
下载需要的语言包 https://github.com/tesseract-ocr/tessdata_best 里面有各种语言包,这是训练好的语言包。简体中文下载:chi_sim.traineddatachi_sim_vert.traineddata
下载好的语言包 放在tessdata目录里面
设置环境变量 tessdata的父目录。如:export TESSDATA_PREFIX=/media/sf_E_DRIVE/src-test/tesseract_all/tesseract_linux
五、使用tesseract
具体用法可参考tesseract的使用说明
tesseract /home/app/1.png output -l chi_sim
识别/home/app/1.png这张图片。输出到output.txt 里面,用chi_sim 识别(不用加.traineddata,会默认加)
cat output.txt 可以查看刚才的内容
Install elsewhere / without root
Tesseract can be configured to install anywhere, which makes it possible to install it without root access.
To install it in $HOME/local:
./autogen.sh
./configure --prefix=$HOME/local/
make install
To install it in $HOME/local using Leptonica libraries also installed in $HOME/local:
./autogen.sh
LIBLEPT_HEADERSDIR=$HOME/local/include ./configure \
--prefix=$HOME/local/ --with-extra-libraries=$HOME/local/lib
make install
Video representation of the Compiling process for Tesseract 4.0 and Leptonica 1.7.4 on Ubuntu 16.xx
Language Data
- Download the data file(s) for the language(s) you interest in.
- Move it to the
tessdatadirectory (e.g. 'mv tessdata $TESSDATA_PREFIX' if definedTESSDATA_PREFIX)
You can also use:
export TESSDATA_PREFIX=/some/path/to/tessdata
to point to your tessdata directory (example: if your tessdata path is '/usr/local/share/tessdata' you have to use 'export TESSDATA_PREFIX='/usr/local/share/').
ubuntu linux 1604 编译安装tesseract-ocr 4.0的更多相关文章
- LINUX下编译安装PHP各种报错大集合
本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. nginx1.6.2-mysql5.5.32二进制,php安装报错解决: 123456 [root@clien ...
- 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正
前题: 在前几个月的时候,写了一篇笔记,说的是kernel compile的事情,当时经验不足,虽说编译过了,但有些地方写的有错误--因为当时的理解是有错误的.今天一一更正,记录如下: 前文笔记链接: ...
- Ubuntu通过源代码编译安装Octave 4.0
本教程/笔记,意在指导在Ubuntu及其它Linux系统上怎样通过源代码安装Octave. Octave简单介绍 Octave是GNU旗下取代matlab的数学工具软件,语法与matlab高度兼容.而 ...
- Linux:编译安装boost 1.69库
Boost库是为C++语言标准库提供扩展的一些C++程序库的总称,由Boost社区组织开发.维护.在C++的地位感觉可以和Spring在Java中相比. boost向来有准标准库之称,很多新特性例如智 ...
- linux安装软件的几种方法----linux下编译安装软件的一般步骤
linux安装软件的几种方法: 一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd so ...
- linux下编译安装vim7.4并安装clang_complete插件
linux下编译安装vim7.4并安装clang_complete插件 因为debian里软件仓库中下载安装的vim是不支持python写的插件的(可以打开vim,在命令模式先输入:py测试一下),导 ...
- linux PHP 编译安装参数详解
linux PHP 编译安装参数详解 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -- ...
- linux下编译安装curl
linux下编译安装curl 1.下载curl git clone https://github.com/curl/curl.git 2.在curl目录下生成configure文件 ./buldcon ...
- linux下编译安装boost库
linux下编译安装boost库 linux下编译安装boost库 1.下载并解压boost 1.58 源代码 下载 解压 2.运行bootstrap.sh 3.使用b2进行构建 构建成功的提示 4. ...
随机推荐
- asp.net网站防恶意刷新的Cookies与Session解决方法
本文实例讲述了asp.net网站防恶意刷新的Cookies与Session解决方法,是WEB程序设计中非常实用的技巧.分享给大家供大家参考.具体实现方法如下: Session版实现方法: public ...
- improve deep learning network 课程笔记
公开课笔记 Bias & variance bias: 1. more epoch 2. deeper network 3.hyperparameters variance : larger ...
- Github初试~从安装到连接到版本库
这里我就只说说从安装到连接到github库时出现的错误,以及如何解决 1. 下载github,安装后你就可以在系统中右键看到 Gui 和 Bush按钮 2. 此时你可能会去尝试着去连接你在github ...
- 智力大冲浪(洛谷P1230)
题目描述 小伟报名参加中央电视台的智力大冲浪节目.本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元.先不要太高兴!因为这些钱还不一定都是你的?!接下来主持人宣布了比赛规则: ...
- 微信小程序入门学习-- 简易Demo:计算器
简单学习下微信小程序 官网 简易教程 · 小程序 https://mp.weixin.qq.com/debug/wxadoc/dev/ 需要通过开发者工具,来完成小程序创建和代码编辑. 下载安装,运行 ...
- 160621、Java注解教程及自定义注解
Java注解提供了关于代码的一些信息,但并不直接作用于它所注解的代码内容.在这个教程当中,我们将学习Java的注解,如何定制注解,注解的使用以及如何通过反射解析注解. Java1.5引入了注解,当前许 ...
- Ubuntu 16.04 安装google浏览器
因为安装的Linux是64位的Ubuntu 16.04系统,所以本人决定也安装64位的谷歌Chrome浏览器.在 Ubuntu 16.04 中,要想使用谷歌的 Chrome 浏览器,可以通过命令行的方 ...
- string 转 java对象、转map的方式
1.使用fastJson 将String转 map: String out; Object succesResponse = JSON.parse(out); //先转换成Object Map ...
- 【Git和GitHub】学习笔记
1. 书籍推荐: 先看一本比较简单并且好的入门书籍 Git - Book https://git-scm.com/book/zh/v2 2. 书籍理解: Git 有三种状态,你的文件可能处于其中之一: ...
- PAT 1013 Battle Over Cities(并查集)
1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...