Commit 15c26ddb authored by oscar's avatar oscar

提交更新

parent a35433a0
......@@ -34,6 +34,7 @@ public:
void SetValues(std::vector<float>& values) { m_values = values; }
int Run(const std::vector<std::vector<float> >& detections, int _no/*观测数量*/, int _ns/*状态数量*/, std::vector<uint64_t>& detectionsId, std::map<uint64_t, int>& updateId, std::vector<uint64_t>& lostId);
int Run(const std::vector<std::vector<float> >& detections, int _no/*观测数量*/, int _ns/*状态数量*/, std::vector<uint64_t>& detectionsId, std::map<uint64_t, int>& updateId, std::map<uint64_t, int>& addId,std::vector<uint64_t>& lostId);
int Run(const std::vector<std::vector<float> >& dets_high, const std::vector<std::vector<float> >& dets_low, int _no/*观测数量*/, int _ns/*状态数量*/, std::map<uint64_t, int>& update_high_ids, std::map<uint64_t, int>& update_low_ids, std::vector<uint64_t>& lostId);
......@@ -601,6 +602,85 @@ void BaseTracker<T>::AssociateDetectionsToTrackersEx(const std::vector<std::vect
}
}
}
}
template<class T>
int BaseTracker<T>::Run(const std::vector<std::vector<float> >& detections, int _no/*观测数量*/, int _ns/*状态数量*/, std::vector<uint64_t>& detectionsId, std::map<uint64_t, int>& updateId, std::map<uint64_t, int>& addId,std::vector<uint64_t>& lostId)
{
/*** Predict internal tracks from previous frame ***/
for (auto& track : m_tracker)
{
track.second->Predict();
}
if (detections.empty())
{
/*** Delete lose tracked tracks ***/
for (auto it = m_tracker.begin(); it != m_tracker.end();)
{
if (it->second->IsLost())
{
lostId.push_back(it->first);
it = m_tracker.erase(it);
}
else
{
it++;
}
}
return 0;
}
detectionsId.resize(detections.size());
// Hash-map between track ID and associated detection bounding box
std::map<uint64_t, int> matched;
// vector of unassociated detections
std::vector<int> unmatched_det;
// return values - matched, unmatched_det
AssociateDetectionsToTrackers(detections,_no,_ns, m_tracker, matched, unmatched_det);
/*** Update tracks with associated bbox ***/
if (m_isGPU == 0)
{
for (const auto& match : matched)
{
const auto& id = match.first;
m_tracker[id]->Update(detections[match.second]);
detectionsId[match.second] = id;
updateId[id] = match.second;
}
}
else
{
}
/*** Create new tracks for unmatched detections ***/
for (const auto& det : unmatched_det)
{
std::shared_ptr<T> trackPtr = std::make_shared<T>();
trackPtr->Init(detections[det]);
trackPtr->SetIouThreshold(m_iou_threshold);
trackPtr->SetMaxCoastCycles(m_kMaxCoastCycles);
trackPtr->SetValidUpdateCount(m_updateValidCount);
trackPtr->SetValues(m_values);
// Create new track and generate new ID
uint64_t newId = ++m_countId;
m_tracker[newId] = trackPtr;
detectionsId[det] = newId;
updateId[newId] = det;
addId[newId] = det;
}
/*** Delete lose tracked tracks ***/
for (auto it = m_tracker.begin(); it != m_tracker.end();)
{
if (it->second->IsLost())
{
lostId.push_back(it->first);
it = m_tracker.erase(it);
}
else
{
it++;
}
}
return 0;
}
This diff is collapsed.
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