Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv_traincascade sometimes loops forever (in nextImg()) ?

Hello all. I have been using opencv_traincascade a lot. I know that it takes time to train, easilly several days or even a week. I (think) however that sometimes the training gets stuck and never ends.

I don't have the full picture of how the training really works in opencv_traincascade but after some analysis I have the feeling that the problem is in CvCascadeImageReader::NegReader::nextImg and/or in combination with CvCascadeClassifier::fillPassedSamples .

In CvCascadeImageReader::NegReader::nextImg it seems like there is no "protection" against that the variable "last" just loops around and around without ever finding whatever the code is looking for!!?? It will just pick the same images over and over again in this line: src = imread( imgFilenames[last++], 0 );

So the loop in CvCascadeClassifier::fillPassedSamples will call CvCascadeImageReader::NegReader::nextImg forever!!?? What will stop this loop if the predict(i) call in CvCascadeClassifier::fillPassedSamples never returns 1.0 ?

It would be nice if someone with a deep understanding of how the training works could explain the termination criteria in this case! :) Or maybe we have a bug here in the code!!??

Regards, Mats B

click to hide/show revision 2
retagged

updated 2014-03-07 02:41:04 -0600

berak gravatar image

opencv_traincascade sometimes loops forever (in nextImg()) ?

Hello all. I have been using opencv_traincascade a lot. I know that it takes time to train, easilly several days or even a week. I (think) however that sometimes the training gets stuck and never ends.

I don't have the full picture of how the training really works in opencv_traincascade but after some analysis I have the feeling that the problem is in CvCascadeImageReader::NegReader::nextImg and/or in combination with CvCascadeClassifier::fillPassedSamples .

In CvCascadeImageReader::NegReader::nextImg it seems like there is no "protection" against that the variable "last" just loops around and around without ever finding whatever the code is looking for!!?? It will just pick the same images over and over again in this line: src = imread( imgFilenames[last++], 0 );

So the loop in CvCascadeClassifier::fillPassedSamples will call CvCascadeImageReader::NegReader::nextImg forever!!?? What will stop this loop if the predict(i) call in CvCascadeClassifier::fillPassedSamples never returns 1.0 ?

It would be nice if someone with a deep understanding of how the training works could explain the termination criteria in this case! :) Or maybe we have a bug here in the code!!??

Regards, Mats B