Extracting Haar feature vectors

asked 2015-04-22 11:31:25 -0600

LorenaGdL gravatar image

I'm trying to extract Haar feature vectors of images but I can't find the way to do it, and I was hoping some of you could shed some light on it. Let me explain the situation:

  • My goal is to obtain a vector of Haar features of an image, as it is possible to get a vector of HOG features (floats) through HOGDescriptor, so then I can use such vector to train an SVM classifier.
  • I know that Haar features are integrated within the Cascade Classifier, but I don't want to use this kind of classifier.
  • I've been navigating through the several source files involved in the issue, where the FeatureEvaluator is defined and the Haar features are described (basically the files in the traincascade app folder), and I've been trying to use/adapt them to my problem. However, I can't find the way to make use of each of the classes to get the vector of features. Indeed, most of my tries have ended in compilation errors due to some virtual functions not being implemented or include files missing...

After several days of trying I'm quite desperate about not finding a solution (not even a close one), so any help would be incredibly appreciated, whether it's some already done implementation of this (though I couldn't find any), any advice or some tips to face the problem.

Thanks in advance!

P.S. Seems that the 3.0 version will allow to do this through the contrib TrackerFeature class, but I don't plan to migrate all my project from 2.4.x right now.

P.S.2. I find it quite weird that no one before has needed to extract Haar feature vectors for other purposes than using them with the Cascade Classifier. Am I missing anything?

edit retag flag offensive close merge delete

Comments

If you only want to extract the Haar features, maybe you could implement it yourself ?

It seems that it is just sum and difference of pixels using a specific pattern (Haar-like features). You can do it at different scales and by sliding a window over the image ?

Or you could use an extern implementation in C++ or in Matlab, or in C#.

Eduardo gravatar imageEduardo ( 2015-04-23 04:39:34 -0600 )edit

Well you will need to specify manually which features you want, since a 24x24 window already contains 180.000 possible features that can be calculated. I think this is one of the main reasons why people only combine then with self learning systems, instead of with SVM classifiers.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-04-23 05:04:00 -0600 )edit
1

@Eduardo: implementing the extraction myself is something I don't discard, but as OpenCV already has such implementation, probably in a very optimized way, I think it would be very better to use it if possible. I'll take a look at those extern links though, thank you.

@StevenPuttemans: maybe that's the reason, but I still find it weird. At the end, whatever the descriptor you choose (HOG, Haar, LBP, etc) you can (and should) make choices of sizes and so on, and you can end up with a feature vector of size 200 or size 2000000, that's up to you and your goal. I guess people just want something to run automatically so they don't have to care about anything, but when you're researching one has to go one step further :)

LorenaGdL gravatar imageLorenaGdL ( 2015-04-23 05:39:21 -0600 )edit

I get your point :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-04-23 05:48:32 -0600 )edit