Fixed small bug in opencv_traincascade application: overflow sometimes happened during calculation of the number of negative samples.

This commit is contained in:
Leonid Beynenson 2011-10-07 14:00:19 +00:00
parent 22bd127365
commit 484e56f31f

View File

@ -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;