From 29d3d1be9bde09df44e757f0fb3b94ed7039eead Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sat, 14 Mar 2026 15:06:26 +0800 Subject: [PATCH] Add debug ROI overlay for shoe detection --- configs/sample_person_shoe_two_stage.json | 7 ++++--- plugins/ai_shoe_det/ai_shoe_det_node.cpp | 24 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/configs/sample_person_shoe_two_stage.json b/configs/sample_person_shoe_two_stage.json index 773b4df..a11a765 100644 --- a/configs/sample_person_shoe_two_stage.json +++ b/configs/sample_person_shoe_two_stage.json @@ -78,13 +78,14 @@ "model_path": "./models/shoe_detector_openimages_ppe_v1.rknn", "model_w": 640, "model_h": 640, - "conf": 0.45, + "conf": 0.25, "nms": 0.45, "append_detections": true, "dynamic_roi": { "enable": true, "person_class_id": 0, "shoe_class_id": 1, + "debug_roi_class_id": 2, "max_rois": 2, "min_person_height": 120, "x_offset": -0.20, @@ -99,9 +100,9 @@ "role": "filter", "enable": true, "draw_bbox": true, - "draw_text": false, + "draw_text": true, "use_rga_bbox": false, - "labels": ["person", "shoe"] + "labels": ["person", "shoe", "foot_roi"] }, { "id": "post", diff --git a/plugins/ai_shoe_det/ai_shoe_det_node.cpp b/plugins/ai_shoe_det/ai_shoe_det_node.cpp index fb67a1f..159eb6b 100644 --- a/plugins/ai_shoe_det/ai_shoe_det_node.cpp +++ b/plugins/ai_shoe_det/ai_shoe_det_node.cpp @@ -39,6 +39,7 @@ struct DynamicRoiConfig { bool enable = false; int person_class_id = 0; int shoe_class_id = 0; + int debug_roi_class_id = -1; int max_rois = 8; int min_person_height = 0; float x_offset = -0.15f; @@ -299,6 +300,8 @@ public: dyn->ValueOr("person_class_id", dynamic_roi_.person_class_id); dynamic_roi_.shoe_class_id = dyn->ValueOr("shoe_class_id", dynamic_roi_.shoe_class_id); + dynamic_roi_.debug_roi_class_id = + dyn->ValueOr("debug_roi_class_id", dynamic_roi_.debug_roi_class_id); dynamic_roi_.max_rois = std::max(1, dyn->ValueOr("max_rois", dynamic_roi_.max_rois)); dynamic_roi_.min_person_height = std::max(0, dyn->ValueOr("min_person_height", dynamic_roi_.min_person_height)); @@ -436,6 +439,10 @@ private: frame->det->img_w = src_w; frame->det->img_h = src_h; + if (dynamic_roi_.enable && dynamic_roi_.debug_roi_class_id >= 0) { + AddDebugRoiDetections(frame, active_windows); + } + for (const auto& d : all_dets) { Detection item; item.bbox = {d.x, d.y, d.w, d.h}; @@ -485,6 +492,23 @@ private: return rois; } + void AddDebugRoiDetections(FramePtr frame, const std::vector& rois) const { + if (!frame || !frame->det) return; + for (const auto& roi : rois) { + Detection item; + item.cls_id = dynamic_roi_.debug_roi_class_id; + item.score = 1.0f; + item.track_id = -1; + item.bbox = { + static_cast(roi.x), + static_cast(roi.y), + static_cast(roi.w), + static_cast(roi.h) + }; + frame->det->items.push_back(item); + } + } + std::vector DetectWindow(FramePtr frame, int src_w, int src_h, const DetWindow& win) { std::vector dets;