3

我在我的代码中使用 eigenfaces (PCA) 进行人脸识别。我使用 OpenCV 网站上的教程作为参考。虽然这对于识别人脸非常有效(即它可以告诉你谁是正确的),但基于置信度分数的人脸验证(或冒名顶替者检测——验证人脸是否已加入训练集)根本无法正常工作。

我计算欧几里得距离并将其用作置信度阈值。还有其他方法可以计算置信度阈值吗?我尝试使用http://www.cognotics.com/opencv/servo_2007_series/part_5/page_5.html中提到的马氏距离,但它产生了非常奇怪的值。

PS:像 face.com 这样的解决方案可能对我不起作用,因为我需要在本地做所有事情。

4

2 回答 2

3

您可以使用函数将新的输入面投影到特征空间上subspaceProject(),然后使用从特征空间生成重建的面subspaceReconstruct(),然后比较input_facereconstructed_face的相似程度。已知人脸(训练数据集中的人脸)的重建图像与input_face的相似性高于冒名顶替者的人脸。您可以为验证设置相似度阈值。这是代码:

// Project the input face onto the eigenspace.
Mat projection = subspaceProject(eigenvectors, FaceRow,input_face.reshape(1,1));

//Generate the reconstructed face
Mat reconstructionRow = subspaceReconstruct(eigenvectors,FaceRow, projection);

// Reshape the row mat to an image mat
Mat reconstructionMat = reconstructionRow.reshape(1,faceHeight);

// Convert the floating-point pixels to regular 8-bit uchar.
Mat reconstructed_face = Mat(reconstructionMat.size(), CV_8U);

reconstructionMat.convertTo(reconstructed_face, CV_8U, 1, 0);

然后,您可以使用 比较输入人脸和重建人脸cv::norm()。例如:

// Calculate the L2 relative error between the 2 images. 
double err = norm(input_face,reconstructed_face, CV_L2);
// Convert to a reasonable scale
double similarity = error / (double)(input_face.rows * input_face.cols);
于 2013-05-18T14:45:49.430 回答
1

您可以查看除 PCA 之外的特征提取算法,例如 LDA(线性判别分析)或局部二进制模式 (LBP)。

LDA 对类间变化进行建模,LBP 是光照不变描述符。您在 OpenCV 中实现了这两种算法。检查以下链接。

http://docs.opencv.org/trunk/modules/contrib/doc/facerec/facerec_api.html

于 2013-01-22T12:49:03.797 回答