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. Problem with OpenCV on Windows

Problem with OpenCV on Windows

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 6.1k Views
  • 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.
  • T Offline
    T Offline
    Trikrista
    wrote on last edited by
    #1

    Used OpenCV 2.4.6, Qt 5.2.1 and Windows 7

    In .pro connect OpenCV thus:
    @
    LIBS += -LC:/opencv/build/x86/mingw/lib/
    LIBS += -lopencv_highgui246
    -lopencv_imgproc246
    -lopencv_objdetect246
    -lopencv_video246
    -lopencv_core246
    @

    Trying to load a image as follows:

    @
    IplImage* image = cvLoadImage("1.jpg", 1);
    @

    As a result, the program quits unexpectedly.
    What could be the problem?

    I'm sorry for my bad English

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Suths
      wrote on last edited by
      #2

      This might be your problem: http://stackoverflow.com/questions/11953832/opencv-cvloadimage-can-not-load-jpg-image

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trikrista
        wrote on last edited by
        #3

        No, it's not the.
        My app crashes immediately after startup

        I'm sorry for my bad English

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Suths
          wrote on last edited by
          #4

          OpenCV if I recall rightly has debug and release libs (I think they are the lib followed by d). Your not compiling debug against release libs are you?

          1 Reply Last reply
          0
          • ZlatomirZ Offline
            ZlatomirZ Offline
            Zlatomir
            wrote on last edited by
            #5

            First make sure that you use libraries that are compatible with the compiler you use, it seems you use OpenCV built with MinGW, so do you have Qt built with MinGW too? Make sure that you do, and also make sure that you don't build a x64 application (that's because you link with 32 bit OpenCV build).

            Then try to debug your code and see the error code that is returned, it can be a simple error saying that at run-time OpenCV's (or Qt's) dll's can't be found so the application can't start (for example you can add the path to OpenCV dll files to the Path in environment variables or copy the dll into the same folder with your application)

            And if those are ok, debug your code, for stuff that might crash your application (example using uninitialized pointers), and if you still can't find the issue (and you provided the appropriate libraries both at compile-time and at run-time) you need to show more code, else we don't have any chance to help you.

            https://forum.qt.io/category/41/romanian

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Trikrista
              wrote on last edited by
              #6

              Checked, using compatible library

              Here is an example:
              @
              #include <opencv/cv.h>
              #include <opencv/highgui.h>

              int main() {
              IplImage* image = cvLoadImage("1.jpg", 1);

              cvNamedWindow("original",CV_WINDOW_AUTOSIZE);
              cvShowImage("original",image);
              
              cvWaitKey(0);
              
              cvReleaseImage(& image);
              cvDestroyWindow("original");
              return 0;
              

              }
              @

              When you debug this error occurs:
              @
              During startup program exited with code 0xc0000135
              @

              I'm sorry for my bad English

              1 Reply Last reply
              0
              • ZlatomirZ Offline
                ZlatomirZ Offline
                Zlatomir
                wrote on last edited by
                #7

                Just as i guessed, that means "dll not found", so make the OpenCV dll's available at run-time (either copy the ones you linked with in the same folder with your application, or add the path C:/opencv/build/x86/mingw/bin to the path in the environment variables) - also if you run from outside of Creator you will need at least two dll's from MinGW runtime: libgcc_s_dw2-1.dll and libstdc++-6.dll (those can be found into the bin folder inside MinGW instalation).

                LE: if you edit the path in environment variables be careful the paths in there are separated by ;

                https://forum.qt.io/category/41/romanian

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Trikrista
                  wrote on last edited by
                  #8

                  After rebuilding of the library problem was resolved

                  I'm sorry for my bad English

                  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