官方参考资料说明:
  leptonica 依赖库: ( http://www.leptonica.org/source/README.html )
             

                交叉编译 tesseract
                     (以 tesseract 3.01 为例)
 
说明:
  1. 嵌入式环境:mips架构, linux 3.08
  2. 交叉工具链: mips-linux-gnu-
  3.工具链路径: /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/
 
一、依赖库:
  依赖库: (官方有说明:https://github.com/tesseract-ocr/tesseract/wiki/Compiling#linux)
  1. leptonica-1.67
    > 其依赖库: (官方说明:http://www.leptonica.org/source/README.html)
    (1) libz (建议版本zlib_1.2.3, 实测zlib_1.2.8也可)
    (2) libjpeg_9.0 (使tesseract支持jpeg,pbm图片格式)
    (3) 如需支持其他图片格式如tif,需要安装其他库libtiif
 
二、交叉编译 leptonica-1.67
  1. 交叉编译 libjpeg_9.0
    (1)mkdir tmp
    (2)./configure --host=mips-linux-gnu --target=mips-linux-gnu --prefix=$PWD/tmp 
       CC=mips-linux-gnu-gcc CXX=mips-linux-gnu-g++
       CFLAGS=-I/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
       LDFLAGS=-L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
    (3)make -j4
    (4)make install
    (5)把tmp/下的include头文件和库文件lib复制到
        /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
        /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
      工具链下
 
  2. mkdir tmp
  3. ./configure --host=mips-linux-gnu --target=mips-linux-gnu --prefix=$PWD/tmp
    CC=mips-linux-gnu-gcc CXX=mips-linux-gnu-g++
    CFLAGS=-I/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
    LDFLAGS=-L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
    --with-jpeg (表示添加jpeg库)
    --includedir=/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
    --libdir=/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
 
    其中:
        --includedir= 表示头文件安装目录
        --libdir= 表示库安装目录
    必需配置,否则会找不到库文件,导致编译不通过
 
  4. 链接库环境变量
    export  LD_LIBRARY_PATH=/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216
        :/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
 
  5. make -j4
    出现错误:
    /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/bin/../lib/gcc/mips-linux-gnu/4.7.2/../../../../mips-linux-gnu/bin/ld: warning: libz.so.1,     needed by ./.libs/liblept.so, not found (try using -rpath or -rpath-link)
    ./.libs/liblept.so: undefined reference to `inflate'
    ./.libs/liblept.so: undefined reference to `powf'
    ./.libs/liblept.so: undefined reference to `ceil'
    ./.libs/liblept.so: undefined reference to `atan2'
    ./.libs/liblept.so: undefined reference to `expf'
    ./.libs/liblept.so: undefined reference to `deflate'
    ./.libs/liblept.so: undefined reference to `floorf'
    ./.libs/liblept.so: undefined reference to `deflateInit_'
    ./.libs/liblept.so: undefined reference to `sin'
    ./.libs/liblept.so: undefined reference to `inflateEnd'
    ./.libs/liblept.so: undefined reference to `atan'
    ./.libs/liblept.so: undefined reference to `deflateEnd'
    ./.libs/liblept.so: undefined reference to `tan'
    ./.libs/liblept.so: undefined reference to `inflateInit_'
    ./.libs/liblept.so: undefined reference to `cos'
    ./.libs/liblept.so: undefined reference to `log'
    ./.libs/liblept.so: undefined reference to `sqrt'
    collect2: error: ld returned 1 exit status
    
    原因:找不到libz库,缺少math库
    解决:修改 Makefile
        对于当前路径下 src/Makefile 和 Makefile:
      (1) LIBS =
          -> LIBS = -lm
      (2) ZLIB_LIBS =
          -> ZLIB_LIBS = -lz
      (3) LDFLAGS = -L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/mips-linux-gnu/libc/lib
               -L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
 
  6. make install
 
  7. 把tmp/下的include头文件和库文件lib复制到
    /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
    /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
   工具链下(如已配置 --includedir --libdir, 则make install时已经安装到以上目录)
 
 
三、交叉编译tesseract 3.01
  1. ./autogen.sh
  2. mkdir tmp
  3. ./configure --host=mips-linux-gnu --target=mips-linux-gnu --prefix=$PWD/tmp
    CC=mips-linux-gnu-gcc CXX=mips-linux-gnu-g++
    CFLAGS=-I/home/newton_linux/prebuilts/toolchains/mips-gcc472- glibc216/include
    LDFLAGS=-L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
    报错:
       checking for leptonica... configure: error: leptonica not found:
    修改为:
    ./configure --host=mips-linux-gnu --target=mips-linux-gnu --prefix=$PWD/tmp
    CC=mips-linux-gnu-gcc CXX=mips-linux-gnu-g++
    CFLAGS=-I/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include
    LDFLAGS=-L/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
    LIBLEPT_HEADERSDIR=/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/include (指定leptonica库路径)
 
    如果再报错:
        checking for leptonica... yes
        checking for pixCreate in -llept... no
        configure: error: leptonica library missing
        则删除 configure 文件中的以下内容的带”*“的行
          * if test "x$ac_cv_lib_lept_pixCreate" = xyes; then :
            cat >>confdefs.h <<_ACEOF
            #define HAVE_LIBLEPT 1
            _ACEOF
            LIBS="-llept $LIBS"
          * else
            * as_fn_error $? "leptonica library missing" "$LINENO" 5
          * fi
 
  4. 链接库环境变量不变
    export LD_LIBRARY_PATH=/home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216:
                 /home/newton_linux/prebuilts/toolchains/mips-gcc472-glibc216/lib
 
  5. make -j4
    出现错误:
      svutil.cpp: In static member function 'static void SVSync::StartProcess(const char*, const char*)':
      svutil.cpp:89:18: error: 'fork' was not declared in this scope
      svutil.cpp:119:28: error: 'execvp' was not declared in this scope
      svutil.cpp: In member function 'void SVNetwork::Close()':
      svutil.cpp:262:16: error: 'close' was not declared in this scope
      svutil.cpp: In constructor 'SVNetwork::SVNetwork(const char*, int)':
      svutil.cpp:417:14: error: 'sleep' was not declared in this scope
 
    原因:无对应头文件
    解决:
       svutil.cpp 文件开始出添加头文件: #include <unistd.h>
 
  6. make install
 
四、开发板上使用tesseract
  1. 分别把tesseract、leptonica、libjpeg_9、libz的tmp/下的include头文件和库文件lib复制到开发板/include和/lib目录下
  2. 在开发板上设置语言数据路径:
    export TESSDATA_PREFIX=/alg
    即把语言数据文件放置在/alg/tessdata之下
  3. 开发板上执行:
    tesseract   xxx.jpg   out   -l eng
 

交叉编译 tesseract的更多相关文章

  1. tesseract系列(1) -- tesseract用vs编译成库

    1.下载teseract 下载地址github:     https://github.com/tesseract-ocr/tesseract/releases/ 2.编译源码 源码的编译有两种方式 ...

  2. Linux主机上使用交叉编译移植u-boot到树莓派

    0环境 Linux主机OS:Ubuntu14.04 64位,运行在wmware workstation 10虚拟机 树莓派版本:raspberry pi 2 B型. 树莓派OS: Debian Jes ...

  3. Ubuntu 16.04 安装 arm-linux-gcc 嵌入式交叉编译环境 问题汇总

    闲扯: 实习了将近半年一直在做硬件以及底层的驱动,最近要找工作了发现了对linux普遍要求很高,而且工作岗位也非常多,所以最近一些时间在时不时地接触linux. 正文:(我一时兴起开始写博客,准备不充 ...

  4. Linux 14.04lts 环境下搭建交叉编译环境arm-linux-gcc-4.5.1

    交叉编译工具链是为了编译.链接.处理和调试跨平台体系结构的程序代码,在该环境下编译出嵌入式Linux系统所需要的操作系统.应用程序等,然后再上传到目标板上. 首 先要明确gcc 和arm-linux- ...

  5. Linux主机上实现树莓派的交叉编译及文件传输,远程登陆

    0.环境 Linux主机OS:Ubuntu14.04 64位,运行在wmware workstation 10虚拟机 树莓派版本:raspberry pi 2 B型. 树莓派OS:官网下的的raspb ...

  6. FFmpeg和X264的交叉编译环境

    在下载好了FFmpeg和X264的源码包之后,在Linux下进行安装的基本流程就是切换到其源码的根目录,然后以此执行以下命令.基本上所有的开源源码包的默认编译安装都是这三步. ./configure ...

  7. Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程)

    Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程) 声明:本教程在参考了以下博文,并经过自己的摸索后实际操作得出,本教程系本人原创,由于升级 ...

  8. selenium使用笔记(二)——Tesseract OCR

    在自动化测试过程中我们经常会遇到需要输入验证码的情况,而现在一般以图片验证码居多.通常我们处理这种情况应该用最简单的方式,让开发给个万能验证码或者直接将验证码这个环节跳过.之前在技术交流群里也跟朋友讨 ...

  9. Ubuntu 树莓派2b交叉编译环境

    在一个平台上生成另一个平台上的可执行代码.为什么要大费周折的进行交叉编译呢?一句话:不得已而为之.有时是因为目的平台上不允许或不能够安装所需要的编译器,而又需要这个编译器的某些特征:有时是因为目的平台 ...

随机推荐

  1. java zip4j 内存文件和磁盘文件 压缩和加密

    经常服务器需要对文件进行压缩,网络上流传较多的是从磁盘文件中来压缩成zip文件.但是常常服务器的文件存放在内存中,以byte[]形式存储在内存中.这个时候就不能使用网络上流传的常用方法了,这里就需要对 ...

  2. OVS 中的 upcall 线程

    总体概览如下: 假设upcall handler线程有两个,vport有四个,那么每个vport下都将持有两个NetLink连接的信息,这两个NetLink连接将被用来上送upcall消息. 每个Ne ...

  3. 基于FPGA的均值滤波算法的实现

    前面实现了基于FPGA的彩色图像转灰度处理,减小了图像的体积,但是其中还是存在许多噪声,会影响图像的边缘检测,所以这一篇就要消除这些噪声,基于灰度图像进行图像的滤波处理,为图像的边缘检测做好夯实基础. ...

  4. Docker 网络命令

    docker network create docker network connect docker network ls docker network rm docker network disc ...

  5. python基础之数据类型/字符串/元组/列表/字典

    Python 数据类型 数字类型: int整型,long 长整型(在python3.0里不区分整型和长整型).float浮点型:complex复数(python中存在小数字池:-5--257):布尔值 ...

  6. php访问数据库$result=$mysql_qurey('')判断是否是空值

    在访问数据库后得到result值,前提是$relust为true,就是没有发生错误连接情况,但是查询的条件由于不满足导致返回值为空,此时判断就不能用!来决定是否有返回数据了,经过书籍搜索,用resul ...

  7. css3自适应圆

    .class{ width:auto; height:auto; border-radius:11px; min-width:14px; padding:0 4px; font-size:12px; ...

  8. PHP设计模式:简单工厂

    示例代码详见https://github.com/52fhy/design_patterns 简单工厂 简单工厂模式的工厂类一般是使用静态方法,通过接收的参数的不同来返回不同的对象实例. 也就是使用的 ...

  9. js传宗接代---继承

    前几天重温了一下js的继承,今天分享给大家: 一,类式继承. 所谓的类式继承就是:第二个类的原型prototype被赋予了第一个类的实例,如subcals.prototype=new supercls ...

  10. 玩转spring boot——websocket

    前言 QQ这类即时通讯工具多数是以桌面应用的方式存在.在没有websocket出现之前,如果开发一个网页版的即时通讯应用,则需要定时刷新页面或定时调用ajax请求,这无疑会加大服务器的负载和增加了客户 ...