3 using namespace suanzi;
7 static const int MaxLost = 5;
9 Tracker::Tracker(const cv::Mat& image, const Detection& detection, int id)
12 status = TrackerStatus::Fire;
13 preStatus = TrackerStatus::Fire;
15 // TODO: Kalman filter
16 KF.transitionMatrix = (Mat_<double>(4, 4) <<
22 KF.measurementMatrix = (Mat_<double>(2, 2) <<
26 KF.processNoiseCov = 1e-5 * Mat_<double>::eye(4, 4);
27 KF.measurementNoiseCov = 1e-1 * Mat_<double>::ones(2, 2);
28 KF.errorCovPost = 1. * Mat_<double>::ones(4, 4);
29 //this->kf.statePre = 0.1 * Matx_<int, 4, 1>::randn(4, 1);
31 randn(KF.statePre, Scalar::all(0), Scalar::all(0.1));
32 KF.statePost = (Mat_<double>(4, 1) << detection.center_x, detection.center_y, 0, 0);
40 void Tracker::updateState(const Mat& image)
42 preStatus = this->status;
43 int lost_age = this->age - this->last_active;
44 int active_age = this->last_active;
46 if (lost_age >= MaxLost){
47 status = TrackerStatus::Delete;
48 } else if (lost_age >= 1 && active_age == 1){
49 status = TrackerStatus::Delete;
50 } else if (lost_age >= 1) {
51 status = TrackerStatus::Lost;
55 void Tracker::addPatch(PatchPtr p)
57 this->patches.push_back(p);
60 void Tracker::correct(const cv::Mat& image, const Detection& detection)
62 // detection.center_x, detection.center_y,
63 // KF.correct(detect.center_x, detect.center_y);
65 status = TrackerStatus::Active;
69 void Tracker::predict()
72 //detection = KF.predict();