Hello Samuel and All,
I am facing similar issue in Train function of Face Recognizer using JavaCV (javacv-platform-1.3.3) in Android 2.3.3 and API level 26.
Problems:-
1. On Train Function,its throwing exception as :-
java.lang.RuntimeException: /home/saudet/projects/bytedeco/javacpp-presets/opencv/cppbuild/android-x86/opencv-3.2.0/modules/core/src/matrix.cpp:1050: error:
(-211) Bad new number of rows in function cv::Mat cv::Mat::reshape(int, int) const
2. I tried loading the images of type .jpg and .png as well. Size of images is around 37- 40KB each.
3. I am not able to use any API functions of JavaCV correctly even if i followed all the steps on
https://github.com/bytedeco/javacv. Is there anything else i am missing or Android has some image loading restrictions?
4. What is the best storage for storing trained images in Android?
Following is the my Train function:-
private void TrainFaceDataBase() {
opencv_core.MatVector matImageDatabase = new opencv_core.MatVector(4);
opencv_core.Mat labels = new opencv_core.Mat(4, 1, CV_32SC1);
IntBuffer labelsBuf = labels.createBuffer();
File file1 = new File("D:\\Demo\\FaceAuthentication\\app\\src\\main\\res\\drawable\\image1.jpg");
matImageDatabase.put(0,imread(file1.getAbsolutePath(),CV_LOAD_IMAGE_GRAYSCALE));
labelsBuf.put(0, 0);
File file2 = new File("D:\\Demo\\FaceAuthentication\\app\\src\\main\\res\\drawable\\image2.jpg");
matImageDatabase.put(1,imread(file2.getAbsolutePath(),CV_LOAD_IMAGE_GRAYSCALE));
labelsBuf.put(1, 1);
File file3 = new File("D:\\Demo\\FaceAuthentication\\app\\src\\main\\res\\drawable\\image3.jpg");
matImageDatabase.put(2,imread(file3.getAbsolutePath(),CV_LOAD_IMAGE_GRAYSCALE));
labelsBuf.put(2, 2);
File file4 = new File("D:\\Demo\\FaceAuthentication\\app\\src\\main\\res\\drawable\\image4.jpg");
matImageDatabase.put(3,imread(file4.getAbsolutePath(),CV_LOAD_IMAGE_GRAYSCALE));
labelsBuf.put(3, 3);
opencv_face.FaceRecognizer FaceRecognizer = null;
FaceRecognizer = createFisherFaceRecognizer();
FaceRecognizer.train(matImageDatabase,labels);
predictLabel();
}
Please please help. Thanks in Advance.