From 2dd9b35b82b85e65309dca71b6c9655c53c34ce4 Mon Sep 17 00:00:00 2001 From: sladro Date: Wed, 7 Jan 2026 19:11:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=BA=E8=84=B8=E7=94=BB?= =?UTF-8?q?=E6=A1=86,xin2,=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=94=BB=E6=A1=86?= =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AF=86=E5=88=AB=E7=BB=93=E6=9E=9C=EF=BC=8C?= =?UTF-8?q?=E5=90=8E=E9=9D=A2=E8=A6=81=E5=85=B3=E9=97=AD3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/ai_face_det/ai_face_det_node.cpp | 13 +++++++++++++ plugins/ai_face_recog/ai_face_recog_node.cpp | 13 +++++++++++++ plugins/ai_yolo/ai_yolo_node.cpp | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/plugins/ai_face_det/ai_face_det_node.cpp b/plugins/ai_face_det/ai_face_det_node.cpp index 684ce12..e93c327 100644 --- a/plugins/ai_face_det/ai_face_det_node.cpp +++ b/plugins/ai_face_det/ai_face_det_node.cpp @@ -14,6 +14,7 @@ #include "ai_scheduler.h" #include "face/face_result.h" #include "node.h" +#include "utils/dma_alloc.h" #include "utils/logger.h" namespace rk3588 { @@ -515,6 +516,18 @@ private: #if defined(RK3588_ENABLE_RKNN) void Run(FramePtr frame) { if (!frame->data || frame->data_size == 0) return; + + struct ScopedDmaCpuAccess { + int fd = -1; + bool active = false; + explicit ScopedDmaCpuAccess(int f) : fd(f), active(f >= 0) { + if (active) DmaSyncStartFd(fd); + } + ~ScopedDmaCpuAccess() { + if (active) DmaSyncEndFd(fd); + } + } sync(frame->dma_fd); + if (frame->format != PixelFormat::RGB && frame->format != PixelFormat::BGR) { std::cerr << "[ai_face_det] input must be RGB/BGR\n"; return; diff --git a/plugins/ai_face_recog/ai_face_recog_node.cpp b/plugins/ai_face_recog/ai_face_recog_node.cpp index 1c20833..7056c56 100644 --- a/plugins/ai_face_recog/ai_face_recog_node.cpp +++ b/plugins/ai_face_recog/ai_face_recog_node.cpp @@ -15,6 +15,7 @@ #include "ai_scheduler.h" #include "face/face_result.h" #include "node.h" +#include "utils/dma_alloc.h" #include "utils/logger.h" #if defined(RK3588_ENABLE_SQLITE3) @@ -776,6 +777,18 @@ private: void Run(FramePtr frame) { if (!frame->face_det || frame->face_det->faces.empty()) return; if (!frame->data || frame->data_size == 0) return; + + struct ScopedDmaCpuAccess { + int fd = -1; + bool active = false; + explicit ScopedDmaCpuAccess(int f) : fd(f), active(f >= 0) { + if (active) DmaSyncStartFd(fd); + } + ~ScopedDmaCpuAccess() { + if (active) DmaSyncEndFd(fd); + } + } sync(frame->dma_fd); + if (frame->format != PixelFormat::RGB && frame->format != PixelFormat::BGR) { std::cerr << "[ai_face_recog] input must be RGB/BGR\n"; return; diff --git a/plugins/ai_yolo/ai_yolo_node.cpp b/plugins/ai_yolo/ai_yolo_node.cpp index fb0871b..ac726be 100644 --- a/plugins/ai_yolo/ai_yolo_node.cpp +++ b/plugins/ai_yolo/ai_yolo_node.cpp @@ -11,6 +11,7 @@ #include "ai_scheduler.h" #include "node.h" +#include "utils/dma_alloc.h" #include "utils/logger.h" #if defined(RK3588_ENABLE_RKNN) @@ -407,6 +408,17 @@ private: void RunInference(FramePtr frame) { if (!frame->data || frame->data_size == 0) return; + struct ScopedDmaCpuAccess { + int fd = -1; + bool active = false; + explicit ScopedDmaCpuAccess(int f) : fd(f), active(f >= 0) { + if (active) DmaSyncStartFd(fd); + } + ~ScopedDmaCpuAccess() { + if (active) DmaSyncEndFd(fd); + } + } sync(frame->dma_fd); + bool is_rgb = (frame->format == PixelFormat::RGB || frame->format == PixelFormat::BGR); if (!is_rgb) { std::cerr << "[ai_yolo] input must be RGB/BGR, got other format\n";