Stagger detector cadence for smoother balanced mode

This commit is contained in:
tian 2026-03-15 01:38:20 +08:00
parent cd42cd0936
commit 938f3760a4
3 changed files with 24 additions and 4 deletions

View File

@ -37,11 +37,13 @@
"type": "ai_yolo",
"role": "filter",
"enable": true,
"cpu_affinity": [4],
"use_rga": true,
"rga_gate": "person_shoe_two_stage_balanced",
"rga_max_inflight": 4,
"dst_packed": true,
"infer_fps": 2,
"infer_phase_ms": 0,
"model_path": "./models/yolov8n-640.rknn",
"model_version": "v8",
"model_w": 640,
@ -64,6 +66,7 @@
"type": "tracker",
"role": "filter",
"enable": true,
"cpu_affinity": [5],
"mode": "bytetrack_lite",
"per_class": true,
"track_classes": [0],
@ -78,11 +81,13 @@
"type": "ai_shoe_det",
"role": "filter",
"enable": true,
"cpu_affinity": [6],
"use_rga": true,
"rga_gate": "person_shoe_two_stage_balanced",
"rga_max_inflight": 4,
"dst_packed": true,
"infer_fps": 2,
"infer_phase_ms": 250,
"model_path": "./models/shoe_detector_openimages_ppe_v1.rknn",
"model_w": 640,
"model_h": 640,
@ -108,6 +113,7 @@
"type": "osd",
"role": "filter",
"enable": true,
"cpu_affinity": [7],
"draw_bbox": true,
"draw_text": false,
"use_rga_bbox": false,
@ -118,6 +124,7 @@
"type": "preprocess",
"role": "filter",
"enable": true,
"cpu_affinity": [7],
"dst_w": 1920,
"dst_h": 1080,
"dst_format": "nv12",

View File

@ -316,6 +316,11 @@ public:
if (infer_interval_ms_ < 1) infer_interval_ms_ = 1;
}
}
infer_phase_ms_ = std::max<int64_t>(
0, static_cast<int64_t>(config.ValueOr<int>("infer_phase_ms", 0)));
if (infer_interval_ms_ > 0 && infer_phase_ms_ >= infer_interval_ms_) {
infer_phase_ms_ %= infer_interval_ms_;
}
if (const SimpleJson* dyn = config.Find("dynamic_roi"); dyn && dyn->IsObject()) {
dynamic_roi_.enable = dyn->ValueOr<bool>("enable", false);
@ -407,12 +412,13 @@ public:
#if defined(RK3588_ENABLE_RKNN)
if (infer_interval_ms_ > 0 && frame->pts > 0) {
const int64_t pts_ms = static_cast<int64_t>(frame->pts / 1000ULL);
const int64_t delta_ms = pts_ms - last_infer_pts_ms_;
const int64_t effective_pts_ms = pts_ms + infer_phase_ms_;
const int64_t delta_ms = effective_pts_ms - last_infer_pts_ms_;
if (last_infer_pts_ms_ > 0 && delta_ms > 0 && delta_ms < infer_interval_ms_) {
Push(frame);
return NodeStatus::OK;
}
last_infer_pts_ms_ = pts_ms;
last_infer_pts_ms_ = effective_pts_ms;
}
RunDetection(frame);
#endif
@ -808,6 +814,7 @@ private:
V8BoxFormat v8_box_format_ = V8BoxFormat::Auto;
V8ClsActivation v8_cls_activation_ = V8ClsActivation::Auto;
int64_t infer_interval_ms_ = 0;
int64_t infer_phase_ms_ = 0;
int64_t last_infer_pts_ms_ = 0;
DynamicRoiConfig dynamic_roi_;
std::vector<DetWindow> windows_;

View File

@ -691,6 +691,10 @@ public:
if (infer_interval_ms_ < 1) infer_interval_ms_ = 1;
}
}
infer_phase_ms_ = std::max<int64_t>(0, static_cast<int64_t>(config.ValueOr<int>("infer_phase_ms", 0)));
if (infer_interval_ms_ > 0 && infer_phase_ms_ >= infer_interval_ms_) {
infer_phase_ms_ %= infer_interval_ms_;
}
std::string ver = config.ValueOr<std::string>("model_version", "auto");
if (ver == "v5") {
@ -793,13 +797,14 @@ public:
if (infer_interval_ms_ > 0 && frame->pts > 0) {
const int64_t pts_ms = static_cast<int64_t>(frame->pts / 1000ULL);
const int64_t delta_ms = pts_ms - last_infer_pts_ms_;
const int64_t effective_pts_ms = pts_ms + infer_phase_ms_;
const int64_t delta_ms = effective_pts_ms - last_infer_pts_ms_;
if (last_infer_pts_ms_ > 0 && delta_ms > 0 && delta_ms < infer_interval_ms_) {
PushToDownstream(frame);
++processed_;
return NodeStatus::OK;
}
last_infer_pts_ms_ = pts_ms;
last_infer_pts_ms_ = effective_pts_ms;
}
#if defined(RK3588_ENABLE_RKNN)
@ -1327,6 +1332,7 @@ private:
BboxExpandConfig bbox_expand_{};
int64_t infer_interval_ms_ = 0;
int64_t infer_phase_ms_ = 0;
int64_t last_infer_pts_ms_ = 0;
#if defined(RK3588_ENABLE_RKNN)