Skip to content

Instantly share code, notes, and snippets.

@shwangdev
Created August 15, 2012 01:40
Show Gist options
  • Save shwangdev/3354620 to your computer and use it in GitHub Desktop.
Save shwangdev/3354620 to your computer and use it in GitHub Desktop.
#include <baseapi.h>
#include <iostream>
#include <allheaders.h>
Pix *pix;
int offset;
float slope;
int main(int argc, char *argv[]) {
tesseract::TessBaseAPI api;
pix = pixRead(argv[1]);
api.Init(NULL, "eng");
api.SetPageSegMode(tesseract::PSM_AUTO);
api.SetImage(pix);
char* outText = api.GetUTF8Text();
int conf = api.MeanTextConf();
api.GetTextDirection(&offset, &slope);
printf("Confidence=%d\n", conf);
printf("Offset: %d Slope: %.2f\n", offset, slope);
printf("OCR output:\n\n");
printf(outText);
api.Clear();
api.End();
delete [] outText;
pixDestroy(&pix);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment