源代码:
#include "baseapi.h"
#include "allheaders.h"
int main()
{
char *outText;
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata path
if (api->Init(NULL, "eng")) // you can set tessdata path and language here
{
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
// Open input image with leptonica library
Pix *image = pixRead("./eurotext.tif");
api->SetImage(image);
// Get OCR result
outText = api->GetUTF8Text();
printf("---- OCR output:---- \n%s", outText);
// Destroy used object and release memory
api->End();
delete[] outText;
pixDestroy(&image);
return 0;
}
VS2015
包含目录:
C:\Users\An\Desktop\OCR\core\buid\lep\src
C:\Users\An\Desktop\OCR\core\leptonica-1.76.0\src
C:\Users\An\Desktop\OCR\core\tesseract-3.05.01\tesseract-3.05.01\api
C:\Users\An\Desktop\OCR\core\tesseract-3.05.01\tesseract-3.05.01\ccmain
C:\Users\An\Desktop\OCR\core\tesseract-3.05.01\tesseract-3.05.01\ccstruct
C:\Users\An\Desktop\OCR\core\tesseract-3.05.01\tesseract-3.05.01\ccutil
C:\Users\An\Desktop\OCR\core\tesseract-3.05.01\tesseract-3.05.01\cutil
库目录
C:\Users\An\Desktop\OCR\core\buid\lep\src\Release
C:\Users\An\Desktop\OCR\core\buid\tess\Release
附加依赖项:
leptonica-1.76.0.lib
tesseract305.lib