22 #ifndef _NNDEPLOY_TRACK_TRAJECTORY_H_
23 #define _NNDEPLOY_TRACK_TRAJECTORY_H_
25 #include <opencv2/core/core.hpp>
26 #include <opencv2/highgui/highgui.hpp>
27 #include <opencv2/imgproc/imgproc.hpp>
30 #include "opencv2/video/tracking.hpp"
47 virtual void init(
const cv::Mat &measurement);
49 virtual const cv::Mat &
correct(
const cv::Mat &measurement);
50 virtual void project(cv::Mat *mean, cv::Mat *covariance)
const;
53 float std_weight_position;
54 float std_weight_velocity;
58 cv::KalmanFilter::transitionMatrix = cv::Mat::eye(8, 8, CV_32F);
59 for (
int i = 0; i < 4; ++i)
60 cv::KalmanFilter::transitionMatrix.at<float>(i, i + 4) = 1;
61 cv::KalmanFilter::measurementMatrix = cv::Mat::eye(4, 8, CV_32F);
62 std_weight_position = 1 / 20.f;
63 std_weight_velocity = 1 / 160.f;
77 bool update_embedding =
true);
122 void update_embedding(
const cv::Mat &
embedding);
137 cv::Mat current_embedding;
144 xyah[0] = (ltrb[0] + ltrb[2]) * 0.5f;
145 xyah[1] = (ltrb[1] + ltrb[3]) * 0.5f;
146 xyah[3] = ltrb[3] - ltrb[1];
147 xyah[2] = (ltrb[2] - ltrb[0]) / xyah[3];
154 smooth_embedding(cv::Mat()),
167 smooth_embedding(cv::Mat()),
180 : state(other.state),
183 is_activated(other.is_activated),
184 timestamp(other.timestamp),
185 starttime(other.starttime),
189 length(other.length) {
191 other.current_embedding.copyTo(current_embedding);
194 other.statePre.copyTo(cv::KalmanFilter::statePre);
195 other.statePost.copyTo(cv::KalmanFilter::statePost);
196 other.errorCovPre.copyTo(cv::KalmanFilter::errorCovPre);
197 other.errorCovPost.copyTo(cv::KalmanFilter::errorCovPost);
208 this->xyah = rhs.xyah;
210 rhs.current_embedding.copyTo(this->current_embedding);
212 this->length = rhs.length;
216 rhs.statePre.copyTo(cv::KalmanFilter::statePre);
217 rhs.statePost.copyTo(cv::KalmanFilter::statePost);
218 rhs.errorCovPre.copyTo(cv::KalmanFilter::errorCovPre);
219 rhs.errorCovPost.copyTo(cv::KalmanFilter::errorCovPost);
virtual ~TKalmanFilter(void)
virtual void init(const cv::Mat &measurement)
virtual void project(cv::Mat *mean, cv::Mat *covariance) const
virtual const cv::Mat & correct(const cv::Mat &measurement)
virtual const cv::Mat & predict()
friend TrajectoryPool operator-(const TrajectoryPool &a, const TrajectoryPool &b)
friend TrajectoryPtrPool operator+(const TrajectoryPtrPool &a, const TrajectoryPtrPool &b)
friend cv::Mat iou_distance(const TrajectoryPtrPool &a, const TrajectoryPool &b)
friend TrajectoryPtrPool operator-(const TrajectoryPtrPool &a, const TrajectoryPtrPool &b)
virtual const cv::Mat & predict(void)
virtual void reactivate(Trajectory *traj, int &cnt, int timestamp, bool newid=false)
friend TrajectoryPool & operator-=(TrajectoryPool &a, const TrajectoryPool &b)
friend cv::Mat embedding_distance(const TrajectoryPtrPool &a, const TrajectoryPool &b)
virtual void activate(int &cnt, int timestamp)
virtual void mark_removed(void)
friend TrajectoryPool & operator+=(TrajectoryPool &a, const TrajectoryPtrPool &b)
Trajectory & operator=(const Trajectory &rhs)
friend cv::Mat mahalanobis_distance(const TrajectoryPtrPool &a, const TrajectoryPool &b)
friend TrajectoryPtrPool operator+(const TrajectoryPtrPool &a, TrajectoryPool *b)
friend cv::Mat mahalanobis_distance(const TrajectoryPool &a, const TrajectoryPool &b)
virtual ~Trajectory(void)
friend cv::Mat mahalanobis_distance(const TrajectoryPtrPool &a, const TrajectoryPtrPool &b)
friend TrajectoryPool operator+(const TrajectoryPool &a, const TrajectoryPtrPool &b)
friend cv::Mat embedding_distance(const TrajectoryPtrPool &a, const TrajectoryPtrPool &b)
friend cv::Mat embedding_distance(const TrajectoryPool &a, const TrajectoryPool &b)
virtual void update(Trajectory *traj, int timestamp, bool update_embedding=true)
friend cv::Mat iou_distance(const TrajectoryPtrPool &a, const TrajectoryPtrPool &b)
virtual void mark_lost(void)
friend cv::Mat iou_distance(const TrajectoryPool &a, const TrajectoryPool &b)
friend TrajectoryPool operator+(const TrajectoryPool &a, const TrajectoryPool &b)
base::Status embedding(device::Tensor *input, device::Tensor *indice, device::Tensor *output)
std::vector< Trajectory >::iterator TrajectoryPoolIterator
std::vector< Trajectory * >::iterator TrajectoryPtrPoolIterator
std::vector< Trajectory > TrajectoryPool
cv::Vec4f ltrb2xyah(const cv::Vec4f <rb)
std::vector< Trajectory * > TrajectoryPtrPool