我正在使用openCV 2.4.9 Java Library,我有几个问题需要实现一些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"));
}
欢迎任何帮助(:
答案 0 :(得分:1)
使用facerecognizer你可以使用
FaceRecognizer rec=createLBPHFaceRecognizer();
或
FaceRecognizer rec=createEigenFaceRecognizer();
或
FaceRecognizer rec=createFisherFaceRecognizer();
答案 1 :(得分:1)
自OpenCV v3.0起,创建FaceRecognizer
的方法是,例如:
faceRecognizer = LBPHFaceRecognizer.create();
您可以像创建另外两个识别器一样。