Image of an arrow

Deploying Person Detection with the VL53L9CX on STM32MP2

Avatar

tgarbay

Person Detection with the VL53L9CX on STM32MP2

Person detection with the VL53L9CX requires a trained model for Near-infrared (NIR) and Depth modalities. After creating a synthetic dataset and training detection models, this final article focuses on integrating person detection with the VL53L9CX. The article describes the path of an image captured by the VL53L9CX dToF sensor, from acquisition on Linux to visualization on the GPU, including multimodal preprocessing, inference on the NPU, and distance fusion, all on an STM32MP257F-DK.

People Detection with a set up composed of the STM32MP257F-DK and the VL53L9CX

From synthetic training data to a real sensor

Person detection with the VL53L9CX combines two kinds of information: depth measurements and near-infrared for a neural network to identify regions likely to contain a person. On the STM32MP257F-DK, connecting these outputs requires more than a compiled model. Acquisition, preprocessing, NPU inference and display must agree on what each frame represents.

The first two articles in this serie addressed the learning side of person detection with a low-resolution LiDAR sensor. We explored synthetic depth and near-infrared data generation, then trained and compared YOLO models using those modalities. The next step is to connect that work to the hardware that will actually produce the detection.

The retained pipeline prepares images on the CPU, runs YOLOv8 on the neural processing unit (NPU), and renders a local 3D view on the GPU. With an asynchronous CPU/NPU pipeline, the measured presentation rate ranges from 14.23 frames/s with YOLOv8m to 24.76 frames/s with YOLOv8n.

A dToF, not an RGB camera

The system combines an ST VL53L9CX sensor with an STM32MP257F-DK running embedded Linux. The sensor supplies a 54 x 42 grid: 2,268 measurement zones rather than a conventional RGB image. A person detector processes depth and near-infrared information, while the application associates its bounding boxes with distances measured by the sensor. Processing stays local and needs no RGB camera stream. The deployment problem for person detection with the VL53L9CX is therefore larger than loading a neural network. Sensor data must reach the application, match the model’s expected representation, execute on the accelerator, and remain geometrically consistent with the information shown on screen.

VL53L9CX evaluation hardware used to acquire depth and signal-amplitude mapsSTM32MP257F-DK development board hosting the Linux application, NPU inference and GPU displayvl53l9 people detection

What person detection adds to a depth sensor

A depth map answers a spatial question: how far away are the surfaces sampled by the sensor? Person detection with the VL53L9CX adds a semantic question: which image regions are likely to contain a person?

Combining the two gives the application a useful output: a person bounding box accompanied by an associated distance. This can support candidate applications such as person-aware mobile robotics, occupancy sensing, or equipment that adapts its interaction according to someone’s presence and proximity. All of this is done with privacy in mind, since it involves dToF data and no RGB camera is required.

These use cases require different interpretations of the same measurements. A robot may use a detection as an input to its navigation software. An interactive device may care more about whether a person is nearby than about reconstructing the whole scene. In either case, a compact sensor can supply both the geometry and the input to a specialized detector.

A Linux application, from acquisition to display

VL53L9CX person detection

Figure 1. Linux frame-processing pipeline on STM32MP257F-DK.

The Linux configuration distributes work across the STM32MP2’s CPU, NPU, GPU, and dedicated capture and display hardware.

The native C/C++ application acquires frames through Video4Linux2 (V4L2), prepares them on the CPU, and calls the STAI runtime to run the detection model on the NPU. Back on the CPU, it interprets the output and associates each detection with a measured distance. GStreamer then hands the result to the GPU for display.

At step 1, the sensor stream reaches Linux through CSI and DCMIPP, the SoC’s capture interface. V4L2 exposes a 100 x 149-byte frame, i.e. 14,900 bytes. These transport dimensions describe a packed payload, not a 100 x 149 depth image. Step 2 decodes the actual 54 x 42 maps, builds a colorized depth map for display, prepares the network input, and retains metric depth and validity for later use. Step 3 runs inference on the NPU. Step 4 discards low-confidence predictions, removes duplicate boxes, maps the remaining boxes back to the sensor grid, and associates distances using the retained depth. Step 5 combines the colorized depth map and detection metadata in one GStreamer buffer. Step 6 renders the depth tiles and boxes on the GPU, and Weston presents the result over HDMI.

The input: matching the model, not just its dimensions

The most important boundary in this person detection with the VL53L9CX application is between the decoded sensor maps and the model input. A tensor can have the correct dimensions and still contain the wrong information. The decoder extracts distance, signal amplitude, ambient measurements, and a validity mask. For the detector, the NIR channel comes from the signal/amplitude plane, not the ambient plane. Substituting one for the other would change the meaning of the input without changing its shape.

The application first applies the selected image orientation consistently to depth, signal, and validity. It then prepares the two modalities differently. For depth, invalid samples are filled with the median of the valid measurements, and the resulting map is normalized to an 8-bit range using that frame’s minimum and maximum. A frame with no valid depth, or no depth variation, receives a neutral value of 128 in the depth plane.

For NIR, the implementation uses a fixed calibration interval, with defaults of 0 to 5987 in the signal map’s units. Values outside this interval are clipped. Unlike depth normalization, this mapping does not independently stretch each frame to its own minimum and maximum.

Letterboxing the sensor grid for the network

The resulting matrices for person detection with the VL53L9CX are placed in a three-channel canvas:

Active image channels: [0, NIR, Depth]

Sensor grid:          54 x 42
Resized image:        224 x 174
Vertical padding:    25 rows above + 25 rows below
Final canvas:        224 x 224 x 3
Padding value:       [114, 114, 114]

There are two sensing modalities, but three tensor channels. The first channel is zero inside the active image, the padding uses 114 in all three channels. This is a model input convention.

Resizing preserves the aspect ratio to the nearest integer dimensions, and padding completes the square input. This operation, known as letterboxing, avoids stretching the sensor’s rectangular field into a square. Upscaling adapts the representation to the network.

The interpolation convention also matters. The implementation uses half-pixel bilinear sampling to match the reference preprocessing. A different coordinate convention can shift sample positions even when the output dimensions are identical. Development history includes a correction to the channel and geometric mapping: a useful reminder that “resize to 224 x 224” is not a sufficient preprocessing specification.

Running YOLO on the NPU

The application for person detection with the VL53L9CX uses compiled .nb model artifacts through the STAI runtime’s OpenVX NPU backend. Offline training and model preparation (see past article about preparing dataset and training models) are separate from this runtime path: the embedded application supplies an input tensor, executes the network, and retrieves its output.

Three 224 x 224 variants are packaged: YOLOv8n, YOLOv8s, and YOLOv8m, corresponding to nano, small, and medium.

For the deployed model, the observed input shape is (1, 224, 224, 3) in INT8 format. This is batch size one, with channels stored last. Its output is an INT8 tensor with shape (1, 5, 1029). Each of the 1,029 candidate predictions carries four box coordinates and one person score. It is the application’s responsibility to turn those predictions into a smaller set of useful boxes.

First, the CPU dequantizes the output using its quantization parameters. It rejects predictions below the confidence threshold, sorts the remaining candidates by score, and applies non-maximum suppression (NMS). NMS removes lower-scoring boxes that overlap too strongly with a box already retained. The active settings use a confidence threshold of 0.50 and an intersection-over-union threshold of 0.45.

The division of responsibility is explicit: the NPU executes the model, while output interpretation stays in application code. This keeps geometric conversion, distance association, and display metadata independent of the accelerator interface.

Performance

Model selection for person detection with the VL53L9CX requires at least two runtime measurements: the inference cost of the model alone, and the behavior of the application that surrounds it, expressed as throughput and latency.

Inference cost with the NPU

ModelCompiled file sizeInference time
YOLOv8 Nano2.47 MiB11.09 ms
YOLOv8 Small7.46 MiB25.03 ms
YOLOv8 Medium16.15 MiB48.04 ms

Inference cost grows with model size, but less than proportionally. Small is 3.0 times larger than Nano but only 2.3 times slower, Medium is 6.5 times larger but only 4.3 times slower.

Complete Pipeline

VL53L9CX person detection

Latency for the asynchronous pipeline.

VL53L9CX person detection

Throughput for the asynchronous pipeline.

Both show the asynchronous pipeline, in which the CPU prepares the next frame while the NPU processes the current one. Throughput does not follow inference cost. Medium’s inference is 4.3 times longer than Nano’s, yet its throughput is only 1.7 times lower (14.23 vs 24.76 frames/s). Two different bottlenecks explain this:

  • Nano is limited by the CPU. Preparing a frame takes about 40 ms on the Cortex-A35, which caps the pipeline at about 25 frames/s, the rate measured. A faster model would not increase throughput but a faster preparation would.
  • Small and Medium are limited by the NPU call. The time between two presented frames (47 ms and 70 ms) matches the duration of the inference call inside the application (45 ms and 68 ms). These calls take about 20 ms longer than in isolation because the 3D display runs at the same time. The GPU and the NPU share the same Vivante driver stack: in a separate test without the application, Nano’s inference rose from 10.9 to 18.8 ms when depth map rendering ran concurrently.

Where a frame spends its time

VL53L9CX person detection

Capture-to-display latency in asynchronous pipeline: 121.8 ms for Nano model, 224.1 ms for Small model and 316.2 ms for Medium model.

CPU preparation, which covers depth-map colorization and model preprocessing, takes about 40–42 ms for all three models. It is not the only cost. For Medium, the mean STAI  run()  call grows from 48.0 ms when the CPU and NPU work in turn to 68.0 ms in the asynchronous pipeline. The GStreamer/GPU interval also grows. “NPU queue / input” covers the time a prepared frame waits, plus input conversion and assignment before  run() . “GStreamer / GPU” runs from buffer submission to the EGL swap request. “Frame presentation” runs from that request until the compositor presents the frame.

Model timing alone overstates what the application delivers. In isolation, Medium’s 48.0 ms inference would allow about 20.8 inferences per second, but the complete application presents 14.23 frames/s. The gap is wider for Nano: about 90 inferences per second in isolation, against 24.76 frames/s in the application. A model benchmark measures a single boundary. Capture, CPU preparation, data movement and display also determine the final rate

Conclusion: Edge AI is a system-level task

This deployment connects the series’ data and model work to a complete embedded processing path for person detection with the VL53L9CX. The data are from VL53L9CX measurements, the Cortex-A35 prepares their representation, the NPU executes the model, and the application combines detections with metric depth before handing the visualization to the GPU.

Three lessons extend beyond this system.

  1. The training-to-runtime input contract includes channel meaning, normalization, interpolation, padding, and quantization. Detection coordinates must stay consistent with the original sensor geometry.
  2. Network timing and application throughput answer different engineering questions. Bringing those elements together is the core of Edge AI integration: connecting sensing, embedded Linux, accelerator execution, and display rather than treating the model as an isolated component.
  3. The resulting application gives low-resolution depth measurements a semantic interpretation while preserving their practical value as distance information.

Leave a comment

Your email address will not be published. Required fields are marked *


Similar articles

Image of an arrow
Small Language Models (SLMs) on the i.MX95

Small Language Models (SLMs) on the i.MX95 LFM3-1.7B running offline on the i.MX95 CPU in real time: first text in about 3 s, then about 5 tokens/s. In this article, we explore the capabilities of the i.MX95 for running SLMs. We already have developed several applications on the i.MX95, including monocular depth estimation. Small language […]

AI coding agents can now modify repositories, run tests, and propose commits. Yet writing code is only one part of engineering work. Between a ticket and a merged change, several steps are still required: gathering context, preparing the environment, producing a patch, opening a review, waiting for feedback, and updating the code until it is […]

Prompt Anything: Instance Segmentation with YOLOE-26 within a Hailo-10H Running YOLOE-26 as a “prompt anything” segmentation within a edge NPU, from model surgery and INT8 quantization to a 15.6 FPS (640px) / ~31 FPS (320px) fully optimized live pipeline. YOLOE-26’s open-vocabulary support lets operators type any class name for real-time segmentation on the Hailo-10H. Our […]

Monocular Depth Estimation on the Verdin i.MX95 for Edge AI   Deploying Monocular Depth Estimation on the Verdin i.MX95 for Edge AI: model adaptation, INT8 quantization, and a full embedded software stack for real-time depth inference at 30 FPS from a single RGB camera. Monocular depth estimation involves reconstructing a depth map from a single […]