Dear OpenCV Developers,
I tried to train a haar cascade with traincascade 2.4.9. For my first test I had only 16 positive samples and 3000 negative samples. I compiled opencv 2.4.9 on Ubuntu 14.04 LTS and installed it to usr/local.
The following command
opencv_traincascade -data cascades -vec Positives/positives.vec -bg Negatives/negatives.dat -numStages 10 -w 16 -h 16 -numPos 16 -numNeg 3000
succeeds with a 3 stage filter. The problem is that the generated cascade.xml file is slightly different from all sample cascade files provided in the sample folder. The header of the generated file looks like this:
<?xml version="1.0"?>
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
<featureType>HAAR</featureType>
<height>16</height>
<width>16</width>
<stageParams>
<boostType>GAB</boostType>
I guess most of the filters provided with opencv 2.4.9 are still created with haartraining, not with traincascade, and have a quite different format. But the files in opencv-2.4.9/data/lbpcascades look similar:
<?xml version="1.0"?>
<!--
number of positive samples 3000
number of negative samples 1500
-->
<opencv_storage>
<cascade type_id="opencv-cascade-classifier">
<stageType>BOOST</stageType>
<featureType>LBP</featureType>
<height>24</height>
<width>24</width>
<stageParams>
<boostType>GAB</boostType>
Obviously the type_id in the cascade item is missing in the file generated by trainscascade 2.4.9. When I try to read this file e.g. with opencv_performance, I get the following error:
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /data/download/OpenCV/opencv-2.4.9/modules/core/src/persistence.cpp, line 4991
I tried to fix the file and add the type_id manually, but the error is exactly the same.
Then I tried traincascade from GIT, but it crashes with the same data. Then I tried haartraining 2.4.9, but although traincascade finishes in a minute or so (on an i7-4770K), haartraining gets stuck at some point after an hour of computation.
Then I tried various filters from opencv-2.4.9/data. The haarcascade_eye_tree_eyeglasses.xml is loadable, but this is in an old format, probably created by haartraining. lbpcascade_frontalface.xml seems to be in the new format, but produces the same error when used e.g. with
opencv_performance -data XmlFormats/lbpcascade_frontalface_2.4.9.xml -w 24 -h 24 -info tests.dat -ni
I also found that the haarcascade_eye_tree_eyeglasses.xml from GIT has been created with traincascade (or at least it looks like this), but I cannot load it either with opencv_performance.
So something seems to be wrong with the training apps in opencv 2.4.9.
Does someone has a simple dummy sample for traincascade 2.4.9, which produces something which can be loaded into opencv_performance 2.4.9?
Thanks & best regards,
Michael