如何使用opencv python获得最佳特征脸

如何使用opencv python获得最佳特征脸,python,opencv,face-recognition,Python,Opencv,Face Recognition,我使用这个链接:获得图像和特征脸的平均脸 # Compute the eigenvectors from the stack of images created print("Calculating PCA ", end="...") mean, eigenVectors = cv2.PCACompute(data, mean=None, maxComponents=NUM_EIGEN_FACES) print ("DONE") averageFace = mean.reshap

我使用这个链接:获得图像和特征脸的平均脸

# Compute the eigenvectors from the stack of images created
  print("Calculating PCA ", end="...")
  mean, eigenVectors = cv2.PCACompute(data, mean=None, maxComponents=NUM_EIGEN_FACES)
  print ("DONE")
  averageFace = mean.reshape(sz)
  eigenFaces = [];
  for eigenVector in eigenVectors:
    eigenFace = eigenVector.reshape(sz)
    eigenFaces.append(eigenFace)
但我不知道怎么才能得到像这张照片一样的头像


源代码

特征面在特征向量中从上到下排序。(根据特征值,从最大到最小)。所以,只需找出前N个特征面。通常,为了显示,我们需要将平均面添加到特征面,并显示结果图像

真正的特征面是人脸图像空间中的ND轴,平均面是原点,特征值与沿特定轴设置的输入面(特征面)的色散成正比。首先(“在您的情况下是最佳的”)是方差最大的轴

因此,如果在面空间中思考,面是特征空间中的一个点,你可以像平常一样对任何面进行粘合

面(C1,C2,…,CN)=平均面+C1*本征面1+C2*本征面2+…CN*本征面n

你可以把任意面投影到特征空间,得到它的C1,C2,…,CN坐标

使用这些坐标可以找到面之间的“距离”,通常用于比较面