# Revision history [back]

Hi Mark,

The error std::bad_alloc occurs when you fail to allocate required storage space.

1)you need to reduce the size of positive and negative images.Max preferable dimension is width=100 and height=100.It would be really good if you could resize them to be around w=20 and h=20.

2)Try to set numPos = 0.9 * number_of_positive_samples and 0.99 as a minHitRate

3)vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S, where S is a count of samples from vec-file.S is a count of samples from vec-file that can be recognized as background right away.

4)To just test lightly on a temporary basis keep number of stages less(around 5-10).

5)It usually takes a lot of time to train,so be patient.

6)try this:

add -nonsym -mem 512 to your opencv_haartraining command