Ask Your Question
0

Very simple TrainCascade not working

asked 2013-01-21 07:41:37 -0600

Jean-François Côté gravatar image

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

image description

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:

image description

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 flag offensive close merge delete

Comments

i have same problem. I use Cascade-Trainer-GUI and haarTraining. Positive image only word "a" and negative images only "n" , "p" but when i test it python with cascade.xml. Program not find a. Program find empty white space. No i test it with use opencv_traincascade

Serdar Öz gravatar imageSerdar Öz ( 2020-08-31 13:34:57 -0600 )edit

2 answers

Sort by » oldest newest most voted
1

answered 2013-01-24 16:52:30 -0600

mnut gravatar image

updated 2013-01-24 16:56:50 -0600

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.

edit flag offensive delete link more

Comments

Thanks for your advice!

Jean-François Côté gravatar imageJean-François Côté ( 2013-01-28 08:47:04 -0600 )edit

Great advice thank you.

flavienb gravatar imageflavienb ( 2019-04-14 08:55:57 -0600 )edit
0

answered 2013-10-28 04:39:09 -0600

Samjakar gravatar image

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-21 07:41:37 -0600

Seen: 2,012 times

Last updated: Oct 28 '13