我正在使用openCV 2.4.9 Java库,在实现某些FaceRecognizer时遇到一些问题。我知道在C ++中,类contrib.FaceRecognizer
是Abastract,但是我不知道Java库是否也会发生这种情况(实际上Java文档太稀缺了!)。无论如何,这是我给班级打电话的尝试:FaceRecognizer rec = new FaceRecognizer();
要么FaceRecognizer rec = null;
或FaceRecognizer rec;
最后,我试图以这种方式调用Train
和Predict
方法:
public static void main(String[] args) {
// TODO code application logic here
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
FaceRecognizer rec = null;
List<Mat> images;
images = new ArrayList<Mat>();
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/1.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/2.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/3.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/1.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/2.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/3.jpg"));
Mat labels = new Mat(1, 6, CvType.CV_8UC1, Scalar(0));
// How can I add some values different from 0 to this Mat?
rec.train(images, labels);
// Predicts the label
System.out.println(testando.predict(Highgui.imread("/home/adriano/Desktop/fotos/gabi/4.jpg"));
}
欢迎任何帮助(:
最佳答案
使人脸识别器可以使用
FaceRecognizer rec=createLBPHFaceRecognizer();
要么
FaceRecognizer rec=createEigenFaceRecognizer();
要么
FaceRecognizer rec=createFisherFaceRecognizer();