1.下载liblept168.dll和liblept168d.dll文件,下载地址:
http://pan.baidu.com/share/link?shareid=1102209231&uk=101472617&fid=2286174501
http://pan.baidu.com/share/link?shareid=1102209231&uk=101472617&fid=388193021
2.Tesseract-ocr的dll tesseract-3.02.02-win32-lib-include-dirs下载地址:
https://tesseract-ocr.googlecode.com/files/tesseract-3.02.02-win32-lib-include-dirs.zip
解压之后包括 include文件夹和lib文件夹,配置头文件和库文件(VC++ include library, linker),建立工程进行测试。
#include "stdafx.h" #include "baseapi.h" #include <iostream> #pragma comment(lib,"libtesseract302.lib") using namespace std; int _tmain(int argc, _TCHAR* argv[]) { char * str = "D:\\validate\\1.png"; tesseract::TessBaseAPI api; api.Init(NULL, "chi_sim", tesseract::OEM_DEFAULT); //初始化,设置语言包,中文简体:chi_sim;英文:eng;也可以自己训练语言包 //api.SetVariable( "tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ); STRING text_out; bool stauts = api.ProcessPages(str, NULL, 0, &text_out); const char *string = text_out.string(); cout<<string<<endl; cout<<endl; }