The fact that the file exists does not mean that OpenCV was able to read its contents.
Instead, you should:
Mat m = Highgui.imread(file.getAbsolutePath());
if (img.data)
{
showToast("Height: " + m.height() + " Width: " + m.width());
}
else
{
// print error and abort execution
}
At the end of the documentation imread(), a big note is noted:
The function determines the type of image by the content, not the file extension.
Before proceeding, you must check the documents. Make sure you can write a simple OpenCV application that downloads and displays an image from disk before proceeding with more complex things.
source
share