7
7
8
8
#include < vector>
9
9
10
+ namespace cv
11
+ {
10
12
class DetectionBasedTracker
11
13
{
12
14
public:
13
15
struct Parameters
14
16
{
15
- int minObjectSize;
16
- int maxObjectSize;
17
- double scaleFactor;
18
17
int maxTrackLifetime;
19
- int minNeighbors;
20
18
int minDetectionPeriod; // the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
21
19
22
20
Parameters ();
23
21
};
24
22
25
- DetectionBasedTracker (const std::string& cascadeFilename, const Parameters& params);
23
+ class IDetector
24
+ {
25
+ public:
26
+ IDetector ():
27
+ minObjSize (96 , 96 ),
28
+ maxObjSize (INT_MAX, INT_MAX),
29
+ minNeighbours (2 ),
30
+ scaleFactor (1 .1f )
31
+ {}
32
+
33
+ virtual void detect (const cv::Mat& Image, std::vector<cv::Rect>& objects) = 0;
34
+
35
+ void setMinObjectSize (const cv::Size& min)
36
+ {
37
+ minObjSize = min;
38
+ }
39
+ void setMaxObjectSize (const cv::Size& max)
40
+ {
41
+ maxObjSize = max;
42
+ }
43
+ cv::Size getMinObjectSize () const
44
+ {
45
+ return minObjSize;
46
+ }
47
+ cv::Size getMaxObjectSize () const
48
+ {
49
+ return maxObjSize;
50
+ }
51
+ float getScaleFactor ()
52
+ {
53
+ return scaleFactor;
54
+ }
55
+ void setScaleFactor (float value)
56
+ {
57
+ scaleFactor = value;
58
+ }
59
+ int getMinNeighbours ()
60
+ {
61
+ return minNeighbours;
62
+ }
63
+ void setMinNeighbours (int value)
64
+ {
65
+ minNeighbours = value;
66
+ }
67
+ virtual ~IDetector () {}
68
+
69
+ protected:
70
+ cv::Size minObjSize;
71
+ cv::Size maxObjSize;
72
+ int minNeighbours;
73
+ float scaleFactor;
74
+ };
75
+
76
+ DetectionBasedTracker (cv::Ptr<IDetector> MainDetector, cv::Ptr<IDetector> TrackingDetector, const Parameters& params);
26
77
virtual ~DetectionBasedTracker ();
27
78
28
79
virtual bool run ();
@@ -44,7 +95,6 @@ class DetectionBasedTracker
44
95
cv::Ptr<SeparateDetectionWork> separateDetectionWork;
45
96
friend void * workcycleObjectDetectorFunction (void * p);
46
97
47
-
48
98
struct InnerParameters
49
99
{
50
100
int numLastPositionsToTrack;
@@ -90,13 +140,11 @@ class DetectionBasedTracker
90
140
std::vector<float > weightsPositionsSmoothing;
91
141
std::vector<float > weightsSizesSmoothing;
92
142
93
- cv::CascadeClassifier cascadeForTracking;
94
-
143
+ cv::Ptr<IDetector> cascadeForTracking;
95
144
96
145
void updateTrackedObjects (const std::vector<cv::Rect>& detectedObjects);
97
146
cv::Rect calcTrackedObjectPositionToShow (int i) const ;
98
147
void detectInRegion (const cv::Mat& img, const cv::Rect& r, std::vector<cv::Rect>& detectedObjectsInRegions);
99
148
};
100
-
149
+ } // end of cv namespace
101
150
#endif
102
-
0 commit comments