Commit e9997606 authored by oscar's avatar oscar

提交bug更新,处理size==0的时候的问题

parent 160e2ec6
......@@ -494,107 +494,113 @@ void BaseTracker<T>::AssociateDetectionsToTrackersEx(const std::vector<std::vect
}
return;
}
if (dets_high.size() > 0)
{
std::vector<std::vector<float>> iou_matrix_high;
// resize IOU matrix based on number of detection and tracks
iou_matrix_high.resize(dets_high.size(), std::vector<float>(tracks.size()));
std::vector<std::vector<float>> iou_matrix_high;
// resize IOU matrix based on number of detection and tracks
iou_matrix_high.resize(dets_high.size(), std::vector<float>(tracks.size()));
std::vector<std::vector<float>> association_high;
// resize association matrix based on number of detection and tracks
association_high.resize(dets_high.size(), std::vector<float>(tracks.size()));
std::vector<std::vector<float>> association_high;
// resize association matrix based on number of detection and tracks
association_high.resize(dets_high.size(), std::vector<float>(tracks.size()));
for (size_t i = 0; i < dets_high.size(); i++)
{
size_t j = 0;
for (const auto& trk : tracks)
for (size_t i = 0; i < dets_high.size(); i++)
{
iou_matrix_high[i][j] = trk.second->CalculateIou(dets_high[i]);
j++;
size_t j = 0;
for (const auto& trk : tracks)
{
iou_matrix_high[i][j] = trk.second->CalculateIou(dets_high[i]);
j++;
}
}
}
// Find association
//std::string str = GetMatrixStr(iou_matrix, detections.size(), tracks.size());
//SDK_LOG(SDK_INFO, "iou_matrix = [%s]",str.c_str());
HungarianMatching(iou_matrix_high, dets_high.size(), tracks.size(), association_high);
// Find association
//std::string str = GetMatrixStr(iou_matrix, detections.size(), tracks.size());
//SDK_LOG(SDK_INFO, "iou_matrix = [%s]",str.c_str());
HungarianMatching(iou_matrix_high, dets_high.size(), tracks.size(), association_high);
for (size_t i = 0; i < dets_high.size(); i++)
{
bool matched_flag = false;
size_t j = 0;
for (auto& trk : tracks)
for (size_t i = 0; i < dets_high.size(); i++)
{
if (0 == association_high[i][j])
bool matched_flag = false;
size_t j = 0;
for (auto& trk : tracks)
{
// Filter out matched with low IOU
//SDK_LOG(SDK_INFO, "match info i = %d,j = %d, iou_matrix = %f, m_iou_threshold = %f",i,j, iou_matrix[i][j], trk.second->m_iou_threshold);
if (iou_matrix_high[i][j] >= trk.second->m_iou_threshold)
if (0 == association_high[i][j])
{
high_matched[trk.first] = i;
trk.second->m_prob = iou_matrix_high[i][j];
matched_flag = true;
// Filter out matched with low IOU
//SDK_LOG(SDK_INFO, "match info i = %d,j = %d, iou_matrix = %f, m_iou_threshold = %f",i,j, iou_matrix[i][j], trk.second->m_iou_threshold);
if (iou_matrix_high[i][j] >= trk.second->m_iou_threshold)
{
high_matched[trk.first] = i;
trk.second->m_prob = iou_matrix_high[i][j];
matched_flag = true;
}
// It builds 1 to 1 association, so we can break from here
break;
}
// It builds 1 to 1 association, so we can break from here
break;
j++;
}
// if detection cannot match with any tracks
if (!matched_flag) {
unmatched_det.push_back(i);
}
j++;
}
// if detection cannot match with any tracks
if (!matched_flag) {
unmatched_det.push_back(i);
}
}
std::vector<std::vector<float>> iou_matrix_low;
// resize IOU matrix based on number of detection and tracks
iou_matrix_low.resize(dets_low.size(), std::vector<float>(tracks.size() - high_matched.size()));
if (dets_low.size() > 0 && tracks.size() - high_matched.size() > 0)
{
std::vector<std::vector<float>> iou_matrix_low;
// resize IOU matrix based on number of detection and tracks
iou_matrix_low.resize(dets_low.size(), std::vector<float>(tracks.size() - high_matched.size()));
std::vector<std::vector<float>> association_low;
// resize association matrix based on number of detection and tracks
association_low.resize(dets_low.size(), std::vector<float>(tracks.size() - high_matched.size()));
std::vector<std::vector<float>> association_low;
// resize association matrix based on number of detection and tracks
association_low.resize(dets_low.size(), std::vector<float>(tracks.size() - high_matched.size()));
for (size_t i = 0; i < dets_low.size(); i++)
{
size_t j = 0;
for (const auto& trk : tracks)
for (size_t i = 0; i < dets_low.size(); i++)
{
if (high_matched.find(trk.first) == high_matched.end())
size_t j = 0;
for (const auto& trk : tracks)
{
iou_matrix_low[i][j] = trk.second->CalculateIou(dets_low[i]);
j++;
if (high_matched.find(trk.first) == high_matched.end())
{
iou_matrix_low[i][j] = trk.second->CalculateIou(dets_low[i]);
j++;
}
}
}
}
// Find association
//std::string str = GetMatrixStr(iou_matrix, detections.size(), tracks.size());
//SDK_LOG(SDK_INFO, "iou_matrix = [%s]",str.c_str());
HungarianMatching(iou_matrix_low, dets_low.size(), tracks.size() - high_matched.size(), association_low);
// Find association
//std::string str = GetMatrixStr(iou_matrix, detections.size(), tracks.size());
//SDK_LOG(SDK_INFO, "iou_matrix = [%s]",str.c_str());
HungarianMatching(iou_matrix_low, dets_low.size(), tracks.size() - high_matched.size(), association_low);
for (size_t i = 0; i < dets_low.size(); i++)
{
bool matched_flag = false;
size_t j = 0;
for (auto& trk : tracks)
for (size_t i = 0; i < dets_low.size(); i++)
{
if (high_matched.find(trk.first) == high_matched.end())
bool matched_flag = false;
size_t j = 0;
for (auto& trk : tracks)
{
if (0 == association_low[i][j])
if (high_matched.find(trk.first) == high_matched.end())
{
// Filter out matched with low IOU
//SDK_LOG(SDK_INFO, "match info i = %d,j = %d, iou_matrix = %f, m_iou_threshold = %f",i,j, iou_matrix[i][j], trk.second->m_iou_threshold);
if (iou_matrix_low[i][j] >= trk.second->m_iou_threshold)
if (0 == association_low[i][j])
{
low_matched[trk.first] = i;
trk.second->m_prob = iou_matrix_high[i][j];
matched_flag = true;
// Filter out matched with low IOU
//SDK_LOG(SDK_INFO, "match info i = %d,j = %d, iou_matrix = %f, m_iou_threshold = %f",i,j, iou_matrix[i][j], trk.second->m_iou_threshold);
if (iou_matrix_low[i][j] >= trk.second->m_iou_threshold)
{
low_matched[trk.first] = i;
trk.second->m_prob = iou_matrix_low[i][j];
matched_flag = true;
}
// It builds 1 to 1 association, so we can break from here
break;
}
// It builds 1 to 1 association, so we can break from here
break;
j++;
}
j++;
}
}
}
}
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