#include <QApplication> #include <tesseract/baseapi.h> #include <leptonica/allheaders.h> int main() { //QApplication a(argc, argv); char *outText; tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI(); if (api->Init(NULL, "eng")) { fprintf(stderr, "Could not initialize tesseract.\n"); exit(1); } Pix *image = pixRead("/home/ubuntu/Desktop/image.png"); api->SetPageSegMode(tesseract::PSM_AUTO_OSD); api->SetImage(image); // 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; //return a.exec(); }