I am trying to train a haar-like classifier for pedestrians in OpenCV using 3340 positive images and 1224 negative images. (in a .txt file I keep the negative image names i.e negatives(1).bmp, and in a txt file I keep the positives i.e. picture(1).bmp 1 0 0 64 128. Actually positive examples are already cropped images of pedestrians so I only need specify one positive sample per image).
At some point during the training process it stops and says :
"Opencv Error: Assertion failed (elements_read==1)in unknown function, file c:\path\cvhaartraining.cpp, line 1858"
Any ideas as to what is causing this ?
this issue was answered by creater of the utility on the OpenCV DevZone site in June 2012.
To quote Maria:
It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with -npos 7000 -nneg 2973
so i did following calcs:
vec-file has to contain >= (numPos + (numStages-1) * (1 - minHitRate) * numPos) + S
and used:
It works. I also noticed that others have also had success with reducing numPos : here