Add debug ROI overlay for shoe detection

This commit is contained in:
tian 2026-03-14 15:06:26 +08:00
parent fc9cf5546f
commit 29d3d1be9b
2 changed files with 28 additions and 3 deletions

View File

@ -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",

View File

@ -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<int>("person_class_id", dynamic_roi_.person_class_id);
dynamic_roi_.shoe_class_id =
dyn->ValueOr<int>("shoe_class_id", dynamic_roi_.shoe_class_id);
dynamic_roi_.debug_roi_class_id =
dyn->ValueOr<int>("debug_roi_class_id", dynamic_roi_.debug_roi_class_id);
dynamic_roi_.max_rois = std::max(1, dyn->ValueOr<int>("max_rois", dynamic_roi_.max_rois));
dynamic_roi_.min_person_height =
std::max(0, dyn->ValueOr<int>("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<DetWindow>& 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<float>(roi.x),
static_cast<float>(roi.y),
static_cast<float>(roi.w),
static_cast<float>(roi.h)
};
frame->det->items.push_back(item);
}
}
std::vector<DetBox> DetectWindow(FramePtr frame, int src_w, int src_h, const DetWindow& win) {
std::vector<DetBox> dets;