Include OpenCV in qtCreator



  • 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


  • Moderators

    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.



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

    [EDIT: fixed image link, Volker]


  • Moderators

    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?



  • 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);
    @



  • without previous command the program go normally


  • Moderators

    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.



  • 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!!


  • Moderators

    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.



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

    I can't find the MinGW version...



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



  • 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]


  • Moderators

    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?


  • Moderators

    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



  • [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



  • 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



  • 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?



  • 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!!


  • Moderators

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

    Please mark the subject line with [Solved] .


Log in to reply
 

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