15 void KalmanTracker::init_kf(
20 kf = KalmanFilter(stateNum, measureNum, 0);
22 measurement = Mat::zeros(measureNum, 1, CV_32F);
24 kf.transitionMatrix = (Mat_<float>(7, 7) << 1, 0, 0, 0, 1, 0, 0,
33 setIdentity(kf.measurementMatrix);
34 setIdentity(kf.processNoiseCov, Scalar::all(1e-1));
35 setIdentity(kf.measurementNoiseCov, Scalar::all(1e-4));
36 setIdentity(kf.errorCovPost, Scalar::all(1e-2));
39 kf.statePost.at<
float>(0, 0) = stateMat.x + stateMat.width / 2;
40 kf.statePost.at<
float>(1, 0) = stateMat.y + stateMat.height / 2;
41 kf.statePost.at<
float>(2, 0) = stateMat.area();
42 kf.statePost.at<
float>(3, 0) = stateMat.width / stateMat.height;
52 if (m_time_since_update > 0)
54 m_time_since_update += 1;
56 StateType predictBox = get_rect_xysr(p.at<
float>(0, 0), p.at<
float>(1, 0), p.at<
float>(2, 0), p.at<
float>(3, 0));
58 m_history.push_back(predictBox);
59 return m_history.back();
67 StateType predictBox = get_rect_xysr(p.at<
float>(0, 0), p.at<
float>(1, 0), p.at<
float>(2, 0), p.at<
float>(3, 0));
76 m_time_since_update = 0;
82 measurement.at<
float>(0, 0) = stateMat.x + stateMat.width / 2;
83 measurement.at<
float>(1, 0) = stateMat.y + stateMat.height / 2;
84 measurement.at<
float>(2, 0) = stateMat.area();
85 measurement.at<
float>(3, 0) = stateMat.width / stateMat.height;
88 kf.correct(measurement);
99 return get_rect_xysr(s.at<
float>(0, 0), s.at<
float>(1, 0), s.at<
float>(2, 0), s.at<
float>(3, 0));
109 float w = sqrt(s * r);
111 float x = (cx - w / 2);
112 float y = (cy - h / 2);