# Revision history [back]

I did some background checking of the current OpenCV2.4.6.1 source code. Your problem is exactly that he cannot read the negative files, so there is actually something wrong with your bg.txt file.

Looking at cascadeclassifier.cpp we see this code:

for( int i = startNumStages; i < numStages; i++ )
{
cout << endl << "===== TRAINING " << i << "-stage =====" << endl;
cout << "<BEGIN" << endl;

if ( !updateTrainingSet( tempLeafFARate ) )
{
cout << "Train dataset for temp stage can not be filled. "
"Branch training terminated." << endl;
break;
}
...


This says clearly that the problem must be at the updateTrainingSet function for the first iteration. If we dig deeper, we can see this code:

bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
{
int64 posConsumed = 0, negConsumed = 0;
int posCount = fillPassedSamples( 0, numPos, true, posConsumed );
if( !posCount )
return false;
cout << "POS count : consumed   " << posCount << " : " << (int)posConsumed << endl;

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;

curNumSamples = posCount + negCount;
acceptanceRatio = negConsumed == 0 ? 0 : ( (double)negCount/(double)(int64)negConsumed );
cout << "NEG count : acceptanceRatio    " << negCount << " : " << acceptanceRatio << endl;
return true;
}


If you look at that code and your output, you clearly see that the positive samples are fetched and this works. The only other way of returning a false in this function, is if negCount has no value, meaning that the fillPassedSamples function doesn't work on your data :)