1 | initial version |
Go to your source code and find the cascadeclassifier.cpp file. Then update the following code.
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, int64& consumed )
{
...
for( ; ; )
{
...
featureEvaluator->setImage( img, isPositive ? 1 : 0, i );
if( predict( i ) == 1.0F )
{
getcount++;
printf("%s getcount: %d\r", isPositive ? "pos":"neg", getcount);
break;
}
}
}
return getcount;
}
This will already give you a possible indication if something goes wrong by displaying the consumation of the negative samples.
Also open the imagestorage.cpp file and adapt the following code. This will make sure that if negative dimensions do not match, that the specific file is skipped and the algorithm continues with the following file.
bool CvCascadeImageReader::NegReader::nextImg()
{
...
src = imread( imgFilenames[last++], 0 );
// -----------------------------------------------------------------------------
// FIX ADDED : if traincascade does not get the image width and heigth correctly
// or the original image width and height are smaller than window size
if(src.rows < winSize.height || src.cols < winSize.width)
continue;
if( src.empty() )
continue;
// -----------------------------------------------------------------------------
...
}
Hope this serves you well.