简体   繁体   English

如何在Javacv中获得人脸相等范围

[英]how to get Face equality range in Javacv

I'm using Javacv 1.1. 我正在使用Javacv 1.1。 have used an image of John lennon to test a Face recognition, that contains a data base with 3 images of Cristiano Ronaldo and 3 of John Terry. 已使用约翰·列侬的图像测试人脸识别,该图像包含一个数据库,其中包含3张克里斯蒂亚诺·罗纳尔多和3张约翰·特里的图像。 Just to verify that my program not find john lennon in the data base I used a photo from his. 为了验证我的程序在数据库中找不到john lennon,我使用了他的照片。

But when program predicts who was the guy in the image, shows me that it been Cristiano Ronaldo as the most similar guy. 但是当程序预测图像中的人是谁时,向我展示了最相似的人是克里斯蒂亚诺·罗纳尔多。

I need the distance between the input image and most similar training image to check if is the enough similar to tell me who is, or if is not enough tell the guy in there is not known. 我需要输入图像和最相似的训练图像之间的距离,以检查是否足够相似以告诉我是谁,或者是否足够不告诉其中的那个人是未知的。

Another question: Any tip for improve a correctly match? 另一个问题:任何改善正确匹配的技巧?

This was my solution ( tested only for Android platform), assuming you use eigenfaces: 这是我的解决方案(仅针对Android平台进行了测试),假设您使用eigenfaces:

public boolean verifyPerson (Mat matResized) {
        CvArr eigenvectors = faceRecognizer.getMat("eigenvectors");
        CvArr averageFaceRow = faceRecognizer.getMat("mean");
        IplImage img1D =MatToIplImage(matResized.reshape(1,1),-1, -1);
        // Project the input image onto the eigenspace:
        CvMat projection = subspaceProject(eigenvectors, averageFaceRow, img1D);
        // Generate the reconstructed face back from the eigenspace:
        CvMat reconstructionRow = subspaceReconstruct(eigenvectors, averageFaceRow, projection);
        CvMat reconstructionMat = new CvMat();
        cvReshape(reconstructionRow, reconstructionMat, 1, matResized.height()); 
        Mat reconstructedFace = CvMatToMat(reconstructionMat);
        // Calculate the L2 relative error between the 2 images.
        double errorL2 = Core.norm(matResized, reconstructedFace, CV_L2);
        // Scale the value since L2 is summed across all pixels.
        double uncertainty = errorL2 / (double)(matResized.rows() * matResized.cols());
        boolean verified;
        if (uncertainty < MaxPersonUncertainty) {
            verified = true; 
            }else{
            verified = false; // Unknown person.
            }
        return verified;
    }

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

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