tesseract-ocr 图像识别所遇到的些问题

 其通过不同的语言训练库可以支持多种语言(包括中文、日文)。
从项目地址 http://code.google.com/p/tesseract-ocr下载最新版本的项目

程序安装包:


项目环境搭建:
新建一个文件夹:
tesseract-build,然后再在tesseract-build目录下面创建三个文件:

include
lib
tesseract-ocr   

include以及lib对应下载的文件名: tesseract-3.02.02-win32-lib-include-dirs.zip

tesseract-ocr直接到官网下载 tesseract-ocr-3.02.02.tar.gz

然后可以打开项目路径下:tesseract-build\tesseract-or\vs2008\tesseract.sln;

vs2008转vs 2010的话,直接把vs2008目录拷贝到当前下面重命名



剩下的就是对工程转换后一些编译环境的错误处理,不详述了;

该项目跑的时候默认读取的语言包是从 tesseract-ocr-setup-3.02.02.exe安装路径里面的tessdata文件夹下,例如我的安装路径D:\Program Files (x86)\Tesseract-OCR\tessdata目录下*.traineddata后缀名;

当使用api.init函数的时候,
参数一:表示tessdata所在文件的父路径
参数二:表示tessdata文件下面的语言包名称如eng.traineddata语言包直接填写"eng"就OK了
参数三:tesseract::OEM_TESSERACT_ONLY;可以取如下的值:

enum OcrEngineMode {
  OEM_TESSERACT_ONLY,           // Run Tesseract only - fastest
  OEM_CUBE_ONLY,                // Run Cube only - better accuracy, but slower
  OEM_TESSERACT_CUBE_COMBINED,  // Run both and combine results - best accuracy
  OEM_DEFAULT                   // Specify this mode when calling init_*(),
                                // to indicate that any of the above modes
                                // should be automatically inferred from the
                                // variables in the language-specific config,
                                // command-line configs, or if not specified
                                // in any of the above should be set to the
                                // default OEM_TESSERACT_ONLY.
};

初始化语言包,总感觉路径和文件名路径分开不舒服,直接传个语言包的绝对路径不更方便,所以做了如下修改;
我的方法比较简单粗暴,直接修改
bool Tesseract::init_tesseract_lang_data(
    const char *arg0, const char *textbase, const char *language,
    OcrEngineMode oem, char **configs, int configs_size,
    const GenericVector<STRING> *vars_vec,
    const GenericVector<STRING> *vars_values,
    bool set_only_non_debug_params) 函数;
在STRING tessdata_path = language_data_path_prefix + kTrainedDataSuffix;这行代码下面加一行
tessdata_path = arg0;

方便在调用api.init函数的时候可以直接填写好语言包的绝对路径就OK了;

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值