PedestrainCounting
ImageDetector.h
1 
7 #ifndef IMAGE_DETECTOR_HEADER
8 #define IMAGE_DETECTOR_HEADER
9 
10 // #include "FeatureExtractor.h"
11 #include "Options.h"
12 #include "Classifier.h"
13 #include "Pool.h"
14 #include "UnionFind.h"
15 
16 struct rect
17 {
18  int x1;
19  int y1;
20  int x2;
21  int y2;
22  int re;
23  int count;
24  rect(int _x1 = 0, int _y1 = 0, int _x2 = 0, int _y2 = 0)
25  : x1(_x1), y1(_y1), x2(_x2), y2(_y2), re(-1), count(1) {}
26 };
27 
28 // Use some specific feature and classifier to detect pedestrain.
29 // Apply this directly on the whole image.
31 public:
32  ImageDetector(Classifier *c, const Options &op);
33 
45  virtual bool Detect(const cv::Mat &img, const IntegralImage *intImage,
46  const Rect &subRegion,
47  const cv::Mat &bkg = defaultBackground
48  );
49 
50  void DrawDetection(cv::Mat &img);
51 
52  // Clear all the detections.
53  void Clear();
54 
55  // Detections.
56  Pool<Rect> dets;
57 
58 protected:
59  Classifier *classifier;
60  feat scaleMin;
61  feat scaleMax;
62  feat scaleStep;
63  int slideStep;
64  int evidence;
65  int modelHeight;
66  int modelWidth;
67 
68 
69  // Temp pool used in merge.
70  Pool<rect> temp;
71 
72  // This is used in union-find.
73  Pool<int> roots;
74 
75  UnionFind *unionFind;
76 
77  // Some helper functions.
78  // Is these two detection the same one?
79  bool IsEqual(const rect &r1, const rect &r2) const;
80  bool IsOverlap(const rect &r, const rect &t) const;
81 };
82 
83 void DrawDetection(cv::Mat &img, Pool<rect> &dets);
84 
85 
86 #endif
Definition: UnionFind.h:9
Definition: Geometry.h:34
Definition: ImageDetector.h:30
virtual bool Detect(const cv::Mat &img, const IntegralImage *intImage, const Rect &subRegion, const cv::Mat &bkg=defaultBackground)
Definition: ImageDetector.cpp:14
Definition: IntegralImage.h:11
Definition: ImageDetector.h:16
Definition: Classifier.h:12
Definition: Options.h:14