X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=src%2FTracker.cpp;h=99a4e2866051f5f270d3bda4a6e3374e7113a961;hb=b5f0328f4054d19fcf8a6b870d5448be8087d29c;hp=79fd9416d2fefc743ec661d05f4355d553eb4525;hpb=b5342c4a4bbfb17346e7bffc5dae129290d184be;p=trackerpp.git diff --git a/src/Tracker.cpp b/src/Tracker.cpp index 79fd941..99a4e28 100644 --- a/src/Tracker.cpp +++ b/src/Tracker.cpp @@ -1,11 +1,55 @@ #include "Tracker.h" using namespace suanzi; +using namespace cv; -Tracker::Tracker() +static const int MaxLost = 5; + +Tracker::Tracker(const cv::Mat& image,int id) : id(id) { + status = TrackerStatus::Fire; + preStatus = TrackerStatus::Fire; + + // TODO + // init KalmanFilter + 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) << + 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); + + } Tracker::~Tracker() { + patches.clear(); +} + +void Tracker::updateState(const Mat& image) +{ + preStatus = this->status; + int lost_age = this->age - this->last_active; + int active_age = this->last_active; + + if (lost_age >= MaxLost){ + status = TrackerStatus::Delete; + } else if (lost_age >= 1 && active_age == 1){ + status = TrackerStatus::Delete; + } else if (lost_age >= 1) { + status = TrackerStatus::Lost; + } +} + +void Tracker::addPatch(PatchPtr p) +{ + this->patches.push_back(p); }