问题
confidence = 1.0f - sqrt( distSq / (float)(nTrainFaces * nEigens) ) / 255.0f
- Why it is divided by (nTrainFaces*nEigens)?
回答1:
Why it is divided by (nTrainFaces*nEigens)?
Well, if you're just trying to find the confidence value for the 'test face eigenvectors (or values?)' with just 1 and only trained face, then you'd do something like
confidence = 1.0f - (sqrt( least_squared_distance / no_of_eigens ) / 255.0)
However, since you're finding nearest neighbour within trained face database, you want the confidence to reflect that your nearest neighbour gives a high confidence value for one of the faces in your trained database, amongst all the trained faces. Thus the confidence now is calculated not against 1 trained face, but with all trained faces, thus
confidence = 1.0f - (sqrt( least_squared_distance / no_of_trained_faces * no_of_eigens ) / 255.0)
"leastDistSq=DBL_MAX" what is DBL_MAX
least_squared_distance = DBL_MAX is basically a safe way from saying least_squared_distance = 99999999, since depending on the platform, hardware, or implementation, that might cause buffer overflow. So DBL_MAX is standard library that represents the largest double value.
And this is how it finds the least squared distance
if(distSq < leastDistSq) {
leastDistSq = distSq;
iNearest = iTrain;
}
来源:https://stackoverflow.com/questions/22791971/face-recognition-2d-array-confidence-formula-derivation