X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=src%2FTracker.cpp;h=e9353bdfbfa3aa5c14aa929d9c291ed7abe6955b;hb=a80807eb35cc0ff70a9afdd6b7db2f38cb686683;hp=50bc82044dbe3e6ddfd42a2e5a5149b9b11238db;hpb=3ff9a5ad691b8dca9d91f8e9786a8d08d31b70fa;p=trackerpp.git diff --git a/src/Tracker.cpp b/src/Tracker.cpp index 50bc820..e9353bd 100644 --- a/src/Tracker.cpp +++ b/src/Tracker.cpp @@ -2,43 +2,40 @@ using namespace suanzi; using namespace cv; +using namespace std; static const int MaxLost = 5; -Tracker::Tracker(const cv::Mat& image,int id) : id(id) +Tracker::Tracker(const cv::Mat& image, const Detection& detection, int id) : id(id) { status = TrackerStatus::Fire; preStatus = TrackerStatus::Fire; - // TODO - // init KalmanFilter - this->kf.transitionMatrix = (Mat_(4, 4) << + // TODO: Kalman filter + this->kf.transitionMatrix = (Mat_(4, 4) << 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1); - this->kf.measurementMatrix = (Mat_(2, 2) << + this->kf.measurementMatrix = (Mat_(2, 2) << 1, 0, 0, 0, 0, 1, 0, 0); - this->kf.processNoiseCov = 1e-5 * Mat_::eye(4, 4); - this->kf.measurementNoiseCov = 1e-1 * Mat_::ones(2, 2); - this->kf.errorCovPost = 1. * Mat_::ones(4, 4); + this->kf.processNoiseCov = 1e-5 * Mat_::eye(4, 4); + this->kf.measurementNoiseCov = 1e-1 * Mat_::ones(2, 2); + this->kf.errorCovPost = 1. * Mat_::ones(4, 4); + //this->kf.statePre = 0.1 * Matx_::randn(4, 1); + //??? TODO + randn(this->kf.statePre, Scalar::all(0), Scalar::all(0.1)); + this->kf.statePost = (Mat_(4, 1) << detection.center_x, detection.center_y, 0, 0); } Tracker::~Tracker() { + patches.clear(); } -//void Tracker::addPatch(Patch* p) -//{ -// patches.push_back(p); -// if (patches.size() > Metrics::MaxPatch){ -// patches.erase(patches.end()); -// } -//} -// void Tracker::updateState(const Mat& image) { preStatus = this->status; @@ -53,3 +50,17 @@ void Tracker::updateState(const Mat& image) status = TrackerStatus::Lost; } } + +void Tracker::addPatch(PatchPtr p) +{ + this->patches.push_back(p); +} + +void Tracker::correct(const cv::Mat& image, const Detection& detection) +{ + //kf.correct(); + preStatus = status; + status = TrackerStatus::Active; + last_active = age; +} +