diff --git a/plugins/ai_shoe_det/ai_shoe_det_node.cpp b/plugins/ai_shoe_det/ai_shoe_det_node.cpp index 964f208..ef21a5c 100644 --- a/plugins/ai_shoe_det/ai_shoe_det_node.cpp +++ b/plugins/ai_shoe_det/ai_shoe_det_node.cpp @@ -571,6 +571,8 @@ private: const uint8_t* model_input_data = nullptr; size_t model_input_size = 0; + int model_input_dma_fd = -1; + Frame resized_frame; if (image_processor_ && win_w > 0 && win_h > 0) { Frame crop_frame; @@ -583,7 +585,6 @@ private: crop_frame.plane_count = 1; crop_frame.planes[0] = {crop_buf.data(), crop_frame.stride, static_cast(crop_buf.size()), 0}; - Frame resized_frame; resized_frame.width = model_w_; resized_frame.height = model_h_; resized_frame.format = PixelFormat::RGB; @@ -595,7 +596,11 @@ 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_data && resized_stride > 0) { + if (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(); + } else if (resized_data && resized_stride > 0) { if (packed_size > input_buf_.size()) input_buf_.resize(packed_size); for (int row = 0; row < model_h_; ++row) { memcpy(input_buf_.data() + static_cast(row) * static_cast(model_w_) * 3, @@ -622,6 +627,7 @@ private: input.is_nhwc = true; input.data = model_input_data; input.size = model_input_size; + input.dma_fd = model_input_dma_fd; input.type = RKNN_TENSOR_UINT8; auto r = infer_backend_->InferBorrowed(model_handle_, input); diff --git a/plugins/ai_yolo/ai_yolo_node.cpp b/plugins/ai_yolo/ai_yolo_node.cpp index 5ac7017..f7b05d6 100644 --- a/plugins/ai_yolo/ai_yolo_node.cpp +++ b/plugins/ai_yolo/ai_yolo_node.cpp @@ -900,6 +900,7 @@ private: const size_t input_row = static_cast(model_input_w_) * 3; const size_t input_size = input_row * static_cast(model_input_h_); resized_input_.resize(input_size); + Frame resized_frame; if (exact_model_input) { for (int y = 0; y < h; ++y) { @@ -918,7 +919,6 @@ private: src_frame.plane_count = 1; src_frame.planes[0] = {src_frame.data, src_stride, static_cast(frame->data_size), 0}; - Frame resized_frame; resized_frame.width = model_input_w_; resized_frame.height = model_input_h_; resized_frame.format = PixelFormat::RGB; @@ -929,7 +929,14 @@ 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_data && resized_stride > 0) { + if (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_; + input.height = model_input_h_; + input.dma_fd = resized_frame.DmaFd(); + input.dma_offset = 0; + } else if (resized_data && resized_stride > 0) { for (int y = 0; y < model_input_h_; ++y) { memcpy(resized_input_.data() + static_cast(y) * input_row, resized_data + static_cast(y) * static_cast(resized_stride),