# Very simple TrainCascade not working

Hello everyone,

I'm currently trying to detect complex thing in video but since it wasn't working at all, I've decided to go back to the basics and I'm trying to find this object

So I used this script in a .bat file with a directory full of 1519 negative image that I checked one by one to contain nothing that look like that.

:: Creaction of 10000 positive variation of the image
opencv_createsamples -vec pos.vec -img positive/recherche.bmp -bg negative.txt -num 10000
pause

:: Training
opencv_traincascade -data resultat -vec pos.vec -featureType LBP -bg negative.txt -numPos 1 -numNeg 1519
pause


After that I'm searching in image like this:

No luck at all... So imagine if the traincascade is not able to detect something as simple as this logo in a white bmp, I will never work on a real world example.

Anyone here could tell me what I'm doing wrong or what I could do to improve my technique. The correct answer will be awarded to the one that will give me an advice that will make this simple detection works. I've also read that Haartraining is slower, not developed anymore but could be more effective, is it true?

Thanks

edit retag close merge delete

Sort by » oldest newest most voted

It is not easy to say for sure what is wrong with the cascade you built. Here are some questions that might help you fix the issue. (1) Is the star in the search image /test image roughly the same size as the star in the positive set? I think the boosted cascade is only good until certain amount of scaling. Try making the star in your test image the same size as the stars in your training set. (2) Try fewer cascade stages when training your cascade. You should get a result where you see a lot of "false positive" detections in your test image. If you see this, then you can start increasing the number of stages. Now you should see some false detections vanish. (3) For testing, try to place the star on one of your negative images (instead of a white background) and see what you get as results. (4) Boosting is good when you train it properly. The negative images are important too. It is good if they should represent the negative instances you are likely to come across in your test set.

I have not used createsamples to generate positive samples automatically (with the -img option). I have used manually marked positive samples (-info option). I would try creating a positive set of 20-30 stars by hand and then creating a vec file using -info option. http://docs.opencv.org/doc/user_guide/ug_traincascade.html#positive-samples

I would not suggest using haartraining. train_cascade is the new version of training and should give you the same results as haartraining, but with more options for improving.

Boosting is great when the object does not change much in appearance. It should certainly work for logos on a piece of paper. Whether it will work for logos that are seen from different angles or not is questionable. Boosting also needs lots of training data (both positive and negative) to do a good job. It is certainly a good algorithm that is worth pursuing. It works, as many face detection researchers will tell you.

more

( 2013-01-28 08:47:04 -0500 )edit

( 2019-04-14 08:55:57 -0500 )edit

Hi Jean, This could very well be resolved now. But, am responding since I was looking for some answers for my questions :). Is there a typo in the question or is it just bad command. opencv_traincascade -data resultat -vec pos.vec -featureType LBP -bg negative.txt -numPos 1 -numNeg 1519

The numPos has just "1". I think that could be your problem, unless that was a typo when you posted on this forum.

Karthik

more

Official site

GitHub

Wiki

Documentation