Commit 2ba49cd5 authored by oscar's avatar oscar

提交计算iou时加入type类型检查

parent a3b94d41
......@@ -103,7 +103,7 @@ bool BaseTrack::IsValid()
{
return m_update_count >= m_updateValidCount;
}
int BaseTrack::GetMeasureData(std::vector<float>& data)
int BaseTrack::GetIouData(std::vector<float>& data, int obj_type)
{
if (kf_ == nullptr || m_num_obs > m_num_states)
return -1;
......
......@@ -30,7 +30,7 @@ public:
virtual bool IsLost();//数据是否丢失,如果不更新就会丢失
virtual bool IsValid();//数据是否有效
virtual int GetMeasureData(std::vector<float>& data);
virtual int GetIouData(std::vector<float>& data,int obj_type);
virtual int GetIouDataOrder(std::vector<int>& order) = 0;
virtual int GetKFDataOrder(std::vector<int>& order) = 0;
......
......@@ -238,11 +238,12 @@ void BaseTracker<T>::AssociateDetectionsToTrackers(const std::vector<std::vector
else
{
std::vector<std::vector<float> > tracker_states;
std::vector<int> iouOrder;
std::vector<int> tracker_type;
for (auto& iter : tracks)
{
std::vector<float> measure;
if (iter.second->GetMeasureData(measure) == 0)
int obj_type = 0;
if (iter.second->GetIouData(measure,obj_type) == 0)
{
tracker_states.emplace_back(measure);
}
......@@ -250,14 +251,11 @@ void BaseTracker<T>::AssociateDetectionsToTrackers(const std::vector<std::vector
{
SDK_LOG(SDK_INFO, "GetMeasureData failed");
}
if (iouOrder.empty())
{
iter.second->GetIouDataOrder(iouOrder);
}
tracker_type.push_back(obj_type);
}
int measure_size = _no;
int tra_size = tracker_states.size() > 0 ? tracker_states[0].size() : 0;
if (measure_size == 0 || measure_size != tra_size)
if (tra_size == 0 || measure_size != tra_size)
return;
int detect_size = detections.size() * measure_size;
int tracker_size = tracker_states.size() * tra_size;
......@@ -276,17 +274,12 @@ void BaseTracker<T>::AssociateDetectionsToTrackers(const std::vector<std::vector
detect_ptr.get()[i * measure_size + j] = out[j];
}
det_type.push_back(ob_type);
//for (int j = 0; j < measure_size; j++)
//{
// detect_ptr.get()[i * measure_size + j] = detections[i][iouOrder[j]];
//}
}
for (int i = 0; i < tracker_states.size(); i++)
{
for (int j = 0; j < tra_size; j++)
{
tracker_ptr.get()[i * tra_size + j] = tracker_states[i][iouOrder[j]];
tracker_ptr.get()[i * tra_size + j] = tracker_states[i][j];
}
}
//std::string dete_str = GetMatrixStr(detect_ptr.get(), measure_size, detections.size());
......@@ -301,7 +294,14 @@ void BaseTracker<T>::AssociateDetectionsToTrackers(const std::vector<std::vector
for (int j = 0; j < tracker_states.size(); j++)
{
float* i_ptr = iou_ptr.get();
iou_matrix[i][j] = i_ptr[i * tracker_states.size() + j];
if (det_type[i] == tracker_type[j])
{
iou_matrix[i][j] = i_ptr[i * tracker_states.size() + j];
}
else
{
iou_matrix[i][j] = 0.0f;
}
}
}
......
......@@ -355,6 +355,24 @@ void Track3D::SetValues(std::vector<float>& data)
0, 0, 0, 0, 0, 0, 1;
}
int Track3D::GetIouData(std::vector<float>& data, int obj_type)
{
if (m_obj == nullptr || kf_ == nullptr)
{
return -1;
}
data.clear();
data.push_back(kf_->x[0]);
data.push_back(kf_->x[1]);
data.push_back(kf_->x[2]);
data.push_back(kf_->x[4]);
data.push_back(kf_->x[5]);
data.push_back(kf_->x[6]);
data.push_back(kf_->x[3]);
obj_type = m_obj->type;
return 0;
}
void Track3D::MeasureData(const std::vector<float>& input, std::vector<float>& out, int& obj_type)
{
......
......@@ -45,6 +45,7 @@ public:
virtual void SetValues(std::vector<float>& data);
virtual int GetIouData(std::vector<float>& data, int obj_type);
static void MeasureData(const std::vector<float>& input, std::vector<float>& out, int& obj_type);
trackOjbPtr m_obj = nullptr;
......
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