1 | initial version |
opencv's FaceRecognizer classes return the distance from your img to the closest item in the database, not a confidence (it's the opposite), that's a misnomer in the code already.
the code you try to use/steal attempts to "normalize" the distance to [0..1] by dividing by some large value (300 here, but unfortunately, this heavily depends on your data !!!), then tries to invert it (1-x), and then scales to [0..100], to get something in %.
please note, that all of it is "heuristic", there's no silver bullet or exact formula for this (the distances are not even "linear") so play with it on your own data, but use "with a grain of salt" ;)
2 | No.2 Revision |
opencv's FaceRecognizer classes return the distance from your img to the closest item in the database, not a confidence (it's the opposite), that's a misnomer in the code already.
the code you try to use/steal you're trying with attempts to "normalize" the distance to [0..1] by dividing by some large value (300 here, but unfortunately, this heavily depends on your data !!!), then tries to invert it (1-x), and then scales to [0..100], to get something in %.
please note, that all of it is "heuristic", there's no silver bullet or exact formula for this (the distances are not even "linear") so play with it on your own data, but use "with a grain of salt" ;)
3 | No.3 Revision |
opencv's FaceRecognizer classes return the distance from your img to the closest item in the database, not a confidence (it's the opposite), that's a misnomer in the code already.
the code you're trying with attempts to "normalize" the distance to [0..1] by dividing by some large value (300 here, but unfortunately, this heavily depends on your data !!!), then tries to invert it (1-x), (1-x) to get a "confidence", and then scales to [0..100], to get something in %.
please note, that all of it is "heuristic", there's no silver bullet or exact formula for this (the distances are not even "linear") so play with it on your own data, but use "with a grain of salt" ;)