Hello, I'm trying to utilize OpenCV 2.4.9 in MS Visual Studio 2008. The problem I have is that I cannot pass images into a Mat object (either from my camera or from files). For instance the following code returns "No image found. Check path!":
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main( int argc, char** argv)
{
cv::Mat baboon = cv::imread("C:\\OpenCV249\\sources\\samples\\cpp\\baboon.jpg",0);
if (!baboon.data)
{
cout << "No image found! Check path." << endl;
cv::waitKey(10000);
return -1;
}
else
{
cv::namedWindow("Window",CV_WINDOW_AUTOSIZE);
cv::imshow("Window",baboon);
cv::waitKey();
return 0;
}
}
I am able to read images in using the older code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main( int argc, char** argv)
{
IplImage *img = cvLoadImage("C:\\OpenCV249\\sources\\samples\\cpp\\baboon.jpg"
,CV_LOAD_IMAGE_UNCHANGED);
while(1)
{
cvNamedWindow("Window",CV_WINDOW_AUTOSIZE);
cvShowImage("Window",img);
cvWaitKey(10);
}
}
Nevertheless, I would like to work with the newer classes. I have tried converting IplImage to Mat, but that also fails (i.e. nothing is passed). I get this error running both .jpg files and .png files. I have checked to ensure that this path leads me to the image. Also, I have tried running in both debug and release modes (and have made sure to change the linked .lib files as needed). Here is the entry for OpenCV in the PATH enviornmental variable: "C:\OpenCV249\build\x64\vc10\bin\;"
I'm wondering if the .dll's in the new version of OpenCV are not compatible with MS VS 2008? If so, is there any way around this? I would prefer to use the newer version.