• Tesseract 3.02 OCR文字识别调查记录


    • 安装使用:

    Tesseract下载地址

    https://code.google.com/p/tesseract-ocr/

    目前最新版本为3.02

    windows版下载解压后,使用命令行,进入解压后目录运行

    命令格式:

    Usage:tesseract.exe imagename outputbase [-l lang] [-psm pagesegmode]
    e...]
    
    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.
    
    Single options:
      -v --version: version info
      --list-langs: list available languages for tesseract engine

    命令举例:

    F:Tesseract-OCR>tesseract.exe 2013-09-05_154628.jpg eng -l eng -psm 6

    相关命令列表:

    功能 命令
      ambiguous_words.exe
      classifier_tester.exe
      cntraining.exe
    整合训练文件 combine_tessdata.exe
      dawg2wordlist.exe
      mftraining.exe
      shapeclustering.exe
    识别程序 tesseract.exe
      unicharset_extractor.exe
      wordlist2dawg.exe

     

    • 字库训练

     需要的字库文件参考代码:

    tesseract-ocrccutil essdatamanager.h

    对字库相关的配置文件的格式要求:

    ASCII or UTF-8 encoding without BOM

    Unix end-of-line marker (' ')

    The last character must be an end of line marker (' '). Some text editors will show this as an empty line at the end of file. If you omit this you will got error message containing "last_char == ' ':Error:Assert failed..."

    步骤:

    1.生成训练图片

    几个原则:

    保证每个字符出现的频率一般10次,常用字20次,不常用字5次;

    不能把特殊字符都放在一起,应该用更加接近实际使用的组合;

    非常重要:在字符和行之间保持一定的间隔,否则可能导致失败。(可能在3.0之后的版本修复)

    训练的数据需要以font分组,相同font的文字需要放在同一个tiff文件中,(支持多页page)

    除非字体太小(高度小于15px),没有必要做不同尺寸的训练;

    绝对不可以在同一个image文件中混杂多种字体

    (可以参考下载页中的boxtiff文件样例)

    Next print and scan (or use some electronic rendering method) to create an image of your training page. Upto 32 training files can be used (of multiple pages). It is best to create a mix of fonts and styles (but in separate files), including italic and bold.

    生成tiff文件

    2.制作box文件

    生成box文件命令:

    tesseract [lang].[fontname].exp[num].tif [lang].[fontname].exp[num] batch.nochop makebox

    例: 

    tesseract eng.timesitalic.exp0.tif eng.timesitalic.exp0 batch.nochop makebox

    3.得到一个新的字符集

    • 其他

    参考文档:

    解压后doc目录中有API说明

     

    --end--

  • 相关阅读:
    phpredis
    nginx rewrite
    注册公司流程
    WebsitePanel 2.1.0beta配置部分
    Windows下cwRsync搭建步骤
    Windows 2008下部署Exchange Server 2007
    【网站国际化必备】Asp.Net MVC 集成Paypal(贝宝)快速结账 支付接口 ,附源码demo
    Win2008远程多用户登陆的配置方法 另附详细设置: Windows server 2008 R2实现多用户远程连接
    IIS安全工具UrlScan介绍 ASP.NET 两种超强SQL 注入免费解决方案( 基于IIS,使用免费工具) 批改或隐藏IIS7.5的Server头信息 移除X-Powered-By,MVC,ASP.NET_SessionId 的 HTTP头或者cookie名称
    利用UDP19端口实施DOS攻击的真实案例
  • 原文地址:https://www.cnblogs.com/rakuhin/p/3303720.html
Copyright © 2020-2023  润新知