I'm currently trying to convert Mat images to INDArray as follows :
//Load image file
Mat srcImage = Imgcodecs.imread(args[0]);
//Rescale
Mat cvImage = new Mat(64,64,srcImage.type());
Imgproc.resize(srcImage,cvImage,cvImage.size(),0,0,Imgproc.INTER_CUBIC);
NativeImageLoader loader = new NativeImageLoader(64,64,1);
INDArray image = loader.asMatrix(cvImage);
MultiLayerNetwork model = KerasModelImport.importKerasSequentialModelAndWeights(args[1], false);
model.predict(image);
However, the INDArray image return null when loading either srcImage or its scaled down cvImage. Both Mat return non-null value and displays correct images when saved.
NativeImageLoader doesn't support that Mat object, use the one given in the docs:
https://deeplearning4j.org/datavecdoc/org/datavec/image/loader/NativeImageLoader.html#asMatrix-org.bytedeco.javacpp.opencv_core.Mat-
Changing the Mat package from org.opencv to org.bytedeco.javacpp.opencv_core ones resolves the problem as said. Thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.