Can anyone help me with my problem? I can't seem to get any answer from the internet. I've been searching for like the whole day. So here's my problem. I am creating a face recognition android application using opencv4android 2.4.10 and Android Studio as my IDE.
I need to use FaceRecognition.predict(Mat src, int[] labels, double[] confidence) to get which person is being detected. But most tutorials I've research only have FaceRecognition.predict(Mat src) I'm not sure where to get int[] labels and double[] confidence. I would appreciate if anyone could teach me how to do this.
Sample code:
File[] imageFiles = root.listFiles(imgFilter);
Mat labels = new Mat(imageFiles.length, 1, CvType.CV_32SC1);
List<Mat> images = (List<Mat>) new Mat(imageFiles.length);
int counter = 0;
int label;
//get all person id and images
for (File image : imageFiles) {
Mat img = Highgui.imread(image.getAbsolutePath(), 0);
images.add(counter, img);
label = Integer.parseInt(image.getName().split("-")[0]);
labels.put(counter, 0, label);
counter++;
}
//I created a java wrapper for this method
//this works just fine.
FaceRecognizer facerec = new FisherFacesRecognizer();
facerec.train(images, labels);
//my problem is here, the parameters are supposed to be
//*Mat src, int[] labels, double[] confidence*
//but most tutorials only have *Mat src*
int predictedLabel = facerec.predict(grayImg);