Ask Your Question

What should the parameters given for the haartrainig to be a success?

asked 2013-10-27 23:30:12 -0600

Tanay gravatar image

I'm trying to train a haar cascade of positive images 1749 and negative images 3867. My positive vector file contains 885 samples. I'm trying to detect palm. Is this the correct ratio of number positive and negative images? And what should be the value of the parameters of my haar cascade?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-10-28 00:13:38 -0600

r.a. gravatar image

updated 2013-10-28 00:15:29 -0600

Hi, I also asked my self those questions I can tell you from my experience.(By the way look in this forum for more answers in this topic there are many of those!)

Regarding your question:

1.Your positive and Negative images must be correlated to the problem scenario you would like to solve!(Is there a typical background lighting condition ...) Try to have positive and negative samples that span the problem that you are trying to solve.

2.The positive samples should be approximately in the same rotation\view-point in all positive Images. If you need several viewpoints train several classifiers one for each viewpoint.

3.Use train_cascade instead of haartraining and use LBP feature for faster training.

4.Start with default params.

5.Try to use for example npos = 5-- and Nneg =2000 for start and check your result if it's not good enough add later more positive and negative samples.

Also as I said look here in this forum question on this topic.

Good luck!

edit flag offensive delete link more


can you elaborate on how to use train_cascade and LBP features. Is there any tutorials available. Thanks

Tanay gravatar imageTanay ( 2013-10-28 03:35:48 -0600 )edit

Try opencv tutorial Try for example a line like this:(Starting point only) opencv_traincascade -data "data" -vec "samples.vec" -bg "out_negatives.dat" -numPos 500 -numNeg 2000 -numStages 16 -featureType LBP -w 20 -h 20 -bt GAB -minHitRate 0.995 -maxFalseAlarmRate 0.5 -weightTrimRate 0.95 -maxDepth 1 -maxWeakCount 100 I believe from now you have what you need to start.

r.a. gravatar imager.a. ( 2013-10-28 05:32:57 -0600 )edit

It's showing an error "Parameters cannot be written, because file hand.xml/params.xml cannot be opened" where hand.xml is my "data".

Tanay gravatar imageTanay ( 2013-10-28 06:27:41 -0600 )edit

O.k. actually you didn't look at:(You must look at the answer I have already told you) see that data is a folder! -data <cascade_dir_name> Anyway this is your third question open it as new question.

If I answered your original question please vote.

r.a. gravatar imager.a. ( 2013-10-28 08:05:12 -0600 )edit

Hi , when i am training the xml using traincascade i am facing an opencv error: Here is the link to my OpenCV error: can you please look in to it Thanks.

ART gravatar imageART ( 2014-02-13 00:46:01 -0600 )edit

Question Tools


Asked: 2013-10-27 23:30:12 -0600

Seen: 485 times

Last updated: Oct 28 '13