人脸识别分类器

Face Recognition Classifier

本文关键字:分类器 人脸识别      更新时间:2023-10-16

参考之前的post,用于分类的方法是最近邻欧氏距离。然而,所获得的结果并不准确,因为已知数据集和未知数据集都给出了99%的相似性。即使与Mahalanobis距离也给出了类似的结果。

人脸识别分类还有其他方法吗?你能给我提供一些例子/公式吗?

float d_i = projectedTestFace[i] - projectedTrainFaceMat->data.fl[iTrain*nEigens + i];
distSq += d_i*d_i; // Euclidean distance

imho,如果你得到了糟糕的结果,那就怪你的输入,而不是距离公式

在没有任何进一步预处理(对齐、裁剪、均衡)的情况下,即使像素上的普通L2范数也比本征面给出更好的结果。(这里是可悲的事实)

自2.4.2年起,opencv推出了开箱即用的人脸识别功能。(还具有可选的fisher和lbph功能)

你可能应该使用它,而不是自己滚动(请使用c++api,而不是神秘的c)。

如果你真的想坚持使用本征面,你仍然可以尝试"重建"(从本征向量)图像和测试图像之间的L2距离作为置信度测量,就像这里所做的那样(再次由shervin)

// Compare two images by getting the L2 error (square-root of sum of squared error).
double getSimilarity(const Mat A, const Mat B)
{
if (A.rows > 0 && A.rows == B.rows && A.cols > 0 && A.cols == B.cols) {
    // Calculate the L2 relative error between the 2 images.
    double errorL2 = norm(A, B, CV_L2);
    // Convert to a reasonable scale, since L2 error is summed across all pixels of the image.
    double similarity = errorL2 / (double)(A.rows * A.cols);
    return similarity;
}
else {
    //cout << "WARNING: Images have a different size in 'getSimilarity()'." << endl;
    return 100000000.0;  // Return a bad value
}
}

我想知道为什么我总是得到100000000的回报。这是否意味着经过预处理和重建的人脸大小不同?这就是它跳过L2距离比较的原因?

以下是我编码的一部分:

Mat j =projectedTestFace[i];
Mat k =projectedTrainFaceMat>data.fl[iTrain*nEigens + i];
similarity=getSimilarity(j,k);

在没有else语句的情况下,我得到了similation=-nan结果,想知道-nan和-inf代表什么。