0

I intend to calculate haar-like features of input images, and then classify those features using SVM.

My question is: Is there some library (C++ or Matlab) of calculating haar-like features of an image I can use?

By the way, I know the application opencv_traincascade.exe from OpenCV. But I wonder if there is a separated code just for calculating haar-like features in OpenCV?

Jiang
  • 147
  • 4
  • 12
  • possible duplicate of [Matlab implementation of Haar feature extraction](http://stackoverflow.com/questions/2058138/matlab-implementation-of-haar-feature-extraction) – Ratbert Mar 07 '15 at 07:55
  • @CrazyRat Thanks, buddy! And I also found the source code of opencv_haartraining.exe and opencv_traincascade.exe. They're in directory ".\sources\apps\". – Jiang Mar 08 '15 at 01:26

1 Answers1

0

I've found source codes of opencv_traincascade.exe and opencv_haartraining.exe. They're in directory ".\sources\apps\".

And the code to calculate haar-like features of an image is in class CvHaarEvaluator from haarfeatures.cpp, but I can't find any explanation of its members.

As far as I know, CvHaarEvaluator is used once in CvCascadeClassifier.cpp, and the latter is then used once in traincascade.cpp. But I also can't find explanations of traincascade.cpp.

Since it seems that it will take me a lot of time to understand these source codes, I've decided to implement a simple one by myself.

Anyway, if anybody finds an explanation or example of how to use CvHaarEvaluator, please tell me. Thanks!

Jiang
  • 147
  • 4
  • 12
  • hi, buddy. I have the same question. I wanna calculate the haar feature(given an image). Do you implement it? if you do, could you please give me the code or some suggestions? thx a lot. – cyh24 Apr 20 '15 at 06:44
  • @cyh24 The one I implemented was very simple. As describes [this document](http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html) , I simply calculate the difference of "sum of pixels" between black and white rectangle (always called "window"). For example, the egde feature (a) in that link, (1) I set a 24x24 rectangle somewhere in an image, and then split it to two 12x24 sub-rectangles -- let's say rectWhite and rectBlack. (2) Calculate "sumOfPixels( rectWhite ) - sumOfPixels( rectBlack )". (3) That difference is the **haar-like feature** of a certain area. – Jiang Apr 21 '15 at 11:03
  • @cyh24 **Robust Real-Time Face Detection, PAUL VIOLA and MICHAEL J. JONES** well explained the concept of **haar-like feature**. You can follow that paper to implement a simple like I did. Otherwise, you can just use the one that OpenCV offers, and in that case, you'd like to follow [tutorial A](http://docs.opencv.org/doc/user_guide/ug_traincascade.html) and [tutorial B](http://note.sonots.com/SciSoftware/haartraining.html). – Jiang Apr 21 '15 at 11:12