Python, OpenCV: it is not possible to create a custom LBP cascade using opencv_traincascade

I am using opencv 2.4.4 installed via macports with python 2.7.5 on mac os x 10.7.5.

I want to train a cascade to look for male frontal faces. But I get a terminate called throwing an exceptionAbort trap: 6 error. I ask the SO community to help me figure out what could go wrong.

Negative (background) image taken from google: googleImages_noFaces (293 images)

Positive images taken from Karolinskaya database: trainingSet (70 images)

I created a text file that indicates the relative location of the background images: bgDesc.txt

I also created a text file indicating the relative location, the number of positive instances in the image (which is always 1) and the bounding area of ​​the object (which is the full image): maleDesc.txt

All these files can be downloaded from here .

Organizing files in this form:

 /trainingSet image1.jpg image2.jpg . . . /googleImages_noFaces image1.jpg image2.jpg . . . /cascadeFiles maleDesc.txt bgDesc.txt 

when I use opencv_createsamples, the maleDesc.vec file maleDesc.vec 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 the -show , I see that 24x24 pixel images are created.

Then i will 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 tried different values ​​of -numPos , such as 10, 20, etc. up to 70, as well as various -numNeg values ​​like 30, 60, etc. to 293. I tried to use numPos values ​​that are less than numNeg values ​​and even those that are larger. I also tried different values ​​of -numStages , such as 1, 5, 10, 20 and 100, but in all these attempts I get the same error.

I have not tried the different values ​​-minHitRate, -maxFalseAlarmRate, -weightTrimRate, -maxDepth, -maxWeakCount, because I really do not understand how they affect the behavior of the opencv_traincascade algorithm.

Any help is much appreciated :)

+6
source share
2 answers

error terminate called throwing an exceptionAbort trap: 6 caused by a typo. I managed to reproduce the behavior and check it in the following code

opencv_traincascade -data cascadeFiles -vec maleDesc.vec -bg bgDesc.txt -numPos 70 - numNeg 293 -nStStages 1 -precalcValBufSize 500 -precalcIdxBufSize 500 -ferecType LBP -w 24 -h 24

there was a space between - and numNeg , which was supposed to be -numNeg

In addition, training continues even with very low samples, but numPos should be twice as large as numNeg

refer to this SO answer for more clarification during the haar and lbp training process: fooobar.com/questions/201447 / ...

two weeks and 50 reputation, because generosity was wasted due to a typo: |

+2
source

They helped me compile the OpenCV TBB function, how to make opencv_traincascade on Ubuntu

negative image sizes (width and height)> positive samples

-3
source

Source: https://habr.com/ru/post/956312/


All Articles