3 using namespace suanzi;
6 static const int MaxLost = 5;
8 Tracker::Tracker(const cv::Mat& image,int id) : id(id)
10 status = TrackerStatus::Fire;
11 preStatus = TrackerStatus::Fire;
13 // TODO: Kalman filter
14 this->kf.transitionMatrix = (Mat_<float>(4, 4) <<
20 this->kf.measurementMatrix = (Mat_<float>(2, 2) <<
24 this->kf.processNoiseCov = 1e-5 * Mat_<float>::eye(4, 4);
25 this->kf.measurementNoiseCov = 1e-1 * Mat_<float>::ones(2, 2);
26 this->kf.errorCovPost = 1. * Mat_<float>::ones(4, 4);
34 void Tracker::updateState(const Mat& image)
36 preStatus = this->status;
37 int lost_age = this->age - this->last_active;
38 int active_age = this->last_active;
40 if (lost_age >= MaxLost){
41 status = TrackerStatus::Delete;
42 } else if (lost_age >= 1 && active_age == 1){
43 status = TrackerStatus::Delete;
44 } else if (lost_age >= 1) {
45 status = TrackerStatus::Lost;
49 void Tracker::addPatch(PatchPtr p)
51 this->patches.push_back(p);