March 30, 2012

pumper pumper
Lab Rat
22 posts

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 :

  1. #include <opencv2/core/core.hpp>
  2. #include <opencv2/highgui/highgui.hpp>
  3. using namespace cv;
  4.  
  5. int main(void)
  6. {
  7.     IplImage *img=cvLoadImage("c:\\IMG_0300.jpg");
  8.     cvNamedWindow("window");
  9.     cvShowImage("window",img);
  10.     cvWaitKey();
  11.     return 1;
  12. }

and for adding libs to my project my pro file is like this:
  1. TEMPLATE = app
  2. CONFIG += console
  3. CONFIG -= qt
  4.  
  5. SOURCES += main.cpp
  6. HEADERS += C:\Opencv\build\include\opencv2\core\core.hpp \
  7.            C:\Opencv\build\include\opencv2\highgui\highgui.hpp
  8.  
  9. INCLUDEPATH+=C:\Opencv\build\include\
  10.  
  11. win32: LIBS += -L$$PWD/../../../Opencv/build/x86/mingw/lib/ -llibopencv_core231 \
  12.                                                             -llibopencv_highgui231
  13. INCLUDEPATH += $$PWD/../../../Opencv/build/include/
  14. 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 ?

14 replies

March 30, 2012

koahnig koahnig
Mad Scientist
2099 posts

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

March 30, 2012

pumper pumper
Lab Rat
22 posts

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

March 30, 2012

koahnig koahnig
Mad Scientist
2099 posts

Oh, sorry, I have misinterpret your issue then.

March 30, 2012

pumper pumper
Lab Rat
22 posts

now do you know whats the problem ?
I changed the pro file like this and same result nothing changed.

  1. TEMPLATE = app
  2. CONFIG += console
  3. CONFIG -= qt
  4.  
  5. SOURCES += main.cpp
  6.  
  7. INCLUDEPATH += C:\opencv\build\include \
  8. INCLUDEPATH += "C:\opencv\modules\core\include" \
  9.                 "C:\opencv\modules\highgui\include"
  10. BASE_PATH = c:/opencv/build/x86/mingw
  11. CONFIG(release,debug|release)
  12. {
  13. win32: LIBS += -L$$BASE_PATH/lib/ -llibopencv_calib3d231 \
  14.                                   -llibopencv_contrib231 \
  15.                                   -llibopencv_core231 \
  16.                                   -llibopencv_features2d231 \
  17.                                   -llibopencv_flann231 \
  18.                                   -llibopencv_gpu231 \
  19.                                   -llibopencv_highgui231\
  20.                                   -llibopencv_imgproc231 \
  21.                                   -llibopencv_legacy231 \
  22.                                   -llibopencv_ml231 \
  23.                                   -llibopencv_objdetect231 \
  24.                                   -llibopencv_video231
  25. }
  26. CONFIG(debug,debug|release)
  27. {
  28. win32: LIBS += -L$$BASE_PATH/lib/ -llibopencv_calib3d231 \
  29.                                   -llibopencv_contrib231 \
  30.                                   -llibopencv_core231 \
  31.                                   -llibopencv_features2d231 \
  32.                                   -llibopencv_flann231 \
  33.                                   -llibopencv_gpu231 \
  34.                                   -llibopencv_highgui231\
  35.                                   -llibopencv_imgproc231 \
  36.                                   -llibopencv_legacy231 \
  37.                                   -llibopencv_ml231 \
  38.                                   -llibopencv_objdetect231 \
  39.                                   -llibopencv_video231
  40. }

March 30, 2012

marcoB marcoB
Ant Farmer
167 posts

can you try to use ?

  1. cvWaitKey(0);

edit: and maybe also without CONFIG += console

March 30, 2012

pumper pumper
Lab Rat
22 posts

I tried these before nothing changed with these

March 30, 2012

pumper pumper
Lab Rat
22 posts

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

  1. During the startup program exited with code 0xc0000005

and then another eooro box :
  1. the gdb process exited unexpectedly (code 0)

March 31, 2012

pumper pumper
Lab Rat
22 posts

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 ?

March 31, 2012

pumper pumper
Lab Rat
22 posts

no idea?
no one can help?

March 31, 2012

Scylla Scylla
Lab Rat
238 posts

Do you have the Dll’s in path?

April 1, 2012

pumper pumper
Lab Rat
22 posts

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

April 2, 2012

pumper pumper
Lab Rat
22 posts

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

June 11, 2012

gautham gautham
Lab Rat
1 posts

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

February 21, 2013

moondark moondark
Lab Rat
1 posts

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.

 
  ‹‹ Splint or PCLint Configuration for use with QT?      qt + powervr ››

You must log in to post a reply. Not a member yet? Register here!