How to construct the parameters required by FaceRecognizer in Java
I build a JNI to create LBPHFaceRecognizer, and I can get dll created as expected, but I met issue when call it during train,
Here are the code I construct the parameters for train and the exception I got,
List<Mat> images = new ArrayList<Mat>(imageFiles.length);
Mat labels = new Mat(imageFiles.length, 1, CvType.CV_32SC1);
int counter = 0;
for (File image : imageFiles) {
Mat img = Highgui.imread(image.getAbsolutePath());
int label = Integer.parseInt(image.getName().split("\\-")[0]);
images.add(counter,img);
labels.put(counter, 1, label);
counter++;
}
OpenCV Error: Bad argument (The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).) in train, file D:\Project\javacv\opencv\opencv\sources\modules\contrib\src\facerec.cpp, line 913
Exception in thread "main" java.lang.Exception: unknown exception
at org.opencv.contrib.FaceRecognizer.predict_0(Native Method)
at org.opencv.contrib.FaceRecognizer.predict(FaceRecognizer.java:173)
at OpenCV2411FaceRecognizer.main(OpenCV2411FaceRecognizer.java:149)
Can anyone help me on this?
And when I tried to load a trained result, I just get exception with no meaningful message, any tips on how to fix this? The exception is
Exception in thread "main" java.lang.Exception: unknown exception
at org.opencv.contrib.FaceRecognizer.load_0(Native Method)
at org.opencv.contrib.FaceRecognizer.load(FaceRecognizer.java:104)
at OpenCV2411FaceRecognizer.main(OpenCV2411FaceRecognizer.java:131)
can you add the
train
line ? and the code for the prediction ?Here are the code
Any one has any tips or suggestions? And anyone know is there a plan to make default java interface contains FaceRecognizer in opencv 3.0?thanks.