Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Basic tesseract-ocr API example in C++
- */
- #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 *pix = pixRead("/usr/src/tesseract-3.02/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(&pix);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement