Giter Club home page Giter Club logo

cardscanner's Introduction

Opencv Tesseract

识别的基本思路,感谢前人的总结:

图片处理识别上文及代码已足够详细,在此仅附上语言包训练方法;

Tesseract Training

  • 中英语言包相加近百兆,身份证号码只用到 0~9+X,故可自行训练语言.
  • 其他语言需求自行准备素材: Text + Font 生成 tif & box, 或者图片转 tif.

Install

  • Homebrew

  • Install tesseract (3.02)

      // Install ImageMagick for image conversion:
      brew install imagemagick
      // Install tesseract for OCR:
      brew install tesseract --all-languages
      // Install training tools
      brew install tesseract --with-training-tools
  • java

  • jTessBoxEditor

Material

自动方法(Text-->tif & box)

  • training_text.txt(UTF-8) 文件写入: 1234567890X(需要识别的目标)
  • Droid Sans Mono Font 36(对应的字体)
  • Press Generate --> .tif & .box

手动方法(jpg/png --> tif & box)

  • 处理图片

      // 灰度: 直接转 tif 会提示:不支持16-bit png
      convert -monochrome name.png name.png
      // png/jpg 转 tif
      convert name.jpg name.tif
  • jTessBoxEditor —— Tools —— Merge Tiff

  • 全选合并 tif & 命名为 language.font.exp0.tif

      // box
      tesseract language.font.exp0.tif language.font.exp0 makebox
      // -l -psm 参数可选

检查 .tif 识别

  • Box Editor tab: Open .tif 检查识别正误,纠正保存

Training

  • touch font_properties 内容: font 0 0 0 0 0
  • 生成训练文件(UTF-8 without DOM)
// 生成 .tr 训练文件
tesseract language.font.exp0.tif language.font.exp0 nobatch box.train
// 生成字符集文件
unicharset_extractor language.font.exp0.box
// 生成 shape 文件
shapeclustering -F font_properties -U unicharset -O language.unicharset language.font.exp0.tr
// 生成聚集字符特征文件: unicharset、inttemp、pffmtable
mftraining -F font_properties -U unicharset -O language.unicharset language.font.exp0.tr
// 生成正常化特征文件 normproto
cntraining language.font.exp0.tr
  • 训练文件改名
mv normproto language.normproto  
mv inttemp language.inttemp  
mv pffmtable language.pffmtable   
mv unicharset language.unicharset  
mv shapetable language.shapetable  
  • 合并训练文件
// 生成fontname.traineddata文件
combine_tessdata language.
  • 命令行最后必须带一个点。
  • 执行结果中,1,3,4,5,13这几行必须有数值,才代表命令执行成功。

cardscanner's People

Contributors

aixtuz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.