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

pull/13383/head
Leonid Beynenson 14 years ago
parent 22bd127365
commit 484e56f31f
  1. 2
      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;

Loading…
Cancel
Save