I have trained faceRecognizer in Java. But when i predict a label it returns a huge value which is not the actual label which i stored during training. Please have a look at my training code and tell me how this error can be resolved.
String trainingDir = "res/"; File root = new File(trainingDir); FilenameFilter imgFilter = new FilenameFilter() { public boolean accept(File dir, String name) { name = name.toLowerCase(); return name.endsWith(".jpg") || name.endsWith(".pgm") || name.endsWith(".png"); } }; File[] imageFiles = root.listFiles(imgFilter); ArrayList <mat> images = new ArrayList(imageFiles.length); Mat labels = new Mat(imageFiles.length,1,CvType.CV_32SC1); ArrayList <integer>labelsBuf = new ArrayList<>(imageFiles.length); int counter =0; for(File image: imageFiles){ Mat img = Imgcodecs.imread(image.getAbsolutePath(),Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE); int label = Integer.parseInt(image.getName().split("\\.")[2]); //images.add(label, img); images.add(img); labelsBuf.add(counter, label); counter++; } FaceRecognizer faceRecognizer = Face.createFisherFaceRecognizer(); faceRecognizer.train(images, labels);
Thanks in advance