PedestrainCounting
Classifier.h
1 
6 #ifndef CLASSIFIER_HEADER
7 #define CLASSIFIER_HEADER
8 
9 // #include "FeatureExtractor.h"
10 #include "IntegralImage.h"
11 
12 class Classifier {
13 public:
14  Classifier();
15  virtual ~Classifier();
16 
17  virtual int Classify(const IntegralImage *intImage, const Rect &roi, float scale = 1.0f) {
18  return -1;
19  }
20 
21  virtual float Evaluate(const IntegralImage *intImage, const Rect &roi, float scale = 1.0f) {
22  return FLT_MIN;
23  }
24 };
25 
26 /*
27 // Define the structure of features.
28 // Notice that the only the last weak classifier
29 // in a stage use the threshold field.
30 // Keep it in the structure is for memory alignment.
31 #define H_OFFSET 0
32 #define W_OFFSET 1
33 #define HEIGHT_OFFSET 2
34 #define WIDTH_OFFSET 3
35 #define Z_OFFSET 4
36 #define MIN_OFFSET 5
37 #define MAX_OFFSET 6
38 #define THRE_OFFSET 7
39 #define PROJ_OFFSET 8
40 #define HISTO_OFFSET 44
41 #define NUM_PROJ 36
42 #define NUM_HISTO 100
43 
44 // Total size of a weak classifier.
45 #define SIZE_WEAK 144
46 
47 /*************************************
48 The structure is like this:
49 
50 struct WeakClassifier {
51 feat h;
52 feat w;
53 feat height;
54 feat width;
55 feat z;
56 feat min;
57 feat max;
58 feat threshold;
59 feat projection[36];
60 feat histogram[100];
61 };
62 
63 ****************************************************/
64 
65 /*
66 class AdaBoostClassifier : public Classifier {
67 public:
68  // Build the AdaBoost Classifier from files.
69  AdaBoostClassifier(const char *filepath);
70 
71  ~AdaBoostClassifier();
72 
73  // Classify the patch.
74  // @param x: the x coordinate of upperleft corner.
75  // @param y: the y coordinate of upperleft corner.
76  // @param featureExt: the Feature Extractor.
77  bool Classify(int x, int y, feat scale, FeatureExtractor &featureExt);
78 
79 private:
80  // Data.
81  int numStages;
82  int *numWeaks;
83  feat *data;
84 
85  inline int District(feat value, feat min, feat max) const {
86  if (value <= min) return 0;
87  if (value >= max) return 99;
88 
89  feat step = (max - min) * 0.01;
90 
91  for (int i = 0; i < 100; i++)
92  if (value >= min + step * i - 0.000001 && value <= min + step * (i + 1) + 0.000001)
93  return i;
94  }
95 
96  // A Feature instance to store the feature.
97  Feature feature;
98 };
99 
100 */
101 #endif
Definition: Geometry.h:34
Definition: IntegralImage.h:11
Definition: Classifier.h:12