あなたはsubspaceProject()
機能を使用して固有空間への新しい入力面を投影し、その後subspaceReconstruct()
を使用してバック固有空間からの再構成顔を生成し、input_faceとreconstructed_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);