Check if image is correct (corrupted) javaCV
I have a list of directories and subdirectories with images. I am using JavaCV to read all images and using cvShowImage to display those images. I am reading files using the listFilesForFolder function. My problem is that some of the images in these folders are invalid (corrupted). So I am getting Opencv exception errors:
OpenCV Error: Null pointer () in cvReleaseImage, file ..\..\..\..\opencv\modules\core\src\array.cpp, line 2983
Exception in thread "main" java.lang.RuntimeException: ..\..\..\..\opencv\modules\core\src\array.cpp:2983: error: (-27) in function cvReleaseImage
at org.bytedeco.javacpp.opencv_core.cvReleaseImage(Native Method)
How can I check my code if the image is indeed (corrupted) or not to continue with the for loop in which I was reading all my images? I use the following function to read images:
public IplImage openImage(String name) {
IplImage img = cvLoadImage(name);
cvShowImage("hello", img);
cvWaitKey();
cvReleaseImage(img);
return img;
}
When I run the program, I am having problems on the cvReleaseImage (img) line.
+3
source to share