我是一个tesseract方面的菜鸟,最近想通过tesseract3.02来识别图片中的文字,但是我的代码当调用“eng.traindata”库时对图片上的英文有很好的识别效果,但是调用“chi_sim.traindata”文字库时识别图片上的汉字都是乱码。希望大家能够帮助我,谢谢大家了。
代码:
#include "stdafx.h"
#include "baseapi.h"
#include "strngs.h"
int _tmain(int argc, _TCHAR* argv[])
{
const char * image = "image1.jpg";
tesseract::TessBaseAPI api;
//api.Init(NULL, "eng", tesseract::OEM_TESSERACT_ONLY);//识别英文
api.Init(NULL, "chi_sim", tesseract::OEM_TESSERACT_ONLY);//识别汉字
STRING text_out;
if (!api.ProcessPages(image, NULL, 0, &text_out))
{
printf("Can not read this picture!!!");
return 0;
}
printf(text_out.string());
getchar();
return 0;
}