From 53afc006c33386d1d05bcf476b89ab5fa147fdb7 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sun, 15 Mar 2026 01:49:06 +0800 Subject: [PATCH] Make DMA input optional per detector --- configs/sample_person_shoe_two_stage_balanced.json | 2 ++ plugins/ai_shoe_det/ai_shoe_det_node.cpp | 4 +++- plugins/ai_yolo/ai_yolo_node.cpp | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configs/sample_person_shoe_two_stage_balanced.json b/configs/sample_person_shoe_two_stage_balanced.json index 7ef828d..6977bf5 100644 --- a/configs/sample_person_shoe_two_stage_balanced.json +++ b/configs/sample_person_shoe_two_stage_balanced.json @@ -42,6 +42,7 @@ "rga_gate": "person_shoe_two_stage_balanced", "rga_max_inflight": 4, "dst_packed": true, + "use_dma_input": true, "infer_fps": 2, "infer_phase_ms": 0, "model_path": "./models/yolov8n-640.rknn", @@ -86,6 +87,7 @@ "rga_gate": "person_shoe_two_stage_balanced", "rga_max_inflight": 4, "dst_packed": true, + "use_dma_input": false, "infer_fps": 2, "infer_phase_ms": 250, "model_path": "./models/shoe_detector_openimages_ppe_v1.rknn", diff --git a/plugins/ai_shoe_det/ai_shoe_det_node.cpp b/plugins/ai_shoe_det/ai_shoe_det_node.cpp index 9032fd6..8541afc 100644 --- a/plugins/ai_shoe_det/ai_shoe_det_node.cpp +++ b/plugins/ai_shoe_det/ai_shoe_det_node.cpp @@ -321,6 +321,7 @@ public: if (infer_interval_ms_ > 0 && infer_phase_ms_ >= infer_interval_ms_) { infer_phase_ms_ %= infer_interval_ms_; } + use_dma_input_ = config.ValueOr("use_dma_input", use_dma_input_); if (const SimpleJson* dyn = config.Find("dynamic_roi"); dyn && dyn->IsObject()) { dynamic_roi_.enable = dyn->ValueOr("enable", false); @@ -597,7 +598,7 @@ private: ? resized_frame.planes[0].stride : (resized_frame.stride > 0 ? resized_frame.stride : model_w_ * 3); const size_t packed_size = static_cast(model_w_) * static_cast(model_h_) * 3; - if (resized_frame.DmaFd() >= 0 && resized_data) { + if (use_dma_input_ && resized_frame.DmaFd() >= 0 && resized_data) { model_input_data = resized_data; model_input_size = resized_frame.data_size > 0 ? resized_frame.data_size : packed_size; model_input_dma_fd = resized_frame.DmaFd(); @@ -816,6 +817,7 @@ private: int64_t infer_interval_ms_ = 0; int64_t infer_phase_ms_ = 0; int64_t last_infer_pts_ms_ = 0; + bool use_dma_input_ = true; DynamicRoiConfig dynamic_roi_; std::vector windows_; std::vector input_buf_; diff --git a/plugins/ai_yolo/ai_yolo_node.cpp b/plugins/ai_yolo/ai_yolo_node.cpp index 7ffe0d9..8d2b942 100644 --- a/plugins/ai_yolo/ai_yolo_node.cpp +++ b/plugins/ai_yolo/ai_yolo_node.cpp @@ -695,6 +695,7 @@ public: if (infer_interval_ms_ > 0 && infer_phase_ms_ >= infer_interval_ms_) { infer_phase_ms_ %= infer_interval_ms_; } + use_dma_input_ = config.ValueOr("use_dma_input", use_dma_input_); std::string ver = config.ValueOr("model_version", "auto"); if (ver == "v5") { @@ -934,7 +935,7 @@ private: const int resized_stride = resized_frame.planes[0].stride > 0 ? resized_frame.planes[0].stride : (resized_frame.stride > 0 ? resized_frame.stride : static_cast(input_row)); - if (resized_frame.DmaFd() >= 0 && resized_data) { + if (use_dma_input_ && resized_frame.DmaFd() >= 0 && resized_data) { input.data = resized_data; input.size = resized_frame.data_size > 0 ? resized_frame.data_size : input_size; input.width = model_input_w_; @@ -1334,6 +1335,7 @@ private: int64_t infer_interval_ms_ = 0; int64_t infer_phase_ms_ = 0; int64_t last_infer_pts_ms_ = 0; + bool use_dma_input_ = true; #if defined(RK3588_ENABLE_RKNN) ModelHandle model_handle_ = kInvalidModelHandle;