2
$\begingroup$

If I have an image like this

1 2 3 4 5 6 7 8
a b c d e f g h
...

And I apply a Haar-like feature with a template

1 1 1 1 
-1 -1 -1 -1

Then in the first position we get X1 = 1+2+3+4+a+b+c+d. If we slide one side to the right, we again get X2 = 2+3+4+5+b+c+d+e.

This way we will get X1 and X2 and X3 and so on. Now, how are these values combined to get the feature? Because when we say a feature we are not just running that template in one place, rather we will run it over multiple places in the image. It gives lots of values like X1,X2 and X3 and so on. Now, how are those combined to get the final feature which will be passed to Adaboost?

$\endgroup$
2
$\begingroup$

I would look at table 1 of the original paper. While you're reading the alogorithm, try to really focus on Step 2 when you get to it.

Table 1

In summary, each feature is used to train it's own classifier. So in your example, the calculated features X1, X2, ... Xn you describe coorespond to apply some set of feature transforms f_1, f_2, ... f_n to a single image. This is a bit backwards from what actually happens. What the method really does is train a classifier for each feature. So if you had n features, you would have n classifiers. Then in an adaboost fashion, you upweight the classifier that performed the best. I.e, you are upweighting the classifier based soley on th best performing feature. You then repeat and re-weight all the classifiers until you reach convergence.

$\endgroup$
5
  • 1
    $\begingroup$ Sorry if this is stupid thing to ask - but in your answer when you say there are X1,...Xn the n features - they are coming from the same Haar featuretemplate shown in example in the question right? So when are we using the all of the haar feature templates? (Btw +1 for your effort in answering my bad question maybe) $\endgroup$
    – user27286
    Apr 10 at 18:45
  • $\begingroup$ Nah, no stupid questions! Only stupid answers on my part. More concretely, each haar feature template would be used to create a single classifier. So if you have n haar feature templates you have n classifiers. For each of those n classifiers, you train the entire image set and use adaboost to come to a final solution. $\endgroup$
    – juicedatom
    Apr 10 at 19:41
  • $\begingroup$ I have n haar feature templates. So for example, one template is as shown in my question. Now if I slide this feature template over an image I will get many scalar values due to different location on which it is slid over. All I am asking this, what would I do with all these values? Do I just put them a vector and tell that it is my feature corresponding to the feature template? Also just notice, in my question I said 'X1` is the output of running this feature templated in one location. X2 is the output of running the same feature template over different position.You define X1 otherway. $\endgroup$
    – user27286
    Apr 10 at 19:54
  • 1
    $\begingroup$ In regards to you saying, "Do I just put them into a vector and tell that it my feature cooresponding to the feature template" The answer is yes. The point is that you're going to have a ton of features in the begining (on the order of thousands) where most of them are actually useless and will get filtered out (or upweighted) by adaboost. I found a link to a python implementation that seems much easier to read than staring at the opencv implementation if that helps github.com/ZihengZZH/viola-jones/blob/master/src/…. $\endgroup$
    – juicedatom
    Apr 10 at 20:23
  • $\begingroup$ I will select this as answer and I will put another answer drawing whatever you said. Thanks. $\endgroup$
    – user27286
    Apr 10 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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