diff --git a/configs/sample_person_shoe_two_stage_balanced.json b/configs/sample_person_shoe_two_stage_balanced.json index 6849a2b..7ef828d 100644 --- a/configs/sample_person_shoe_two_stage_balanced.json +++ b/configs/sample_person_shoe_two_stage_balanced.json @@ -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", diff --git a/plugins/ai_shoe_det/ai_shoe_det_node.cpp b/plugins/ai_shoe_det/ai_shoe_det_node.cpp index 4f6da70..9032fd6 100644 --- a/plugins/ai_shoe_det/ai_shoe_det_node.cpp +++ b/plugins/ai_shoe_det/ai_shoe_det_node.cpp @@ -316,6 +316,11 @@ public: if (infer_interval_ms_ < 1) infer_interval_ms_ = 1; } } + infer_phase_ms_ = std::max( + 0, static_cast(config.ValueOr("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("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(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 windows_; diff --git a/plugins/ai_yolo/ai_yolo_node.cpp b/plugins/ai_yolo/ai_yolo_node.cpp index d1043fa..7ffe0d9 100644 --- a/plugins/ai_yolo/ai_yolo_node.cpp +++ b/plugins/ai_yolo/ai_yolo_node.cpp @@ -691,6 +691,10 @@ public: if (infer_interval_ms_ < 1) infer_interval_ms_ = 1; } } + infer_phase_ms_ = std::max(0, static_cast(config.ValueOr("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("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(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)