Tesseract libraries on Qt 5.7 Mingw32 in Windows



  • Hi, i'm trying to build the tesseract ocr libraries in order to use these on qt 5.7. I've found only this link tutorial but when i try to launch, at the end, the code qt says me that:

    Starting C:\Users\fed_2\Documents\build-Prova_tsr-Desktop_Qt_5_7_1_MinGW_32bit-Debug\debug\Interfaccia.exe...
    The program has unexpectedly finished.
    C:\Users\fed_2\Documents\build-Prova_tsr-Desktop_Qt_5_7_1_MinGW_32bit-Debug\debug\Interfaccia.exe crashed.

    has anyone ever used these libraries on QT and is able to explain how to install correctly?

    Thank you


  • Lifetime Qt Champion

    Hi,

    Can you show a stack trace ?

    By the way, where are the Tesseract .dlls located ?

    Depending on that, you should modify the PATH environment variable in the Run part of the Project panel to contain also the folder to them.



  • All the libraries are built following the tutorial in the link that i show in the main post.
    The .pro file is that:

    SOURCES += main.cpp\
    
    
    INCLUDEPATH+=C:\\new\\include
     LIBS +=-LC:\\new\\lib \
                -ltesseract.dll\
                -llept.dll
    
    INCLUDEPATH+=C:\\OpenCV3.0\\opencv_bin\\install\\include
    
    LIBS+=-LC:\\OpenCV3.0\\opencv_bin\\bin\
    -lopencv_calib3d320d \
    -lopencv_core320d\
    -lopencv_features2d320d\
    -lopencv_flann320d\
    -lopencv_highgui320d\
    -lopencv_imgcodecs320d\
    -lopencv_imgproc320d\
    -lopencv_ml320d\
    -lopencv_objdetect320d\
    -lopencv_photo320d\
    -lopencv_shape320d\
    -lopencv_stitching320d\
    -lopencv_superres320d\
    -lopencv_video320d\
    -lopencv_videoio320d\
    -lopencv_videostab320d
    
    
    
    

    and the main file

    
    #include <tesseract/baseapi.h>
    #include <tesseract/strngs.h>
    #include <iostream>
    
    int main(int argc, char** argv)
    {
    
    
    const char* lang = "eng";
    const char* filename = "C:/immagini/nn.jpg";
    
    tesseract::TessBaseAPI tess;
    tess.Init(NULL, lang, tesseract::OEM_DEFAULT);
    tess.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
    
    FILE* fin = fopen(filename, "rb");
    if (fin == NULL)
    {
    std::cout << "Cannot open " << filename << std::endl;
    return -1;
    }
    fclose(fin);
    
    STRING text;
    if (!tess.ProcessPages(filename, NULL, 0, &text))
    {
    std::cout << "Error during processing." << std::endl;
    return -1;
    }
    else
    std::cout << text.string() << std::endl;
    
    return 0;
    }
    
    
    

  • Lifetime Qt Champion

    But you likely have a runtime problem hence my question of location of the .dlls. Did you modify the PATH environment variable in Qt Creator like I suggested ? Otherwise your application won't find the tesseract nor the OpenCV .dlls file thus it won't be able to start.

    Note that your tesseract link lines look wrong, they should be like the OpenCV ones.



  • Yes i've
    I checked the PATH environment and the path is there. The .pro file works for the opencv libraries but when it calls the "tesseract::TessBaseAPI tess" that line it crashed.


  • Lifetime Qt Champion

    What does the stack trace tells you about that ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.