• 用jTessBoxEditor和tesseract-ocr-setup-3.02.02训练字库


    创建字库步骤:

    下载安装好两个工具:

    -----jTessBoxEditor
    -----tesseract-ocr---3.0.2版本

    在样本图片所在目录下创建一个名称为font_properties的文件,用记事本打开,
    font 的取值为1或0,表示字体是否具有这些属性。
    输入以下下内容:
    例如:font 0 0 0 0 0

    修改样图文件名。
    必须与[lang].[fontname].exp[num].box中的名称保持一致。

    其中fontname为字体名称,lang为语言类型,num为序号,随便写,但是格式要正确。

    1:将需要组建字库的图片文件改为[语言].[字体].[exp0].tif格式。例如:num.font.exp0.tif
    2.通过命令行进入样本文件夹,输入以下命令生成box文件:
    生成box文件: tesseract num.font.exp0.tif num.font.exp0 batch.nochop makebox
    命令详解:
    Usage:tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]
    pagesegmode values are:
    0 = Orientation and script detection (OSD) only.
    1 = Automatic page segmentation with OSD.
    2 = Automatic page segmentation, but no OSD, or OCR
    3 = Fully automatic page segmentation, but no OSD. (Default)
    4 = Assume a single column of text of variable sizes.
    5 = Assume a single uniform block of vertically aligned text.
    6 = Assume a single uniform block of text.
    7 = Treat the image as a single text line.
    8 = Treat the image as a single word.
    9 = Treat the image as a single word in a circle.
    10 = Treat the image as a single character.
    -l lang and/or -psm pagesegmode must occur before anyconfigfile.
    613/5000

    0 =定位和脚本检测(OSD)。
    1 =使用OSD自动分割页面。
    2 =自动页面分割,但没有OSD或OCR
    3 =完全自动的页面分割,但没有OSD。(默认)
    4 =假设有一列不同大小的文本。
    5 =假设一个垂直对齐的文本块。
    6 =假设一个统一的文本块。
    7 =将图像视为单个文本行。
    8 =将图像视为一个单词。
    9 =把图像看成是圆中的一个单词。
    10 =将图像视为单个字符。
    -l lang和/或-psm pagesegmode必须出现在任何配置文件之前。

    3.用jTessBoxEditor进行修正,保存。

    4.创建批处理文件,输入以下内容(注意修改文件名)

    echo Run Tesseract for Training..
    tesseract.exe number.font.exp1.tif number.font.exp1 nobatch box.train

    echo Compute the Character Set..
    unicharset_extractor.exe number.font.exp1.box
    mftraining -F font_properties -U unicharset -O number.unicharset number.font.exp1.tr

    echo Clustering..
    cntraining.exe number.font.exp1.tr

    echo Rename Files..
    rename normproto number.normproto
    rename inttemp number.inttemp
    rename pffmtable number.pffmtable
    rename shapetable number.shapetable

    echo Create Tessdata..
    combine_tessdata.exe number.
    cmd /k echo.

    输出结果:

    其中
    Offset 1、3、4、5、13这些项不是-1
    表示创建成功!
    其中number.traineddata文件就是训练的字库文件。
    否则即使创建出来number.traineddata文件也是不能用的。

  • 相关阅读:
    java中string与json互相转化
    UVa 10125
    IOS开发之蘑菇街框架
    从头认识设计模式-策略模式-03-思考过程二:在每个类里面单独添加方法或者添加接口
    使用spring-loaded开源项目,实现java程序和web应用的热部署
    矩阵高速幂专题(二)
    EBS 第一个项目 学习总结 ---- 发运模块
    关于App程序猿泡沫
    Go 语言编程
    jar运行main函数的方法
  • 原文地址:https://www.cnblogs.com/dadada-jiasheng/p/9795886.html
Copyright © 2020-2023  润新知