PedestrainCounting
HaarFeature.h
1 
7 #ifndef HAAR_FEATURE_HEADER
8 #define HAAR_FEATURE_HEADER
9 
10 #include "EstimatedGaussianDistribution.h"
11 #include "IntegralImage.h"
12 #include "Feature.h"
13 
14 #define HAAR_FEATURE_MAX_NUM_AREAS 4
15 
16 class HaarFeature {
17 public:
18  HaarFeature(const Size &patchSize);
19  virtual ~HaarFeature();
20 
21  // Get the initial distribution of the feature.
22  void GetInitialDistribution(EstimatedGaussianDistribution<1> *distribution) const;
23 
24  bool Extract(const IntegralImage *intImage, const Rect &roi, Feature *feature);
25 
29  void Reset(const Size &patchSize);
30 
31  float GetResponse() { return response; }
32 
33  int GetNumAreas() { return numAreas; }
34 
35  int *GetWeights() { return weights; }
36 
37 private:
38  int type;
39  int numAreas;
40  int *weights;
41  float initMean;
42  float initSigma;
43 
44  // Generate a random Haar feature extractor.
45  void GenerateRandomFeature(const Size &imageSize);
46 
47  // areas within the patch to compute the feature.
48  Rect *areas;
49 
50  // size of patch used in training.
51  Size initSize;
52 
53  // current size under investigation.
54  Size curSize;
55 
56  // scale factor in vertical direction.
57  float scaledHeight;
58 
59  // scale factor in horizontal direction.
60  float scaledWidth;
61 
62  // areas after scaling.
63  Rect *scaledAreas;
64 
65  // weights after scaling.
66  float *scaledWeights;
67 
68  // The result feature from last extraction.
69  float response;
70 
71  // A CDF for five types.
72  static const float cdf[5];
73 
74  // Minimum size.
75  static const Size minimumSize;
76  static const int minimumArea;
77 };
78 
79 #endif
Definition: Geometry.h:34
Definition: EstimatedGaussianDistribution.h:10
Definition: Geometry.h:14
Definition: Feature.h:12
Definition: IntegralImage.h:11
Definition: HaarFeature.h:16
void Reset(const Size &patchSize)
Definition: HaarFeature.cpp:38