Tesseract ocr 中文批量训练脚本

@echo off 

 

set "src=%1%" 

set "font_name=%2%"

set "desc=%3%" 

 

 

if  not  defined src set /p src=" please pass your filename : "

 

if  not  defined font_name set /p font_name=" please pass your font_name : "

 

rem 判断参数的合法性

 

if  not  defined src echo  IllegalArgumentException arg1 must not be null &  pause>nul & exit

 

if  not  defined font_name echo  IllegalArgumentException arg2 must not be null &  pause>nul & exit

 

if  not  defined desc set "desc=%src:~0,-4%"  

 

 echo desc %desc%

 

rem 如果目录下没有font_properties 文件创建 font_properties ,并写入文件

if exist font_properties (

 echo  font_properties exist

) else (

ECHO  %font_name% 0 0 0 0 0  >"font_properties"

)

 

rem  删除原有文件  

if exist %font_name%.unicharset ECHO DEL %font_name%.unicharset &   DEL  /Q  names %font_name%.unicharset

if exist %font_name%.inttemp  ECHO DEL %font_name%.inttemp &  DEL  /Q  names %font_name%.inttemp

if exist %font_name%.pffmtable  ECHO DEL %font_name%.pffmtable &  DEL  /Q  names %font_name%.pffmtable

if exist %font_name%.shapetable ECHO DEL %font_name%.shapetable & DEL  /Q  names %font_name%.shapetable

if exist %font_name%.normproto ECHO DEL %font_name%.normproto & DEL  /Q  names %font_name%.normproto

if exist %font_name%.font_properties ECHO DEL %font_name%.font_properties & DEL  /Q  names %font_name%.font_properties

 

rem   makebox

 

tesseract  %src%  %desc%   -l chi_sim -psm 6 batch.nochop makebox

 

java -Xms128m -Xmx512m -jar jTessBoxEditor/jTessBoxEditor.jar

 

ECHO Please change your results , and press any key to continue

 

pause>nul 

  

tesseract  %src%  %desc%  -l chi_sim -psm 6 nobatch box.train

 

unicharset_extractor %desc%.box

 

shapeclustering -F font_properties -U unicharset %desc%.tr

 

mftraining -F font_properties -U unicharset -O  unicharset %desc%.tr

 

cntraining %desc%.tr

 

 

rem  配置新文件

if exist unicharset ECHO rename unicharset %font_name%.unicharset &  rename unicharset %font_name%.unicharset

if exist inttemp ECHO rename inttemp %font_name%.inttemp &  rename inttemp %font_name%.inttemp

if exist pffmtable ECHO rename pffmtable %font_name%.pffmtable &  rename pffmtable %font_name%.pffmtable

if exist shapetable ECHO rename shapetable %font_name%.shapetable &  rename shapetable %font_name%.shapetable

if exist normproto ECHO rename normproto %font_name%.normproto &  rename normproto %font_name%.normproto

 

combine_tessdata %font_name%.

 

if exist font_properties ECHO rename font_properties %font_name%.font_properties & rename font_properties %font_name%.font_properties

 

ECHO  press any key to continue

pause>nul 

 

 

转载于:https://my.oschina.net/rock912/blog/609780

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值