Ask Your Question
0

problem with imshow

asked 2013-12-13 00:10:12 -0600

Lokesh gravatar image

updated 2013-12-13 00:12:31 -0600

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..

edit retag flag offensive close merge delete

Comments

the usual: try "D:/ganesh.jpg" or "D:\\ganesh.jpg"

berak gravatar imageberak ( 2013-12-13 03:09:47 -0600 )edit

also, you got a problem with imread, not imshow. maybe you want to change the title ?

berak gravatar imageberak ( 2013-12-13 04:15:49 -0600 )edit

u can add your image to location of your program and only use "ganesh.jpg" and about this you should write d:\ganesh.jpg no d:/

amin.karimi gravatar imageamin.karimi ( 2013-12-13 15:03:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-12-13 08:59:20 -0600

Try to run VS as admin, or run the program outside of VS as admin (UAC has a bad habit to restrict the access to the root of the partition)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-13 00:10:12 -0600

Seen: 462 times

Last updated: Dec 13 '13