我正在尝试在android应用程序中实现人脸识别,经过一番研究,我安装了opencv android库并将其导入到android应用程序中。
我还了解到,用于人脸识别的3种最常用的算法(至少是教程中最常用的算法)是LBPH,FischerFaces和Eigenfaces,但是我无法在SDK中找到它们的实现,我错过了什么吗?
我是否需要通过JNI导入C ++代码?还是我可以在Android应用程序中使用一些Java实现?
我做了一个快速(虚拟)尝试,它应该类似于以下内容:
facerec = new createFisherFaceRecognizer();
// traindata
List<Mat> traindata = new ArrayList<Mat>();
traindata.add(image1); // add grayscale images, all cropped to the same size (like(90x90)
traindata.add(image2); // ...
// trainlabels, i guess, MatOfInt(1,2,3) would work, too
Mat labels = new Mat(1,traindata.size(), CvType.CV_32S);
int [] l = {1,2,3, ... }; // 1 label for each image
labels.put(0, 0, l);
facerec.train( traindata, labels );
// now to prediction:
int [] label = new int[1];
double [] conf = new double[1];
// test_im must be grayscale, cropped to same size as the trainimages
facerec.predict(test_im, label, conf);
System.out.println("rec " + label[0] + " " + conf[0]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句