OpenCV traincascade for LBP training

I am trying to create a head detector using the LBP functions in OpenCV using the traincascade utility. It is reliable that a head detector will lead to something similar to the OpenCV profile created by Vladimir Pivarevsky. I want to recreate the model because the current model only handles the front and left sides.

I follow the Naotoshi Seo tutorial and use the dataset from the Irshad Ali website . Unfortunately, the resulting model slowly performs many false positives.

Tracing is performed as follows:

opencv_traincascade -data "data" -vec "samples.vec" -bg "out_negatives.dat" -numPos 26000 -numNeg 4100 -numStages 16 -featureType LBP -w 20 -h 20 -bt GAB -minHitRate 0.995 -maxFalseAlarmRate 0.3 -weightTrimRate 0.95 -maxDepth 1 -maxWeakCount 100 -maxCatCount 256 -featSize 1 

I tried using a different dataset, now the front face from http://fei.edu.br/~cet/facedatabase.html , but the result is still the same: slow detection and a lot of false positives.

Does anyone have any knowledge or experience in creating a cascading haar / lbp model? Please give any suggestion so that I can improve the accuracy of the model. I tried using the built-in OpenCV model and the result is good (lbpfrontalface.xml). Thank you very much!

+7
source share
3 answers

The best way is trial and error ... you really need different faces, and the big difference is better. You can take one face and create many faces through createamples. But in this way you will never have a good cascade. You must have many different faces, and if they are not enough, you can enlarge them using templates. For example, you have 500 different faces, creating patterns that you can make 5,000 with them, then perhaps the cascade will satisfy you.

About the beginning of training: a lot of positive :) or too few negative. You need, for example, 5000 pos and 2500 neg (pos = 2 * neg). At least in my case it was the best choice.

+3
source

It will be slow, relatively, starting at 20x20 and looking at the whole image, then it gets a little bigger, looks again, etc. - Try increasing the sample size to reduce the execution time.

I also noticed that you have nowhere near as many bg images as positive. Try to increase this, at least in the same way as your positive, and this should help.

I also propose to identify the features of the hara and see if it gives any results.

everything else seems beautiful without looking at your input

+1
source

In short, it is normal to get a lot of false positives after stage 1 of the simulation. You need to take these false positives and add them to the negative data set and repeat the simulation (step 2). This is called hard negative booty. It is important. You can multiply false negatives by gradually rotating them 360 degrees.

Three other important points: 1) opencv_createsamples is bad for individuals; 2) Use negatives that are complex (suitable); 3) LBP is the second bet in many contexts.

  • Faces are fairly symmetrical and never display trapezoid like distortion when photographing. Use very small angles if you need, for example, 0.02 radians. In addition, you will find that when viewing images in a .vec file, the background fill around the distorted edges looks completely unnatural.

  • It is important not only the number of negatives, but also the quality of the negatives. Faces are smooth compared to many negative images (for example, trees, Rocky Mountains, etc.). Therefore, it is relatively easy to distinguish a face from a pine tree in the distance. However, you will receive many false positives from smooth surfaces such as walls. It is best to include complex images in a negative dataset. I found that the best background was images of smooth painted drywall walls. Take a video while walking along some walls, use ffmpeg to cut it into a bunch of images. Again, you can multiply these negatives by gradually rotating them 360 degrees, then turn them again and again.

  • Be patient, use HAAR, not LBP.

Now AI is a rage, just divide the 100,000 raw images into folders for the respective classes and start training your model. However, you may find that this approach provides only the right classification rate of 98-99%. Too many false positives. You will get better results with much less data doing what I said above (using HAAR cascades or neural networks). This is real scientific work on data: a perceptive selection of negative and positive data sets and the time-consuming work of defining boundary boxes.

+1
source

All Articles