I am having problems while installing tesseract to develop in C++ on Windows 10.
Can anyone provide a guide to get:
1. Leptonica (required by tesseract) lib and includes
2. Tesseract lib and includes
3. Link both to project (e.g. Visual Studio)
so that example from https://github.com/tesseract-ocr/tesseract/wiki/APIExample works:
#include <tesseract/baseapi.h>
#include <leptonica/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")) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
// Open input image with leptonica library
Pix *image = pixRead("/usr/src/tesseract/testing/phototest.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;
}
Install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so
.\vcpkg install tesseract:x64-windows-static
. Dependency libraries likeLeptonica
will be auto installed for you. The tesseract can be auto integrated to your VS project using.\vcpkg integrate install.