From b7f2b671a27098929f0622b211ec450f1b3a3f7e Mon Sep 17 00:00:00 2001 From: Ivy Lee Date: Thu, 30 Jan 2014 21:53:05 +0000 Subject: [PATCH] Fixed Bug #3514 Incorrect Chi-Square distance used in LBPH FaceRecognizer --- modules/contrib/src/facerec.cpp | 2 +- modules/imgproc/include/opencv2/imgproc.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index 669fd735a2..c6f154af2a 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -833,7 +833,7 @@ void LBPH::predict(InputArray _src, int &minClass, double &minDist) const { minDist = DBL_MAX; minClass = -1; for(size_t sampleIdx = 0; sampleIdx < _histograms.size(); sampleIdx++) { - double dist = compareHist(_histograms[sampleIdx], query, HISTCMP_CHISQR); + double dist = compareHist(_histograms[sampleIdx], query, HISTCMP_CHISQR_ALT); if((dist < minDist) && (dist < _threshold)) { minDist = dist; minClass = _labels.at((int) sampleIdx); diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 2b94e0de21..84de283c0b 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -203,7 +203,8 @@ enum { HISTCMP_CORREL = 0, HISTCMP_CHISQR = 1, HISTCMP_INTERSECT = 2, HISTCMP_BHATTACHARYYA = 3, - HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA + HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA, + HISTCMP_CHISQR_ALT = 4 }; //! the color conversion code