May 11, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

Qt Creator’s MSVC2010 debug compiler didn’t work with OpenCV in Windows system

 

But MSVC2010 release compiler works well with OpenCV.I don’t know why.
Here’s part of my .pro file.

  1. INCLUDEPATH +=D:\OpenCV\opencv\build\include\opencv2 \
  2. D:\OpenCV\opencv\build\include\opencv \
  3. D:\OpenCV\opencv\build\include
  4.  
  5. CONFIG(release,debug|release)
  6. {
  7.     LIBS += D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231.lib \
  8. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231.lib \
  9. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231.lib \
  10. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231.lib \
  11. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231.lib \
  12. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231.lib \
  13. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231.lib \
  14. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231.lib \
  15. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231.lib \
  16. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231.lib \
  17. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231.lib \
  18. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231.lib \
  19. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231.lib
  20. }
  21.  
  22. CONFIG(debug,debug|release)
  23. {
  24.     LIBS +=D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231d.lib \
  25. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231d.lib \
  26. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231d.lib \
  27. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231d.lib \
  28. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231d.lib \
  29. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231d.lib \
  30. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231d.lib \
  31. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231d.lib \
  32. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231d.lib \
  33. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231d.lib \
  34. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231d.lib \
  35. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231d.lib \
  36. D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231d.lib
  37. }

Thank you for your attention.

10 replies

May 11, 2012

Tobias Hunger Tobias Hunger
Mad Scientist
3130 posts

What does not work? Building your code (compiling/linking) or debugging it afterwards? Are there error messages or popups or something? What are you actually trying to do?

May 12, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

Here’s my code which is used to load and show a image.

  1. #include <QtCore/QCoreApplication>
  2. #include <opencv.hpp>
  3. using namespace std;
  4. using namespace cv;
  5. int main(int argc, char *argv[])
  6. {
  7.     QCoreApplication a(argc, argv);
  8.     const char* imagename = "E:\\library\\Pictures\\images\\boldt.jpg";
  9.         //load image
  10.         Mat img = imread(imagename);
  11.         //if loading image failed
  12.         if(img.empty())
  13.         {
  14.             cout<<"Can't load image"<<imagename;
  15.             waitKey();
  16.             return -1;
  17.         }
  18.         //show image
  19.         imshow("image", img);
  20.         //wait
  21.         waitKey();
  22.  
  23.     return a.exec();
  24. }

When I built my code with MSVC2010 debug compiler,the console outputted “ Can’t load image E:\library\Pictures\images\boldt.jpg”.
But if I built code with MSVC2010 release compiler,the image would show correctly.

May 12, 2012

Tobias Hunger Tobias Hunger
Mad Scientist
3130 posts

Sounds like the jpeg plugin to Qt is missing from the debug version.

Check under $(PLACE_WHERE_QT_LIBS_ARE)/plugins/imageformats for *qjpegd.dll (not 100% sure about the name, I am on Linux). If it is missing that then your debug Qt installation is incomplete. Please build it again making sure jpeg support is enabled during “configure” or report a bug against the package (if you downloaded the binary from somewhere).

May 12, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

I have qjpeg4.dll and qjpegd4.dll.And even if I change the format of the image such as .bmp,the situation is same.

May 12, 2012

Tobias Hunger Tobias Hunger
Mad Scientist
3130 posts

Then please try to find out why the debug version does not pick up the plugins. There are tools to monitor which files a application tries to access, that might help here.

May 12, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

I used Process Monitor to have a look,and there is almost no difference between debugging compiling and release compiling.Then I re-installed Qt Creator,the debugging compiler still didn’t work with OpenCV.

May 12, 2012

Tobias Hunger Tobias Hunger
Mad Scientist
3130 posts

Sorry, I am not sure I understand your problem then.

Did you check whether running your application in debug build is finding the image plugins or did you compare file access during compilation? What do you mean with “debugging compiler”? What does Qt not being able to load images have to do with opencv?

May 12, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

That’s all right.
In Windows,Qt Creator has 4 compiling choices : MSVC2010 debugging compiler,MSVC2010 release compiler,MinGW4.4 debugging compiler and MinGW4.4 release compiler.
I didn’t find image plugin but I have compared file access more or less.
imread and imshow functions are from OpenCV.If loading image failed,it turned out that OpenCV didn’t work.

May 12, 2012

nimingzhe2008 nimingzhe2008
Ant Farmer
60 posts

In addition,when I used visual studio 2010’s debugging mode to compile the code which had used OpenCV,it worked well.So I think there’s nothing wrong with OpenCV.

August 9, 2012

nimcap nimcap
Lab Rat
1 posts

I am having almost the same problem, any updates on the issue? I started believing this is a bug in OpenCV that has something to do with Qt.

 
  ‹‹ What does "Tool chain" option in Helpers setting in Mac Qt Creator do?      [solved] PRO function calls ››

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