Ask Your Question
0

opencv_traincascade sometimes loops forever (in nextImg()) ?

asked 2014-03-06 05:14:28 -0600

matspetter gravatar image

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

berak gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-08-31 21:02:57 -0600

Netsai Chibuku gravatar image

You might be seeing bug #3370 in OpenCV: http://code.opencv.org/issues/3370 It should be fixed in the latest OpenCV.

The change that was made to fix the bug is here: https://github.com/Itseez/opencv/commit/e59912f803c73d62ce08c3b10885a43392a17626

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-06 05:14:28 -0600

Seen: 298 times

Last updated: Aug 31 '14