Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The first thing to do (And this is true for absolutely any program, in any language, in any configuration) is to check your input before processing it. So, modify your code with this lines:

cv::Mat img = cv::imread(in_path);

if(img.empty())
{
    cout << "Error! Could not read the image from disk"
    return -1;
}

cv::imshow("image", img); // No exception should be thrown here now

And going back to your problem, most probably you have a different Release directory, and from that one, your image is not visible. so, if you have your image in MyProject/Debug/img.png, it will work in debug mode, but when your exe is in MyProject/Release/myprogram.exe, trying to load a relative path will fail