PedestrainCounting
FeatureExtractor.h
1 /*******************************************
2  FeatureExtractor base class.
3  *******************************************/
4 
5 #ifndef FEATURE_EXTRACTOR_HEADER
6 #define FEATURE_EXTRACTOR_HEADER
7 
8 #include "Feature.h"
9 
10 typedef unsigned char uchar;
11 
13 public:
14  // Interface.
15  virtual void Extract(int width, int height, int i, int j, Feature *feature) = 0;
16 
17  // Some preprocess work, such as integral image.
18  virtual void Preprocess(const cv::Mat& img) {}
19 };
20 
21 // Extract a HoG feature.
22 // Use integral image to accelerate.
24 public:
25  HoGExtractor(int width, int height);
26 
27  void Preprocess(const cv::Mat& img);
28 
29  // Use the integral image to extract HoG.
30  // Must be called after Preprocess.
31  void Extract(int width, int height, int i, int j, Feature *feature);
32 
33  ~HoGExtractor();
34 
35 private:
36  static const float xVector[9];
37  static const float yVector[9];
38 
39  inline int Direct(feat x, feat y) {
40  feat max = 0.0;
41  int ret = 0;
42  for (int i = 0; i < 9; i++) {
43  feat proj = ABS(x * xVector[i] + y * yVector[i]);
44  if (proj > max) {
45  max = proj;
46  ret = i;
47  }
48  }
49  return ret;
50  }
51 
52  feat *integrals;
53  feat *bins;
54  int widthStep;
55 };
56 
57 #endif
Definition: FeatureExtractor.h:12
Definition: Feature.h:12
Definition: FeatureExtractor.h:23