The code is this:
// 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
}
}
If L2 relative error is a Euclidean Distance, what is this "Predict" and "Confidence" in opencv FaceRecognizer class?
Regards,
Marcelo
It's for sure not a new formula, guess they just mean the Euclidean (=L2) norm. Btw. the most haven't read this book, so a link to the page you are referring to would be helpful.
Thanks for help.
I can't a link to download, only a github page: https://github.com/MasteringOpenCV/code/blob/master/Chapter8_FaceRecognition/recognition.cpp