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. Include OpenCV in qtCreator
Qt 6.11 is out! See what's new in the release blog

Include OpenCV in qtCreator

Scheduled Pinned Locked Moved General and Desktop
19 Posts 2 Posters 29.5k Views 1 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.
  • D Offline
    D Offline
    dott.infernus
    wrote on last edited by
    #1

    Hello guys,
    I'm making an accademic project with qt creator and I must use the OpenCV libraries for image processing.
    The qtcreator version is the 4.7.4 and the Opencv version is 2.3.1
    Pratically in the .pro I've included this code line:

    @INCLUDEPATH += C:\opencv\include

    CONFIG(release,debug|release){
    LIBS += C:\opencv\build\gpu\x86\lib\opencv_calib3d231.lib
    C:\opencv\build\gpu\x86\lib\opencv_contrib231.lib
    C:\opencv\build\gpu\x86\lib\opencv_core231.lib
    C:\opencv\build\gpu\x86\lib\opencv_features2d231.lib
    C:\opencv\build\gpu\x86\lib\opencv_flann231.lib
    C:\opencv\build\gpu\x86\lib\opencv_gpu231.lib
    C:\opencv\build\gpu\x86\lib\opencv_highgui231.lib
    C:\opencv\build\gpu\x86\lib\opencv_imgproc231.lib
    C:\opencv\build\gpu\x86\lib\opencv_legacy231.lib
    C:\opencv\build\gpu\x86\lib\opencv_ml231.lib
    C:\opencv\build\gpu\x86\lib\opencv_objdetect231.lib
    C:\opencv\build\gpu\x86\lib\opencv_ts231.lib
    C:\opencv\build\gpu\x86\lib\opencv_video231.lib
    }

    CONFIG(debug,debug|release){
    LIBS += C:\opencv\build\gpu\x86\lib\opencv_calib3d231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_contrib231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_core231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_features2d231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_flann231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_gpu231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_highgui231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_imgproc231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_legacy231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_ml231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_objdetect231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_ts231d.lib
    C:\opencv\build\gpu\x86\lib\opencv_video231d.lib
    }
    @
    and in a function when i call
    @ IplImage* img = 0;
    int h, w, step, channels, i, j, k;
    uchar *data;

    img = cvLoadImage("C:\\imm.PNG", 0);@
    

    this launch an exception.

    Someone can help me to fix this...or know to use OpenCv on Qtcreator

    thank you in advance

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to this forum.

      You should provide the error message with details. Otherwise it will be hard to get an idea what the problem might be.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dott.infernus
        wrote on last edited by
        #3

        Sorry...in the link below you can see the print screen: !http://img651.imageshack.us/img651/7008/errorke.jpg!

        [EDIT: fixed image link, Volker]

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Apparently you are using precompiled versions of the libs. Did you make sure that the libs are compiled with the same compiler as you compile your source?
          Note, that for msvc compilers you should not mix different versions such as 2005 and 2008, etc.

          In case you are sure that the compiler versions are identical, can you use the debugger to see where the problem occurs within the lib?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dott.infernus
            wrote on last edited by
            #5

            Libs compiled with the same compiler?? I don't know, beacause I downloaded the pack, unpacked it into C:\ and then I use it. mhhh for the problem I checked the code and the exception is launched when I insert the code line:
            @img = cvLoadImage("C:\imm.PNG", 0);
            @

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dott.infernus
              wrote on last edited by
              #6

              without previous command the program go normally

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                You should check what tool chain you are using qt creator.
                MinGW
                Any of the Microsoft Visual Studio? Which one?
                OpenCV seem to be available pre-compiled by different compilers. Alternatively, you can compile OpenCV with the tool chain you are using in qt creator.

                Only when the compiler used by creator and of the compilation of the libs are identical you will have a chance.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dott.infernus
                  wrote on last edited by
                  #8

                  oh...Now I understand!
                  Mhh...the compiler of Qt creator is MinGw, so, how can I compile the opencv libraries with MinGW? Exists any tutorial/guide?

                  Thank you in advance!!

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    koahnig
                    wrote on last edited by
                    #9

                    You may find apparently the source "here":http://opencv.willowgarage.com/wiki/
                    There is also a guide to be found. Where did you get OpenCV from? Maybe you get there also a Mingw version.

                    Vote the answer(s) that helped you to solve your issue(s)

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dott.infernus
                      wrote on last edited by
                      #10

                      I've downloaded this version: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/

                      I can't find the MinGW version...

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        dott.infernus
                        wrote on last edited by
                        #11

                        I found this guide, it is good for compile the opencv with MinGW?
                        http://opencv.willowgarage.com/wiki/MinGW

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          dott.infernus
                          wrote on last edited by
                          #12

                          when I follow the above guide, the program cmake return me an error:

                          !http://img823.imageshack.us/img823/6568/error2pl.jpg!

                          I don't know what anything do!

                          [EDIT: fixed image link, Volker]

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            koahnig
                            wrote on last edited by
                            #13

                            Well, did you read the messages?
                            It clearly sais that there is a problem with your cmake setup. It cannot find the mingw compiler. That is your entry ticket.
                            I do not know anything about CMake. So, are at your place some colleaques to help you?

                            Vote the answer(s) that helped you to solve your issue(s)

                            1 Reply Last reply
                            0
                            • K Offline
                              K Offline
                              koahnig
                              wrote on last edited by
                              #14

                              I have downloaded this windows superpack file. There is already quite a lot included. There are also some mingw libs readily available. You have used "gpu" libs which are under ...\opencv\build\gpu . However, there are mingw libs ...\opencv\build\x86\mingw and ...\opencv\build\x64\mingw .
                              Probably the ones ...\opencv\build\x86\mingw are more suitable assuming that you are using mingw 32bit.

                              However, check out the documentation supplied in this superpack.

                              There are also other posts here with an "opencv tag ":http://developer.qt.nokia.com/search/tag/opencv

                              Vote the answer(s) that helped you to solve your issue(s)

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                dott.infernus
                                wrote on last edited by
                                #15

                                [quote author="koahnig" date="1318413525"]Well, did you read the messages?
                                It clearly sais that there is a problem with your cmake setup. It cannot find the mingw compiler. That is your entry ticket.
                                I do not know anything about CMake. So, are at your place some colleaques to help you? [/quote]

                                No I'm alone

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  dott.infernus
                                  wrote on last edited by
                                  #16

                                  I tried to use this libs:
                                  @INCLUDEPATH += C:\opencv\include

                                  LIBS += C:\opencv\build\x86\mingw\lib\libopencv_calib3d231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_contrib231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_core231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_features2d231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_flann231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_gpu231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_highgui231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_imgproc231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_legacy231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_ml231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_objdetect231.dll.a
                                  C:\opencv\build\x86\mingw\lib\libopencv_video231.dll.a
                                  @

                                  and the qtcreator returns the same error

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    dott.infernus
                                    wrote on last edited by
                                    #17

                                    I made another proof, I followed this guide: http://opencv.willowgarage.com/wiki/MinGW step by step. Before step 20 everything was ok, so at the 21st the guide tell how to configure Code::Block, but I don't want to configure it, I want configure QtCreator, someone say how I can do?

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      dott.infernus
                                      wrote on last edited by
                                      #18

                                      Problem Solved!! After following the guide, the problem persisted! Luckily I watched an example where the programmer use imread to load an image and not cvLoadImage. Now OpenCv completely working on my QTCreator....Thanks for everyhing!!

                                      1 Reply Last reply
                                      0
                                      • K Offline
                                        K Offline
                                        koahnig
                                        wrote on last edited by
                                        #19

                                        It is good to know that you could finally solve the problem.

                                        Please mark the subject line with [Solved] .

                                        Vote the answer(s) that helped you to solve your issue(s)

                                        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