Qt Opencv Integration



  • Hi
    I am using qt sdk 1.2(qt 4.8 , creator 2.4.1) and i want to use opencv
    so I downloaded opencv2.3.1 and unpacked it to c:
    I wrote a simple code like hello world :
    @
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    using namespace cv;

    int main(void)
    {
    IplImage *img=cvLoadImage("c:\IMG_0300.jpg");
    cvNamedWindow("window");
    cvShowImage("window",img);
    cvWaitKey();
    return 1;
    }
    @
    and for adding libs to my project my pro file is like this:
    @
    TEMPLATE = app
    CONFIG += console
    CONFIG -= qt

    SOURCES += main.cpp
    HEADERS += C:\Opencv\build\include\opencv2\core\core.hpp
    C:\Opencv\build\include\opencv2\highgui\highgui.hpp

    INCLUDEPATH+=C:\Opencv\build\include\

    win32: LIBS += -L$$PWD/../../../Opencv/build/x86/mingw/lib/ -llibopencv_core231
    -llibopencv_highgui231
    INCLUDEPATH += $$PWD/../../../Opencv/build/include/
    DEPENDPATH += $$PWD/../../../Opencv/build/x86/mingw/bin/
    @
    but every time i run the project I see a console window that ask me to press return to close this window.
    and application output says that exited with code 0
    whats the problem ?


  • Moderators

    You have no problem. This is showing only the error code on exit of your program. 0 is considered as no error.



  • but my program must show me a window and the picture on it what happens to them ?


  • Moderators

    Oh, sorry, I have misinterpret your issue then.



  • now do you know whats the problem ?
    I changed the pro file like this and same result nothing changed.
    @
    TEMPLATE = app
    CONFIG += console
    CONFIG -= qt

    SOURCES += main.cpp

    INCLUDEPATH += C:\opencv\build\include
    INCLUDEPATH += "C:\opencv\modules\core\include"
    "C:\opencv\modules\highgui\include"
    BASE_PATH = c:/opencv/build/x86/mingw
    CONFIG(release,debug|release)
    {
    win32: LIBS += -L$$BASE_PATH/lib/ -llibopencv_calib3d231
    -llibopencv_contrib231
    -llibopencv_core231
    -llibopencv_features2d231
    -llibopencv_flann231
    -llibopencv_gpu231
    -llibopencv_highgui231
    -llibopencv_imgproc231
    -llibopencv_legacy231
    -llibopencv_ml231
    -llibopencv_objdetect231
    -llibopencv_video231
    }
    CONFIG(debug,debug|release)
    {
    win32: LIBS += -L$$BASE_PATH/lib/ -llibopencv_calib3d231
    -llibopencv_contrib231
    -llibopencv_core231
    -llibopencv_features2d231
    -llibopencv_flann231
    -llibopencv_gpu231
    -llibopencv_highgui231
    -llibopencv_imgproc231
    -llibopencv_legacy231
    -llibopencv_ml231
    -llibopencv_objdetect231
    -llibopencv_video231
    }

    @



  • can you try to use ?

    @cvWaitKey(0);@

    edit: and maybe also without CONFIG += console



  • I tried these before nothing changed with these



  • one point may be help.
    when i try to debug program i get this error box :

    @
    During the startup program exited with code 0xc0000005
    @
    and then another eooro box :
    @
    the gdb process exited unexpectedly (code 0)
    @



  • one interesting thing :
    when i put build configuration to msvc10 the program runs corectly
    but when i put it on mingw build every thing is like what i said before.
    any sugestions ?



  • no idea?
    no one can help?



  • Do you have the Dll's in path?



  • I copied dll's to the directory of EXE file and system32



  • I did it.
    finally I've downloaded mingw32 and cmake and rebuild opencv from source with qt support and it worked like a charm.



  • i used the above include path files in qt but i am getting some errors like cannot open the library file calib3d231.



  • hello,

    I have met the same problem, have u solved it?

    I have tried again and again, but it didn't work

    However, I have successed once, when I did something and restarted qt creator, but since I rewrite the .pro, it crashed. Except this, all are the same with you.


Log in to reply
 

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