I'm trying to create an xml file using samples I took with my camera. This is a test run where I put my camera against my window and let it take a picture every 30 seconds of passing cars for a while. I have now about 200 pictures (just for a small test), but I can't get any further.
I made a selecting tool to pick out the cars on pictures (bounding boxes) and mark pictures as negatives if there aren't any. Here are 2 examples of what the application looks like:
The application then saves the marked objects in positive.txt
file as follows, skipping the non-marked pictures or the pictures marked as negative:
/samples/img_0000.jpg 1 74 66 34 30
/samples/img_0001.jpg 2 78 69 31 25 218 129 61 38
/samples/img_0003.jpg 1 83 72 21 21
/samples/img_0005.jpg 1 76 65 19 17
/samples/img_0006.jpg 1 127 112 37 24
/samples/img_0007.jpg 2 83 72 22 21 127 112 36 22
...
The negative pictures are simply saved to negative.txt
file as follows:
/samples/img_0002.jpg
/samples/img_0004.jpg
/samples/img_0024.jpg
/samples/img_0026.jpg
...
Finally I try to run the haar training algorithm with /usr/bin/opencv_haartraining -data samples -vec positive.txt -bg negative.txt -npos 99 -nneg 20 -nstages 5 -mem 128 -minhitrate 0.999 -maxfalsealarm 0.5 -nonsym -mode ALL
.
Don't mind the settings, I simply need this to work before I use a much more powerful computer to do the actual training on actual data with much more pictures.
For that I get the following output and error:
Data dir name: samples
Vec file name: positive.txt
BG file name: negative.txt, is a vecfile: no
Num pos: 99
Num neg: 20
Num stages: 5
Num splits: 1 (stump as weak classifier)
Mem: 128 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 0
Min number of positive samples per cluster: 500
Required leaf false alarm rate: 0.03125
Tree Classifier
Stage
+---+
| 0|
+---+
Number of features used : 261600
Parent node: NULL
*** 1 cluster ***
OpenCV Error: Unspecified error (Vec file sample size mismatch) in icvGetHaarTrainingDataFromVec, file /build/opencv-XZa2gn/opencv-2.3.1/modules/haartraining/cvhaartraining.cpp, line 1930
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-XZa2gn/opencv-2.3.1/modules/haartraining/cvhaartraining.cpp:1930: error: (-2) Vec file sample size mismatch in function icvGetHaarTrainingDataFromVec
Aborted
Does anybody know what that means? Why is there an error with sample size, whatever that is... I also tried replacing relative paths with absolute paths, but I got the same error. Is what I'm trying to do actually right, I haven't found any explicit examples on how to create a classifier from existing and marked pictures.