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;
}