Unable to load image in Visual studio c++ [closed]
I have just set up open cv4.1.0 with visual studio 2019 on windows 10. My simple code for loading the image is as under
main()
{ Mat imag;
// LOAD image
imag = imread("D:\\image1.png",0); // Read the file "image1.png".
if(imag.empty() ) // Check for invalid inputf
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
//DISPLAY image
namedWindow("Window1", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Window1", imag); // Show our image inside it.
//SAVE image
imwrite("result1.jpg",imag);// it will store the image in name "result.jpg"
waitKey(5000); // Wait for a keystroke in the window
return 0;
}
that's pretty normal, you're a noob with no clue about relative pathes,, and your ide is playing tricks on you.
try to find the debug settings for your project, and adjust the startup path, so you program starts in the expected folder with the image.
@berak please help me sir, i have put the image in debug directory and also set the working directory as debug folder . but it fails, can you help me with teamviewer ?
no, never, sorry.