Ask Your Question

Lokesh's profile - activity

2013-12-13 00:10:12 -0600 asked a question problem with imshow

include "opencv2/core/core.hpp"

include "opencv2/highgui/highgui.hpp"

include "iostream"

include "stdio.h"

include "conio.h"

using namespace cv;

using namespace std;

int main( int argc, char** argv )

{

Mat image;

image = imread("D:\ganesh.jpg", CV_LOAD_IMAGE_COLOR); // Read the file

if(! image.data ) // Check for invalid input {

cout << "Could not open or find the image" << std::endl ;

getchar();

return -1;

}

namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.

imshow( "Display window", image ); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window

return 0; }

I'm using visual studio 2012 express and opencv 2.4.7.. i have tried my level best to make the above code work. i have no idea about where i'm going wrong.. image location is perfect, no problem with that.. but still it says "Could not open or find the image" every time.. please someone help me out..

2013-12-11 02:29:48 -0600 received badge  Editor (source)
2013-12-11 02:28:04 -0600 asked a question about imread
#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include "iostream.h"


using namespace cv;

using namespace std;

int main( int argc, const char** argv )

{

Mat img = imread("D:\MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED);

if (img.data == NULL)

{

cout << "Image cannot be loaded..!!" << endl;

system("pause");

return -1;

}

namedWindow("MyImage", CV_WINDOW_AUTOSIZE);

imshow("MyImage", img);

waitKey(0);

return 0;

}

when i use this code, i'm getting the error "Image cannot be loaded..!!" ..

but when i use 'IplImage* img = cvLoadImage( "D:\MyImage.jpg" );' its working..

I'm a beginner and i have no idea what is going wrong.. I'm using Opencv 2.4.7 and visual studio express 2012..

I'm supposed to use 'imread' according to my professor.. please someone help me out..

Thank you in advance..