imread return a Mat object with no methods
I'm trying to change some code from openCV to openCV2 in windows using a Cmake/Mingw compiled openCV248 (on Eclipse). My normal openCV code works fine using cvLoadImage and cvShowImage. But when I try to use imread and imshow I get a Mat from the imread that has no methods and an error from eclipse that tells me that imshow has invalid arguments...
Here is an example code:
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image = imread("pic.jpg",0);
namedWindow( "window", CV_WINDOW_AUTOSIZE );
imshow("window", image);
waitKey(10);
resizeWindow("window", 400, 400);
waitKey(0);
return 0;
}
Any help ?
you mean, that imread returns an empty Mat , and that imshow chokes on that ?
it's most likely a 'wrong path' problem. try an absolute one, like '/home/me/pic.jpg'
I think #include <opencv/cv.h> is missing
but @berak, he says that it works with cvLoadImage so I'm guessing thats not it.
@Median, if he is swapping to c++ interface, you do not have to specify the cv.h header anymore. I never use it in my programs... I also suggest using imread with only the path for a starter, making it use all default parameters. Also you do not need the waitKey(10) before the resize of the window if you add a waitKey(400) later on.
Btw, are you placing the correct header location in additional lib options of your C++ compiler?
keghn, please ask your own question ...
Removed it ... what a complete useless remark ...