5

it's some weeks that I try to create a good cascade classifier but it seems that this process is surrounded by mystery. I have a lot of questions:

1) Why opencv give us so little information?

2) It needs more positive images or negative images?

3) What size should have positive images? And negative images? They must have all the same size?

4) if I want to create a classifier for a single road sign is enough a single positive image like this to create samples with opencv_createsamples?

5) To create a classifier used on an android app is better Haar or LBP?

6) what is the right number of stages?

7) What is the right value for minHitRate and maxFalseAlarmRate?

1 Answer 1

6
  1. It gives information, it is just a bit borring to read it http://docs.opencv.org/doc/user_guide/ug_traincascade.html
  2. You need more negative images, for several reasons. First it just sometimes crashes when there more positive images then negative, second - most of the time training is focused on looking in negative images for something that was detect as your object and fixing the mistake.
  3. As far as i know, it does not matter that much, but what is relevant is the negative images them self. They should be close to the real backgrounds of your object, i mean if it is a traffic sign don't give pictures clicked in your office as background, take pictures clicked outside.
  4. For me it was enough to have one picture of my object, to generate 1500 samples with opencv_createsamples, but much better to have several images 10, 20 to generate 100, 200 samples with each and then combine it all into one training set.
  5. Haar is slower training and runtime, but sometimes it is more precise, so my choice is LBP.
  6. You can train cascade stage by stage, to make 10 -15 stages at the beginning, and then add them one by one.All stages recorded, and you don't have to begin each time from stage one.

7.I did not play with this parameters, i always leave them with defaults but you can check here about traincascade paremeters, samples, and other... for explanations.

Also check this question and answer How to train cascade properly and FAQ - HAARTraining

7
  • Last question: I need more positive samples or negative image? Dec 22, 2013 at 15:02
  • More negative images. I fixed the second bullet of my answer. I usually give 1500 positive, with 3000 negatives
    – Dabo
    Dec 22, 2013 at 15:07
  • Ok, I'll try. thanck you very much! Dec 22, 2013 at 15:13
  • I found this post. Here they use more positive samples than negative images and they use a formula to calculate the right number of samples to pass to -npos. You know something about it? Dec 22, 2013 at 15:33
  • Yes I know there is a formula, but it is just easier to give more negative samples. By the way i forgot to mention not to use the same number of positive in numPos parameter as you have in vec file. i.e if your vec file contains 1500 positive pictures, pass something like 1200 or 1300 in numPos parameter.
    – Dabo
    Dec 22, 2013 at 15:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.