Ask Your Question

Revision history [back]

I think I already discovered why this is not running. Keep in mind that OpenCV pushes the feature descriptors of each training image into memory. Keeping in mind you have over 2000 training images (pos and neg - where negatives can actually contain multiple negatives) of which you want to store a 48x24 pixel descriptor in only 256 MB of memory will absolutely not work and just crash. Try adding the memory parameters to your train_cascade command.

This will be about the memory you will need. It is still possible you will need to reserve even more! Also I have changed some of the parameters you are assigning. Keep in mind that you have to need the exact same description, so with identation! Getting a hitrate of 0.9999 is quite impossible. That model will never train or require millions of data! Be happy with 0.95 as a start! I would also add the -featureType LBP parameter. It helps training time descrease drastically and works almost as good as HAAR wavelets. And as a last remark, hoping for 14 stages to differentiate a car model is hoping for to much. I would suggest increasing it at least to lets say 30 stages.

Final command:

opencv_traincascade -data data -vec cars.vec -bg bg.txt -numStages 30 -nsplits 2 -minHitrate 0.95 -maxFalseAlarmRate 0.5 -numPos 1400 -numNeg 692 -w 48 -h 24 -precalcValBufSize 2048 -precalcIdxBufSize 2048 -featureType LBP