1

This is my first attempt to use the cascade training mechanism of opencv. I am trying this based on a small image set of one positive and 3 negative images. I followed the instructions of the official opencv documentation.

The negative images are referenced to by a description file bg.txt:

Negative/t1.jpg
Negative/t2.jpg
Negative/t3.jpg

The negative images have different sizes (all in a "1920 x something" pixel range).

The positive image was used to generate a vector file with

opencv_createsamples.exe -img Positive/p1.jpg -num 5000 -w 100 -h 60 -show -vec vecFile.vec

Everything so far works without an error. I'd guess it's normal that the vector file vecFile.vec is not readable since it stores the 5000 images.

When I now want to apply cascade training by using

opencv_traincascade.exe -data TrainData/ -vec vecFile.vec -bg bg.txt -w 100 -h 60 -npos 10 -nneg 10

The program crashes without any output ("the program has stopped working"). Any idea why this is happening? Did I forget some important parameters?

I'm using Windows 10 and opencv 3.

Mthenn
  • 189
  • 1
  • 14

1 Answers1

0

When I tried to train a cascade last year, I had this same problem. What I found is that it's very memory hungry, so if you used 5000 images sampled at the sizes you wrote (-w 100 -h 60), your PC probably went out of memory (or other thing such as a heap size limit perhaps). Seems to me that trainscascade puts all of the sample data in RAM to train.

You'll probably have to try much smaller sizes such as the example of the documentation you mentioned, -w 24 -h 24, and increase in small amounts until you got a good size but no crashes.

  • This really seems to have fixed it, thanks a lot. The funny thing is that , before it simply crashed, I had an out of memory exception (which was written in the console output) and reduced it already. So I didn't expect that this problem is still a thing, since the console output was not there. 24 x 24 just sounds very small :-) – Mthenn Mar 03 '16 at 14:07