Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 :)

click to hide/show revision 2
retagged

updated 2013-10-22 03:16:52 -0600

berak gravatar image

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 :)