Detection based tracker was refactored. Detector interface added.

This commit is contained in:
Alexander Smorkalov
2012-06-18 08:55:05 +00:00
parent a20837fb7c
commit 7c160cdc30
4 changed files with 224 additions and 89 deletions

View File

@@ -12,17 +12,66 @@ class DetectionBasedTracker
public:
struct Parameters
{
int minObjectSize;
int maxObjectSize;
double scaleFactor;
int maxTrackLifetime;
int minNeighbors;
int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
Parameters();
};
DetectionBasedTracker(const std::string& cascadeFilename, const Parameters& params);
class IDetector
{
public:
IDetector():
MinObjSize(96, 96),
MaxObjSize(INT_MAX, INT_MAX),
ScaleFactor(1.1f),
MinNeighbours(2)
{}
virtual void detect(const cv::Mat& Image, std::vector<cv::Rect>& objects) = 0;
void setMinObjectSize(const cv::Size& min)
{
MinObjSize = min;
}
void setMaxObjectSize(const cv::Size& max)
{
MaxObjSize = max;
}
cv::Size getMinObjectSize() const
{
return MinObjSize;
}
cv::Size getMaxObjectSize() const
{
return MaxObjSize;
}
float getScaleFactor()
{
return ScaleFactor;
}
void setScaleFactor(float value)
{
ScaleFactor = value;
}
int getMinNeighbours()
{
return ScaleFactor;
}
void setMinNeighbours(int value)
{
}
virtual ~IDetector() {}
protected:
cv::Size MinObjSize;
cv::Size MaxObjSize;
int MinNeighbours;
float ScaleFactor;
};
DetectionBasedTracker(cv::Ptr<IDetector> MainDetector, cv::Ptr<IDetector> TrackingDetector, const Parameters& params);
virtual ~DetectionBasedTracker();
virtual bool run();
@@ -44,7 +93,6 @@ class DetectionBasedTracker
cv::Ptr<SeparateDetectionWork> separateDetectionWork;
friend void* workcycleObjectDetectorFunction(void* p);
struct InnerParameters
{
int numLastPositionsToTrack;
@@ -90,8 +138,7 @@ class DetectionBasedTracker
std::vector<float> weightsPositionsSmoothing;
std::vector<float> weightsSizesSmoothing;
cv::CascadeClassifier cascadeForTracking;
cv::Ptr<IDetector> cascadeForTracking;
void updateTrackedObjects(const std::vector<cv::Rect>& detectedObjects);
cv::Rect calcTrackedObjectPositionToShow(int i) const;