zoukankan      html  css  js  c++  java
  • Tesseract 3 语言数据的训练方法

    需要用到的程序

    (1) Tesseract 3.00
    (2) Tesseract 3.00 Bugfix
    (3) CowBoxer 1.01
    (4) Universal Extractor 1.61 (非必需)

    使用 Universal Extractor 将 Tesseract 的安装包解开,再用 Bugfix 里的 tesseract.exe 覆盖原来的主程序,Tesseract 就可用了。CowBoxer 是用于修改 box 文件的程序。

    生成第一个 box 文件

    演示中将 Tesseract 解压到了 E: esseract-ocr 目录。然后在该目录中建立了一个 build 目录用于存放原始数据和训练过程中生成的文件。原始图片数据一共有 3 个 (test.001.tif - test.003.tif):





    首先生成第一个图片 test.001.tif 的 box 文件,这里使用官方的 eng 语言数据进行文字识别:

    E: esseract-ocruild>.. esseract test.001.tif test.001 -l eng batch.nochop makebox
    Tesseract Open Source OCR Engine with Leptonica
    Number of found pages: 1.

    执行完这个命令之后,build 目录下就生成了一个 test.001.box。使用 CowBoxer 打开这个 box 文件,CowBoxer 会自动找到同名的 tif 文件显示出来。



    CowBoxer 的使用方法可以看 Help -> About 中的说明。修改完成之后 File -> Save box file 保存文件。

    生成初始的 traineddata

    接下来使用这一个 box 文件先生成一个 traineddata,在接下来生成其他图片的 box 文件时,使用这个 traineddata 有利于提高识别的正确率,减少修改次数。

    .. esseract test.001.tif test.001 nobatch box.train
    .. rainingunicharset_extractor test.001.box
    .. rainingmftraining -U unicharset -O test.unicharset test.001.tr
    .. rainingcntraining test.001.tr
    rename normproto test.normproto
    rename Microfeat test.Microfeat
    rename inttemp test.inttemp
    rename pffmtable test.pffmtable
    .. rainingcombine_tessdata test.

    在 build 目录下执行完这一系列命令之后,就生成了可用的 test.traineddata。

    生成其余 box 文件

    将上一步生成的 test.traineddata 移动到 tesseract-ocr essdata 目录中,接下来生成其他 box 文件时就可以通过 -l test 参数使用它了。

    .. esseract test.002.tif test.002 -l test batch.nochop makebox
    .. esseract test.003.tif test.003 -l test batch.nochop makebox

    这里仅仅是使用 3 个原始文件作为例子。实际制作训练文件时,什么时候生成一个 traineddata 根据情况而定。中途生成 traineddata 的目的只是为了提高文字识别的准确率,使后面生成的 box 文件能少做修改。

    生成最终的 traineddata

    在所有的 box 都制作完成后,就可以生成最终的 traineddata 了。

    .. esseract test.001.tif test.001 nobatch box.train
    .. esseract test.002.tif test.002 nobatch box.train
    .. esseract test.003.tif test.003 nobatch box.train
    .. rainingunicharset_extractor test.001.box test.002.box test.003.box
    .. rainingmftraining -U unicharset -O test.unicharset test.001.tr test.002.tr test.003.tr
    .. rainingcntraining test.001.tr test.002.tr test.003.tr
    rename normproto test.normproto
    rename Microfeat test.Microfeat
    rename inttemp test.inttemp
    rename pffmtable test.pffmtable
    .. rainingcombine_tessdata test.

    在文件较多时可以用程序生成这种脚本执行。
     
    当前语言: 中文 (简体)
  • 相关阅读:
    21分钟 MySQL 入门教程
    git学习网址
    Unsupported major.minor version 51.0解决办法
    导入Mybatis_Spring项目遇到的问题
    SQL 模糊查询
    数据持久层
    持久化框架
    ORM
    ORM框架
    重量级框架
  • 原文地址:https://www.cnblogs.com/waw/p/5493989.html
Copyright © 2011-2022 走看看