Python, OpenCV: unable to make custom LBP cascade using opencv_traincascade
This is a copy of my question on stackoverflow...
I am using opencv 2.4.4 installed via macports with python 2.7.5 on a mac os x 10.7.5.
I want to train a cascade to look for male frontal faces. But I am getting the terminate called throwing an exceptionAbort trap: 6
error. I request your help in figuring out why this errors occurs. For instance is there something wrong in my .txt files or in the parameters given to opencv_traincascade?
The negative (background) image are taken from google: googleImages_noFaces (293 images)
The positive images are taken from Karolinska database: trainingSet (70 images)
I created a text file which indicates the relative location of background images: bgDesc.txt
I also created a text file indicating the relative location, number of positive instances in the image (which is always 1) and bounding region of the object (which is the entire image): maleDesc.txt
All these files can be downloaded from here
The organization of the files is in this form:
/trainingSet
image1.jpg
image2.jpg
.
.
.
/googleImages_noFaces
image1.jpg
image2.jpg
.
.
.
/cascadeFiles
maleDesc.txt
bgDesc.txt
when I use opencv_createsamples a maleDesc.vec file is successfully created with the following line:
opencv_createsamples -vec maleDesc.vec -info maleDesc.txt -bg bgDesc.txt -num 70 -w 24 -h 24
if I use -show
parameter I can see that 24x24 pixel images are created.
I then try
opencv_traincascade -data cascadeFiles -vec maleDesc.vec -bg bgDesc.txt -numPos 70 - numNeg 293 -numStages 1 -precalcValBufSize 500 -precalcIdxBufSize 500 -featureType LBP -w 24 -h 24
which gives me an error.
I have tried different values of -numPos
such as 10, 20 and so on up to 70 along with different values of -numNeg
as 30, 60 and so on up to 293. I have tried to use numPos values that are less than numNeg values and even those which are greater than. I have also tried different -numStages
values like 1, 5, 10, 20 and 100 but in all of these attempts I get the same error.
I have not tried different values of -minHitRate, -maxFalseAlarmRate, -weightTrimRate, -maxDepth, -maxWeakCount because I don't really understand how they influence the behavior of opencv_traincascade algorithm.
Any help is much appreciated :)
Does the training start? Or crashes right at take off?
it crashes right away. the training doesn't start.
I've never tried to train a cascade with so few positive and negative samples. I've had the same problem when I tried to call traincascade.exe method with the whole set of positives I used in the createsamples utility. So, for example, if I had 1000 positive samples, I would train with 900, or else the training would crash at start. Try to use the older version of the training cascade haartraining.exe, if it crashes it outputs slightly more information about where the program crashed and might even give you an error message. Good luck
started a bounty on SO: http://stackoverflow.com/q/19464834/1463143 lets see if someone can help find a solution