Skip to content

Commit a3be73b

Browse files
author
Alexander Smorkalov
committed
revisions 8681 and 8688 restored. Warning fixed.
Warning: changes beak binary compatibility
1 parent 0a58d8f commit a3be73b

File tree

9 files changed

+437
-194
lines changed

9 files changed

+437
-194
lines changed

modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,73 @@
77

88
#include <vector>
99

10+
namespace cv
11+
{
1012
class DetectionBasedTracker
1113
{
1214
public:
1315
struct Parameters
1416
{
15-
int minObjectSize;
16-
int maxObjectSize;
17-
double scaleFactor;
1817
int maxTrackLifetime;
19-
int minNeighbors;
2018
int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
2119

2220
Parameters();
2321
};
2422

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);
2677
virtual ~DetectionBasedTracker();
2778

2879
virtual bool run();
@@ -44,7 +95,6 @@ class DetectionBasedTracker
4495
cv::Ptr<SeparateDetectionWork> separateDetectionWork;
4596
friend void* workcycleObjectDetectorFunction(void* p);
4697

47-
4898
struct InnerParameters
4999
{
50100
int numLastPositionsToTrack;
@@ -90,13 +140,11 @@ class DetectionBasedTracker
90140
std::vector<float> weightsPositionsSmoothing;
91141
std::vector<float> weightsSizesSmoothing;
92142

93-
cv::CascadeClassifier cascadeForTracking;
94-
143+
cv::Ptr<IDetector> cascadeForTracking;
95144

96145
void updateTrackedObjects(const std::vector<cv::Rect>& detectedObjects);
97146
cv::Rect calcTrackedObjectPositionToShow(int i) const;
98147
void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector<cv::Rect>& detectedObjectsInRegions);
99148
};
100-
149+
} //end of cv namespace
101150
#endif
102-

0 commit comments

Comments
 (0)