繁体   English   中英

在Android应用程序中使用OpenCV人脸识别算法

[英]Using OpenCV Face recognition algorithms in Android application

我正在尝试在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]);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM