Dual MIPI Camera Integration and AI Inference on a Domestic ARM Platform

    This article presents a practical engineering guide for connecting two MIPI CSI cameras and running real-time AI inference on a domestic ARM development board equipped with an 8-core processor and an NPU delivering roughly 6 TOPS of integer performance. It covers sensor selection, MIPI bandwidth budgeting, power and clock sequencing, device tree configuration, V4L2 dual-stream capture, NPU model conversion and quantization, a multi-threaded inference pipeline, and zero-copy buffer reuse. The article also shares measured frame rates and a troubleshooting order for performance issues, without binding to any specific board model.

    1. Background: Why Dual Cameras Plus Real-Time Inference Are Harder on Domestic Platforms

    When building vision AI on a domestic ARM platform, the first obstacle is usually not model accuracy but getting the data in. Debugging a single camera often takes only a few days to produce images. Once two high-resolution sensors must run simultaneously, problems tend to surface all at once: one stream never starts, timestamps drift between the two streams, the frame rate drops to single digits, or the inference process exhausts memory and gets reclaimed by the system. The root causes are usually spread across four layers: hardware bandwidth, driver timing, memory allocation, and scheduling policy.

    This article uses a domestic development board with an 8-core ARM processor and an NPU delivering about 6 TOPS of integer compute as a reference to discuss a general engineering approach for dual MIPI CSI capture, from acquisition through object detection. No specific model is bound here; the interfaces and parameters mentioned are industry-standard concepts, and actual values should follow the hardware manual of the platform in use.

    2.1 Match Sensors to the Scenario, Not the Spec Sheet

    The value of a dual-camera system lies in complementary viewpoints and levels of detail. A common combination for security inspection, production-line spot checks, and vehicle surround view is one 4K-class sensor for global situational awareness and one sensor around 13 megapixels for mid-range and close-range detail. Three things really need to be verified during selection: the sensor’s maximum frame rate mode for pixel output, whether it supports outputting multiple virtual channels at the same time, and how well the lens matches the sensor’s image plane (to avoid vignetting and distortion beyond what the algorithm can tolerate).

    2.2 Bandwidth Budget: Do the Math Before Wiring

    When two high-resolution streams run at once, total MIPI bandwidth is the first resource to hit the ceiling. A rough formula can estimate the upper bound:

    1. Per-stream bandwidth (Gbps) ≈ pixel clock (MHz) × bits per pixel / lanes × 8 / 1000
    2. System requirement ≈ Σ(per-stream bandwidth) × 1.2 # headroom for edge overhead and blanking intervals

    If the estimate approaches the platform’s MIPI controller limit, the correct move is to lower the frame rate, enable pixel binning, or switch to compressed output, rather than wiring things up first and hoping tuning will save you.

    2.3 Power, Clock, and Reset Are Hidden Failure Sources

    The inrush current when both cameras start is noticeably higher than with a single camera. Insufficient power headroom shows up as “cold start works fine, stream drops after a few minutes of running.” In addition, if the reset and power-down sequences of the two sensors are fully parallel, power-up contention can occur. In practice, the two sensors are usually powered on a few milliseconds apart, and the clock sources are kept as common as possible to make later synchronization easier.

    3. System and Driver Adaptation: Making Both Streams Coexist

    3.1 The Device Tree Is Central to Dual-Camera Configuration

    On ARM Linux, the camera pipeline is described in the device tree: sensor nodes, clock and reset pins, the MIPI receiver controller node, and the mapping of virtual channels to data formats. The most common mistake in a dual-camera setup is having both streams share the same interrupt or the same DMA buffer, which causes one stream to time out continuously. It is recommended to configure a separate receive channel and buffer pool for each stream.

    3.2 Ecosystem Compatibility of Domestic Systems

    Some domestic desktop operating systems have passed official compatibility certification and can run Android applications directly, which lets existing mobile apps migrate at relatively low cost and saves repeated development effort. Note that application compatibility does not mean hardware peripherals become available automatically: peripherals such as cameras and the NPU still need driver and runtime adaptation at the system layer, and this effort should be estimated as an independent subsystem.

    3.3 Capture-Side Sample Code

    Using the generic V4L2 interface as an example, the key to dual capture is to create an independent buffer queue for each device node and to share a unified time base:

    1. /* Pseudocode: dual-stream capture skeleton */
    2. for (int i = 0; i < 2; i++) {
    3. fd[i] = open(dev_path[i], O_RDWR);
    4. set_format(fd[i], WIDTH[i], HEIGHT[i], PIXFMT); /* 4K or 1080P */
    5. request_buffers(fd[i], NBUF);
    6. for (int j = 0; j < NBUF; j++)
    7. queue_buffer(fd[i], j);
    8. start_streaming(fd[i]);
    9. }
    10. /* Main loop: align frames from both streams by timestamp, then feed the inference queue */

    4. NPU Inference Pipeline: From Model to Frame Rate

    4.1 Model Conversion and Operator Compatibility

    The mainstream object detection model families (including single-stage detectors, instance segmentation, pose estimation, and more than a dozen other architectures) can all be deployed on a domestic NPU, but the workflow is the same: export from the training framework to an intermediate format → use the platform’s conversion tool for operator adaptation and quantization calibration → generate a model file loadable on the NPU. For the quantization stage, prepare a calibration set that covers real-world scenarios; otherwise you get “accuracy looks fine offline, but objects are missed in the field.”

    4.2 A Multi-Threaded Pipeline, Not a Serial One

    Chaining capture, preprocessing, inference, and post-processing into a single thread wastes the NPU. A recommended three-stage pipeline decouples the stages with queues:

    1. Capture thread (dual stream) → preprocessing queue → NPU inference thread (can be multi-instance) → post-processing/rendering thread

    In preprocessing, offload scaling, color space conversion, and normalization to hardware acceleration units as much as possible to avoid loading the CPU.

    4.3 Zero-Copy Memory and Buffer Reuse

    Copying high-resolution frames often costs more than the inference itself. Using a unified memory allocator and a buffer reuse mechanism so that capture, preprocessing, and inference share the same physical memory is one of the most effective ways to improve end-to-end frame rate.

    5. Measured Performance and Tuning Approach

    With the architecture above, one 13-megapixel-class stream can achieve real-time detection at about 25 FPS; one 4K-class stream can sustain 30 FPS capture and perform object detection at roughly the same frame rate. If the expected results are not met, troubleshoot in this order: first check memory bandwidth usage, then check whether a single CPU core is maxed out by post-processing, then look for implicit copies, and only then consider lowering the model input resolution.

    6. Deployment Recommendations

    To further reduce integration cost, model training and data management can be moved to the cloud: use object storage to archive samples, a container platform to host training jobs, and a monitoring and alerting service to track device online rate and inference latency. Keeping real-time inference on the device and iteration and operations in the cloud is currently a cost-effective division of labor.