Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Loading png image always result in an empty Matrix

I am trying to load a simple png image with opencv (3.2.0) with java, using the x64 library. But each time i get an empty matrix (all the pixels are 0). However, when i convert the image to jpg, it works just fine. I have tried to run imread method with every flag possible, I even did this (iterated over every possible flag f):

System.loadLibrary("opencv_java320");
for (int k = 0; k < 130; f++) {
    Mat img = Imgcodecs.imread(inFile, f);
    for (int i = 0; i < img.cols(); i++) {
        for (int j = 0; j < img.rows(); j++) {
            if (img.get(i, j) != null && img.get(i, j)[0] > 0) {
                System.out.println(f);
                System.exit(0);
            }
        }
    }
}

Here is the image I'm running imread against. enter image description here