Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5 and Tesseract 3.04.01in Ubuntu
Forum Updated to NodeBB v4.3 + New Features

Qt5 and Tesseract 3.04.01in Ubuntu

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt tesseract
9 Posts 2 Posters 3.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bhavin03B Offline
    bhavin03B Offline
    bhavin03
    wrote on last edited by
    #1

    Hallo, I am integrating Tesseract OCR in Qt. While in the Debug mode (no optimization used ..!), everything works perfect. The OCR result ist quite good in debug mode. But when I just run without debugging, it just outputs totally wrong ( but everytime same result ) result. I dont know where to start. Because when I compile the same code (without Qt Framework code ) in linux GCC, it works great. Please give me any hint, where to start digging..

    Will be very thankful for any hint.. !!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      That's pretty strange. Are you sure you are linking against the correct libraries ? i.e. release version of Tesseract when build against release version of your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • bhavin03B Offline
        bhavin03B Offline
        bhavin03
        wrote on last edited by
        #3

        Actually I compiled tesseract myself from source. I have also tried to link against library downloaded via "apt-get install tesseract-ocr". But same result.. I am really stuck now.. Thinking of IPC between two binaries (Qt for frontend and Mingw compiled binary for backend...!), but it's not effective way though..!

        Regards...!!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you provide a minimal sample that shows that strange behavior ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • bhavin03B Offline
            bhavin03B Offline
            bhavin03
            wrote on last edited by
            #5

            Hallo,
            Here the result in Debug version : Link
            And here the result in Run Version : Link

            With Regards

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Silly question, is it only the visualization that's messed or is it the result returned by tesseract that is different ? e.g. does printing the string on the console show the same difference ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • bhavin03B Offline
                bhavin03B Offline
                bhavin03
                wrote on last edited by
                #7

                Hi,
                It has nothing to do with output.. I met some interesting scenario. When I create the Qt project in commandline without QAppliction framework

                int main(int argc, char *argv[])
                {
                //QApplication a(argc, argv);
                 CODE
                //return a.exec();.
                }
                

                it just works fine. As soon as I uncomment QApplication a(argc, argv); and return a.exec(); it just gives wrong result.. I dont know now, what effect has QApplication Framework on Tesseract Code..??

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  How are you initializing the tesseract API ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • bhavin03B Offline
                    bhavin03B Offline
                    bhavin03
                    wrote on last edited by
                    #9
                    #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();
                    }
                    
                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved