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.@INCLUDEPATH +=D:\OpenCV\opencv\build\include\opencv2
D:\OpenCV\opencv\build\include\opencv
D:\OpenCV\opencv\build\includeCONFIG(release,debug|release)
{
LIBS += D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231.lib
}CONFIG(debug,debug|release)
{
LIBS +=D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231d.lib
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231d.lib
}@Thank you for your attention.
-
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?
-
Here's my code which is used to load and show a image.
@#include <QtCore/QCoreApplication>
#include <opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char argv[])
{
QCoreApplication a(argc, argv);
const char imagename = "E:\library\Pictures\images\boldt.jpg";
//load image
Mat img = imread(imagename);
//if loading image failed
if(img.empty())
{
cout<<"Can't load image"<<imagename;
waitKey();
return -1;
}
//show image
imshow("image", img);
//wait
waitKey();return a.exec();
}
@
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. -
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).
-
I have qjpeg4.dll and qjpegd4.dll.And even if I change the format of the image such as .bmp,the situation is same.
-
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.
-
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.
-
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?
-
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. -
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.