Commit 8cc6ce61 authored by oscar's avatar oscar

提交update一定次数才认为是有效的数据

parent 1ad751e6
......@@ -18,6 +18,7 @@ void BaseTrack::Init(const std::vector<float>& data)
observation(i) = data[i];
kf_->x_.head(size) << observation;
hit_streak_++;
m_update_count++;
}
void BaseTrack::Predict()
{
......@@ -40,6 +41,7 @@ void BaseTrack::Update(const std::vector<float>& data)
coast_cycles_ = 0;
// accumulate hit streak count
hit_streak_++;
m_update_count++;
// observation - center_x, center_y, area, ratio
int size = data.size();
......@@ -96,6 +98,10 @@ bool BaseTrack::IsLost()
{
return coast_cycles_ > m_kMaxCoastCycles;
}
bool BaseTrack::IsValid()
{
return m_update_count >= m_updateValidCount;
}
int BaseTrack::GetMeasureData(std::vector<float>& data)
{
if (kf_ == nullptr || m_num_obs > m_num_states)
......
......@@ -27,7 +27,8 @@ public:
virtual int GetPredictData(std::vector<float>& data);
virtual float GetNIS() const;
virtual float GetProb() const;
virtual bool IsLost();
virtual bool IsLost();//数据是否丢失,如果不更新就会丢失
virtual bool IsValid();//数据是否有效
virtual int GetMeasureData(std::vector<float>& data);
......@@ -45,6 +46,8 @@ public:
int coast_cycles_ = 0, hit_streak_ = 0;
int m_update_count = 0;//数据更新的次数
int m_num_states = 0;
int m_num_obs = 0;
......@@ -52,6 +55,7 @@ public:
float m_iou_threshold = 0.3;//iou计算之后匹配的最小值
int m_kMaxCoastCycles = 2;//predict之后,计算几次认为丢失。
int m_updateValidCount = 3;//更新多少次认为是一个有效数据。
std::shared_ptr<mytracker::KalmanFilter> kf_ = nullptr;
......
......@@ -30,7 +30,7 @@ public:
int Run(const std::vector<std::vector<float> >& detections,std::vector<uint64_t>& detectionsId,std::map<uint64_t,int>& updateId,std::vector<uint64_t>& lostId);
std::map<uint64_t, std::shared_ptr<T> >& GetStates();
std::map<uint64_t, std::shared_ptr<T> > GetStates();
void AssociateDetectionsToTrackers(const std::vector<std::vector<float> >& detections, std::map<uint64_t, std::shared_ptr<T> >& tracks, std::map<uint64_t, int>& matched, std::vector<int>& unmatched_det);
......@@ -157,9 +157,17 @@ int BaseTracker<T>::Run(const std::vector<std::vector<float> >& detections, std:
}
template<class T>
std::map<uint64_t, std::shared_ptr<T> >& BaseTracker<T>::GetStates()
std::map<uint64_t, std::shared_ptr<T> > BaseTracker<T>::GetStates()
{
return m_tracker;
std::map<uint64_t, std::shared_ptr<T> > ret;
for (auto& track : m_tracker)
{
if (track.second->IsValid())
{
ret[track.first] = track.second;
}
}
return ret;
}
template<class T>
......
......@@ -300,7 +300,7 @@ void TrackingRos::ThreadTrackingProcess()
m_tracker.Run(input, detectionsId, updateId, lostId);
uint64_t rTime = GetCurTime() - begin;
//SDK_LOG(SDK_INFO, "m_tracker.Run time = %llu", rTime);
std::map<uint64_t, std::shared_ptr<Track3D> >& trackers = m_tracker.GetStates();
std::map<uint64_t, std::shared_ptr<Track3D> > trackers = m_tracker.GetStates();
static int count = 0;
static int calcCount = 0;
count++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment