Building a Zero-Copy Dual-Vision System on RK3576 with DMA-BUF
2026-07-14
21
Walk through the engineering path from working prototype to automotive-grade, production-ready latency.
I. The Problem: Why a Traditional OpenCV Pipeline Falls Short
During the initial validation phase of our 360° surround view system, we relied on a straightforward, battle-tested stack: OpenCV handling everything from frame capture to display. Functionally, it worked — four-channel fisheye undistortion, perspective projection, and bird's-eye stitching all produced correct results. But the moment we shifted the question from "does it run?" to "is it actually usable?", a hard reality surfaced: end-to-end latency sat at roughly 300 ms, nearly eight times the 40 ms frame budget demanded by 25 fps.
A thorough profiling session revealed that the bottleneck had nothing to do with algorithmic complexity. The RK3576's quad Cortex-A72 cluster had plenty of headroom on raw compute. What was eating the budget was something far more mundane: relentless, unnecessary data movement at every stage of the pipeline. The typical data flow looked like this:

1.1 Trying GPU Acceleration — and Hitting a New Wall
The natural next step was to offload the compute-heavy stages — undistortion, projection, stitching — to the Mali-G52 GPU via OpenCL (cv::UMat). The speedup on the compute side was real and immediate: undistortion dropped from ~10 ms on the CPU to ~1 ms, and projection transformation fell from ~30 ms to ~8 ms. The catch? Explicitly moving data between cv::Mat and cv::UMat cost roughly 15 ms on the upload and another 10 ms on the download — nearly cancelling out every gain the GPU delivered.
1.2 The Core Insight: Compute Isn't the Bottleneck — Data Movement Is
The underlying problem was architectural, not algorithmic. The "allocate independently, copy at every step" paradigm turned data movement into an absolute ceiling. The path forward wasn't a faster algorithm; it was eliminating the copies altogether.
II. The Optimization Strategy: From "It Runs" to "It Ships"
With the root cause clearly identified, the roadmap wrote itself: replace memory copies with DMA-BUF file descriptors (fds), so that V4L2, RGA, the CPU, and DRM all operate on the same physical memory without ever duplicating it. On the display side, bypass the X11 protocol stack entirely and drive output directly through a DRM Overlay Plane — eliminating the last remaining copy on the render path. The goal was simple: every pixel written once, read once, and never touched again.

III. Inside the DMA-BUF Zero-Copy Pipeline
The concept behind DMA-BUF is straightforward: instead of handing data between modules by copying it, you hand them a file descriptor that points to the same underlying physical memory. Each module reads from or writes to that shared buffer in place — no duplication, no extra allocation.

The optimized pipeline collapses to a single DMA-BUF fd chain, with each module operating in place on the same physical memory:
V4L2 MMAP (camera DMA-writes directly to physical memory) → RGA NV12→BGR (hardware blit, source virAddr → target fd, ~3 ms/channel) → CPU undistortion (cv::Mat constructed on the DMA-BUF mmap pointer — zero extra allocation) → CPU stitching (9-grid bird's-eye layout + LUT weight-map blending + car-model overlay, ~8 ms) → RGA fd→fd scaling (hardware DMA, ~2 ms) → drmModeSetPlane (Overlay Plane hardware page-flip, ~0.1 ms)
IV. Replacing X11 with DRM Overlay Plane Direct Display

Dropping cv::imshow in favor of a direct drmModeSetPlane call binds the DMA-BUF fd straight to the Overlay Plane. The display controller scans the buffer on the next VSYNC with no intermediate copies, no X Server round-trips, and no GPU compositor involvement. The submission itself takes roughly 0.1 ms and is fully non-blocking.
V. Measured Performance and Comparative Analysis
All figures below were measured on the MYIR MYD-LR3576 development board under the following conditions: four 720P fisheye cameras, HDMI output at 2560×1440@60 Hz, DMA-BUF pipeline active.
5.1 End-to-End Latency Breakdown
| Stage | Time | Execution Unit | Notes |
|---|---|---|---|
| Sensor Exposure + ISP Pipeline | ~33 ms | Hardware (fixed) | 30 fps capture cycle; hardware ISP latency |
| V4L2 Queue Backlog (4 buffers) | ~17 ms | Kernel Scheduler | Average queuing latency at 4-buffer depth |
| RGA NV12→BGR ×4 | ~3 ms/ch | RGA Hardware | Synchronous hardware DMA blit; four channels serial = ~12 ms total |
| CPU Undistortion (Front/Rear/Left/Right) | 15–22 ms | Cortex-A72 | Output 700×300 / 300×900; four channels run in parallel |
| CPU Stitching + Weight-Map Blending | ~8 ms | Cortex-A72 | 9-zone copy + 4-corner LUT blend + car-model overlay |
| RGA fd→fd Scaling | ~2 ms | RGA Hardware | 700×900 → 1280×1440; bilinear interpolation |
| drmModeSetPlane | ~0.1 ms | Kernel Atomic | Non-blocking atomic commit; hardware scans on next VSYNC |
| Display Scan Output (60 Hz) | ~16 ms | Display Controller (fixed) | One full frame scan period |
| End-to-End Total | ~100 ms | — | Sensor exposure → pixel on screen, full chain |
5.2 Head-to-Head: Three Approaches Compared
| Metric | OpenCV CPU (Serial) | OpenCV + GPU (OpenCL) | DMA-BUF Zero-Copy |
|---|---|---|---|
| Full-Chain Memory Copies | ~5 | ~3 | 0 |
| End-to-End Latency | ~300 ms | ~150 ms | ~100 ms |
| V4L2 Buffer Count | 8 | 4 | 4 |
| GPU↔CPU Data Transfer | Copy at every stage | Upload + Download | None |
| Display Path | X11 imshow | DRM SetCrtc | DRM Overlay Plane |
| Stitching Method | CPU serial Mat copy | GPU OpenCL kernel | CPU DMA-BUF direct read |
VI. DMS — Driver Monitoring System
6.1 System Overview and Architecture
If the 360° surround view gives the vehicle eyes that look outward, the DMS gives it eyes that look inward. Surround view protects the environment around the car; DMS protects the person behind the wheel. Together, they form a complete closed loop for in-vehicle intelligent vision.
On the MYIR MYD-LR3576, the DMS is built on top of the Rockchip DMS SDK, running real-time AI inference on the RK3576's 6 TOPS NPU:
Input: MIPI CSI RGB camera at 1920×1080, mounted in front of the driver's seat and aimed at the driver's face.
Inference Engine: RK3576 on-chip NPU running the packaged DMS model (
rkdms_3576.data, ~4.9 MB), which bundles face detection, facial landmark localization, and attribute analysis into a single model file.Detection Capabilities: Drowsy driving (eye-closure detection), yawning, phone-call detection, and smoking detection.
Alert Output: Categorized local audio playback —
fatigue.wav,yawning.wav,phone.wav,smoking.wav.

6.2 Core Detection Metrics
The DMS SDK surfaces a rich set of facial state indicators. Applications can layer any custom decision logic on top of these raw outputs:
| Detection | Output Metric | What It Measures | Alert Trigger | Use Case |
|---|---|---|---|---|
| Face Localization | Bounding box + landmarks | Real-time tracking of driver face position | Face absent beyond threshold duration | Driver left seat / excessive head turn |
| Eye Closure | EAR (Eye Aspect Ratio) | Lower EAR = more closed eye | EAR < threshold for N consecutive frames | Drowsy driving warning |
| Yawning | MAR (Mouth Aspect Ratio) | Higher MAR = wider open mouth | MAR > threshold for N consecutive frames | Fatigue / attention drop |
| Head Pose | Yaw / Pitch / Roll | Head rotation angles around each axis | Angle deviation exceeds safe envelope | Distracted attention detection |
| Phone Call | phone_call flag | Combined pose + hand-feature inference | Handheld phone behavior detected | Distracted driving alert |
| Metric | Value | Notes |
|---|---|---|
| Camera Interface | MIPI CSI (RGB) | Standard RGB sensor — no IR required |
| Input Resolution | 1920×1080 | Full HD 1080P |
| Model File | rkdms_3576.data (~4.9 MB) | Rockchip DMS SDK packaged model |
| Inference Accelerator | RK3576 NPU (6 TOPS) | NPU-exclusive; zero CPU or GPU load |
| DMS Inference Rate | ~25 FPS | Matches camera frame rate |
| Per-Frame NPU Inference Time | 11–25 ms | Includes face detection + attribute analysis |
| NPU Utilization | ~9% | Single-core NPU: 18% |
| CPU Utilization (DMS process) | ~5% | Single-core: 22% |


VII. Bringing It Together: 360° Surround View + DMS on a Single Screen
7.1 Display Layout
In a real vehicle deployment, both systems need to be visible to the driver simultaneously. We took advantage of the full 2560×1440@60 Hz HDMI resolution and implemented a left-right split-screen layout using the DRM Overlay Plane mechanism:
| Screen Region | Resolution | Content | DRM Mechanism |
|---|---|---|---|
| Left Half | 1280×1440 | 360° Bird's-Eye Surround View | Overlay Plane 162; drmModeSetPlane page-flip |
| Right Half | 1280×1440 | DMS Driver Monitoring Feed | DRM shim intercept layer mapped to a second Overlay Plane |
| Base Layer | 2560×1440 | Desktop / System UI (optional) | Primary Plane; X11 desktop |
7.2 Full System Resource Budget
Running both systems concurrently, the resource utilization across the RK3576's heterogeneous compute units breaks down as follows. The key takeaway is that each workload lands on the right type of processor — CPU+RGA for the data-movement-heavy surround view pipeline, NPU for the inference-heavy DMS — leaving the GPU almost entirely free:
| Resource | 360° Surround View | DMS | Combined |
|---|---|---|---|
| CPU | ~40% | ~5% | ~45% |
| GPU (Mali-G52) | 0% | 0% | 0% |
| RGA | ~45% | ~6% | ~51% |
| NPU (6 TOPS) | 0% | ~8% | ~8% |
| Display Bandwidth | ✅ Left 1280×1440 | ✅ Right 1280×1440 | 2560×1440 @ 60 Hz |
VIII. Key Takeaways
End-to-end latency cut from 300 ms to ~100 ms. Full-chain DMA-BUF zero-copy eliminated five memory moves between capture and display. Unlike the GPU approach, which introduced timing jitter, the DMA-BUF pipeline is deterministic and fully reproducible.
Two vision systems, one screen, one board. The 360° surround view and DMS run as independent processes in a left-right split-screen layout on a single 2560×1440 display. Process isolation keeps the architecture modular and fault-tolerant.
Heterogeneous compute working as designed. Surround view runs on CPU+RGA; DMS runs on NPU; GPU sits nearly idle. Each workload is matched to the right accelerator — exactly what the RK3576's heterogeneous architecture was built for.
On embedded platforms, compute is rarely the bottleneck in real-time vision pipelines — data movement is. GPUs can accelerate computation, but they cannot eliminate the transfer overhead between GPU and CPU memory; in some cases they make it worse. The shift from "use a faster compute unit" to "stop moving data unnecessarily" is what unlocked the performance gains described here. DMA-BUF and DRM Overlay Plane are the Linux kernel's purpose-built infrastructure for exactly this class of problem. Used correctly, they make it entirely feasible to build automotive-grade, real-time intelligent vision systems on an embedded SoC like the RK3576.
Get Started with MYD-LR3576
2026-05-19
When 6 TOPS Is No Longer the Limit: RK3576 + Hailo-8 Achieves True Real-Time Processing for High-Frame-Rate Cameras
Beyond 6 TOPS: RK3576 + Hailo-8 Delivers True Real-Time for High-FPS Cameras
2025-11-27
SECC GreenPHY Solution: Bridging STM32MP135 SOM to V2G Industry Advancement
Debug MSE102x G on MYC-YF13X, providing reference for V2G communication development.
2025-11-20
SECC Solution for Charging Pile Applications
MYIR's SECC solution delivers a high-standard, low-risk rapid development platform for clients, with core strengths in protocol compatibility, operational security, and a comprehensive reference design.
2025-11-02
Simultaneous Control of 4 YOLOv8 Video Streams via MYIR's RK3576 Board
In the era of rapid technological advancement, the integration of artificial intelligence and edge computing is transforming our lives at an unprecedented pace. The RK3576 processor features a quad-co
2025-09-20
Compiling OpenCV and Developing Applications on the RK3576 Board
This article introduces how to compile OpenCV on the RK3576 development board and build an application.
2025-08-30
MYIR T536 Development Board: Multi-protocol IoT Gateway Solution Test
The article details the development and testing of a multi-protocol IoT gateway solution that utilizes MYIR's MYD-LT536 development board, which is based on the Allwinner T536 SoC.
2025-08-29
MYIR RK3576 Development Board: 12-Channel 1080p HD Video Streaming
MYIR has successfully achieved efficient H.264 encoding and low-latency RTSP streaming for 12-channel HD video streams on the Rockchip RK3576 SOM.
2025-08-07
Compiling Kernel for MYD-LMX9X Development Board
This guide walks you through building a Linux kernel for the MYIR MYD-LMX9X Development Board
2025-06-23
RZ/G2L-Based MYD-YG2LX System Startup Time Optimization Application Notes
This article introduces a debugging case for optimizing system boot time based on the MYD-YG2LX development board.