|
@@ -3,7 +3,7 @@
|
|
namespace GNode
|
|
namespace GNode
|
|
{
|
|
{
|
|
|
|
|
|
-const float IOU_THRESHOLD = 0.9; // 可调阈值
|
|
|
|
|
|
+const float IOU_THRESHOLD = 0.7; // 可调阈值
|
|
|
|
|
|
float calculate_iou(const std::vector<float>& tlwh, const data::Box& box) {
|
|
float calculate_iou(const std::vector<float>& tlwh, const data::Box& box) {
|
|
float track_x1 = tlwh[0];
|
|
float track_x1 = tlwh[0];
|
|
@@ -59,14 +59,16 @@ void TrackNode::work()
|
|
}
|
|
}
|
|
std::vector<Object> objects;
|
|
std::vector<Object> objects;
|
|
std::transform(metaData->boxes.begin(), metaData->boxes.end(), std::back_inserter(objects), [](data::Box& box) {
|
|
std::transform(metaData->boxes.begin(), metaData->boxes.end(), std::back_inserter(objects), [](data::Box& box) {
|
|
- Object obj;
|
|
|
|
- obj.rect.x = box.left;
|
|
|
|
- obj.rect.y = box.top;
|
|
|
|
- obj.rect.width = box.right - box.left;
|
|
|
|
- obj.rect.height = box.bottom - box.top;
|
|
|
|
- obj.label = box.class_id;
|
|
|
|
- obj.prob = box.score;
|
|
|
|
- return obj;
|
|
|
|
|
|
+ if (std::find(track_labels_.begin(), track_labels_.end(), box.label) != track_labels_.end()) {
|
|
|
|
+ Object obj;
|
|
|
|
+ obj.rect.x = box.left;
|
|
|
|
+ obj.rect.y = box.top;
|
|
|
|
+ obj.rect.width = box.right - box.left;
|
|
|
|
+ obj.rect.height = box.bottom - box.top;
|
|
|
|
+ obj.label = box.class_id;
|
|
|
|
+ obj.prob = box.score;
|
|
|
|
+ return obj;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
std::vector<STrack> output_stracks = tracker_->update(objects);
|
|
std::vector<STrack> output_stracks = tracker_->update(objects);
|
|
std::vector<bool> box_matched(metaData->boxes.size(), false); // 标记 box 是否已被匹配
|
|
std::vector<bool> box_matched(metaData->boxes.size(), false); // 标记 box 是否已被匹配
|
|
@@ -93,13 +95,9 @@ void TrackNode::work()
|
|
if (best_match_idx != -1 && max_iou >= IOU_THRESHOLD) {
|
|
if (best_match_idx != -1 && max_iou >= IOU_THRESHOLD) {
|
|
metaData->boxes[best_match_idx].track_id = track_id;
|
|
metaData->boxes[best_match_idx].track_id = track_id;
|
|
box_matched[best_match_idx] = true; // 标记此 box 已匹配
|
|
box_matched[best_match_idx] = true; // 标记此 box 已匹配
|
|
- printf("Track ID %d matched to box %d with IoU %.2f\n", track_id, best_match_idx, max_iou);
|
|
|
|
- } else {
|
|
|
|
- printf("Track ID %d (TLWH: %.1f,%.1f,%.1f,%.1f) could not find a suitable match (max IoU: %.2f)\n",
|
|
|
|
- track_id, tlwh[0], tlwh[1], tlwh[2], tlwh[3], max_iou);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
for (auto& output_buffer : output_buffers_)
|
|
for (auto& output_buffer : output_buffers_)
|
|
{
|
|
{
|
|
// printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
|
|
// printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
|