using namespace suanzi;
using namespace cv;
+using namespace std;
static const int MaxLost = 5;
-Tracker::Tracker(int id) : id(id)
+Tracker::Tracker(const cv::Mat& image, const Detection& detection, int id)
+: id(id)
{
- status = TrackerStatus::Fire;
- preStatus = TrackerStatus::Fire;
-}
+ KF.transitionMatrix = (Mat_<double>(4, 4) <<
+ 1, 0, 1, 0,
+ 0, 1, 0, 1,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
-Tracker::~Tracker()
-{
+ KF.measurementMatrix = (Mat_<double>(2, 2) <<
+ 1, 0, 0, 0,
+ 0, 1, 0, 0);
+
+ KF.processNoiseCov = 1e-5 * Mat_<double>::eye(4, 4);
+ KF.measurementNoiseCov = 1e-1 * Mat_<double>::ones(2, 2);
+ KF.errorCovPost = 1. * Mat_<double>::ones(4, 4);
+ randn(KF.statePre, Scalar::all(0), Scalar::all(0.1));
+ KF.statePost = (Mat_<double>(4, 1) << detection.center_x, detection.center_y, 0, 0);
}
-void Tracker::addPatch(Patch* p)
+Tracker::~Tracker()
{
- patches.push_back(p);
- if (patches.size() > Metrics::MaxPatch){
- patches.erase(patches.end());
- }
+ patches.clear();
}
void Tracker::updateState(const Mat& image)
status = TrackerStatus::Lost;
}
}
+
+void Tracker::addPatch(PatchPtr p)
+{
+ patches.insert(patches.begin(), p);
+ if (patches.size() > MaxPatch){
+ patches.pop_back();
+ }
+}
+
+void Tracker::correct(const cv::Mat& image, const Detection& detection)
+{
+ // detection.center_x, detection.center_y,
+ // KF.correct(detect.center_x, detect.center_y);
+ preStatus = status;
+ status = TrackerStatus::Active;
+ last_active = age;
+}
+
+void Tracker::predict()
+{
+ age++;
+ // TODO
+ Mat temp = KF.predict();
+}