From 484e56f31fbb5efbea81245069dba2ae2e45c1c4 Mon Sep 17 00:00:00 2001 From: Leonid Beynenson Date: Fri, 7 Oct 2011 14:00:19 +0000 Subject: [PATCH] Fixed small bug in opencv_traincascade application: overflow sometimes happened during calculation of the number of negative samples. --- modules/traincascade/cascadeclassifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/traincascade/cascadeclassifier.cpp b/modules/traincascade/cascadeclassifier.cpp index d192dffcad..a005fbb449 100644 --- a/modules/traincascade/cascadeclassifier.cpp +++ b/modules/traincascade/cascadeclassifier.cpp @@ -268,7 +268,7 @@ bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio) return false; cout << "POS count : consumed " << posCount << " : " << (int)posConsumed << endl; - int proNumNeg = cvRound( (float)(numNeg * posCount) / numPos ); // apply only a fraction of negative samples. + int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible int negCount = fillPassedSamples( posCount, proNumNeg, false, negConsumed ); if ( !negCount ) return false;