Ask Your Question
2

opencv_traincascade crash without explanation

asked 2014-01-30 05:09:26 -0600

taktak004 gravatar image

updated 2014-01-30 06:55:13 -0600

same question on stackoverflow

I try to use opencv_traincascade.exe but it crashes few seconds after I launch it. Here is how I proceeded:

I first create the positive sample using:

opencv_createsamples -info info.txt -vec vecFile.vec -bg neg.txt -num 100 -w 100 -h 100
  • info.txt has 116 lines which are all like:

    imagepath 1 0 0 100 100

    just the name of the file change in the different lines but all the images are of size 100*100 (I am working on high resolution picture on stem cells, therefore in a 25x25 image, I think I would not have enough information to detect what I am looking for)

  • neg.txt contains 715 lines with just file paths

which successfully created 100 samples

and then I launch the training with:

opencv_traincascade -data Cascade -vec vecFile.vec -bg neg.txt -numPos 10 -numNeg 20 -numStages 2 -featureType HAAR -w 100 -h 100

And then I got the following error message:

opencv_traincascade.exe has stopped working

And nothing else.

Any idea what is going on ?

Thanks

edit retag flag offensive close merge delete

Comments

@taktak004 got ur training started without any issues??

ART gravatar imageART ( 2014-02-12 00:27:26 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2014-01-30 05:27:47 -0600

updated 2014-01-30 05:30:51 -0600

This is happening because of the window size you chose. The memory traincascade.exe uses for training a classifier grows exponentially with window size, and there are few home computers that would handle a 100x100 window size in traincascade..

Do this exercise: open your task manager and monitorize the memory usage growing when you start training, you'll notice that the program crashes when it can't allocate more memory. To fix this you'll really have to choose a smaller window size.

By the way, if your traincascade application is 32-bit, it wont even use more then 2GB RAM, no matter how much you have.

As I told you on stackoverflow :P

edit flag offensive delete link more

Comments

Actually he only uses 10 positives and 20 negatives, so it is weird that his memory would have problems with that. Agree, a lot of memory is used, but 30 samples should work, as I use up to 10.000 samples on a 4GB ram pc with a window of 45x45...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 05:45:52 -0600 )edit

Yes, I find that weid too.. maybe number of samples do not really matter (memory-wise) when you choose such a big window size?

Pedro Batista gravatar imagePedro Batista ( 2014-01-30 05:54:29 -0600 )edit

Hmm I am wondering if their is any other output before the error. On which stage does this happen? How many samples have been processed before? ... can you provide more info?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 05:56:17 -0600 )edit

He posted this same question on stackoverflow, he says that reducing window size solved his problem. Also, the training doesn't even start, it crashes a few seconds after starting to run. http://stackoverflow.com/questions/21454215/opencv-traincascade-crash-without-explanation/21454877#21454877

Pedro Batista gravatar imagePedro Batista ( 2014-01-30 05:58:34 -0600 )edit

Weird ... i am still not convinced this is the problem. A wrong size would start the training, then crash at a specific stage with a memory allocation error ...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 06:02:09 -0600 )edit

I've had this issue before, I'd choose a way to big window size and the training wouldn't even start. Actually, traincascade allocates all the memory it is going to need in the beggining of the execution as far as I can tell

Pedro Batista gravatar imagePedro Batista ( 2014-01-30 06:09:40 -0600 )edit

Hmm it might be possible that it allocates memory for storing all possible features contained in the process. If it does that, than it could actually be the case...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 06:47:53 -0600 )edit

So, as said by @Median, no previous output, and changing from 100 to 25 "solved" my problem. The training does occurs, but as expected, with bad prediction result. But isn't it possible to do the training without allowing everything in the same time ? Probably not with opencv, but theoretically it is possible ?

taktak004 gravatar imagetaktak004 ( 2014-01-30 07:00:19 -0600 )edit

Diving into the source code and optimizing the memory handling would basically do the trick. Everyone knows the problem, but none has tried to solve it.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 07:08:15 -0600 )edit

But @taktak004, you couldn't expect to get good results using only 10 positives and 20 negatives. Think thousands, not dozens!

Pedro Batista gravatar imagePedro Batista ( 2014-01-30 08:09:27 -0600 )edit
1

answered 2015-03-09 14:00:19 -0600

Miguel Lorenzo gravatar image

Hello i'd just like to comment something:

I had the same problem, using 60x20 window size, and my problem was that I had recently installed MinGW w64 on my system, and had deleted my old path to MinGW32/bin in my PATH env variable, to replace it with the 64 one. Since my openCV had been built using the old mingw, I suppose there were issues. As soon as I reinstated the old /bin directory in my system path, my problem was fixed.

edit flag offensive delete link more

Comments

Thank you @Miguel Lorenzo

Steven_ocv gravatar imageSteven_ocv ( 2015-09-08 15:47:19 -0600 )edit

Question Tools

Stats

Asked: 2014-01-30 05:09:26 -0600

Seen: 2,677 times

Last updated: Mar 09 '15