This project provides a real-time embedded environment for STM32F4 microcontroller to execute STEdgeAI generated models, specifically targeting the hand posture application. The code prioritizes clarity and understandability over performance, making it an ideal starting point for further development.
Hand posture classification using EVK software.
This is a standalone project that can be deployed directly to hardware. It is also integrated into the ST ModelZoo repository, and is required to deploy the hand posture use case. The ModelZoo enables you to train, evaluate, and automatically deploy any supported model. If you wish to use this project as part of the ModelZoo, please refer to the Quickstart using stm32ai-modelzoo-services section for instructions.
- Features Demonstrated
- Hardware Support
- Tools Version
- Quickstart using stm32ai-modelzoo-services
- Quickstart using Prebuilt Binaries
- Quickstart using Source Code
- Read Application Output
- Application Overview
- Known Issues and Limitations
- Sequential application flow
- Software floating point AI model inference
- ToF sensor data acquisition
Supported development platforms:
- NUCLEO-F401RE Nucleo board
- X-NUCLEO-53LxA1 Nucleo expansion board
- A USB host for data transmission via serial COM port using the ST-Link USB port
- STM32CubeIDE (v1.17.0)
- STM32CubeProgrammer (v2.18.0)
- STEdgeAI (v3.0.0)
This application is a C-based project required by the deployment service in the ModelZoo. The ModelZoo enables you to train, evaluate, and automatically deploy any supported model.
To deploy your model using the ModelZoo, refer to the Deployment README for detailed instructions.
Note: This C-based application is already included in the ModelZoo repository under STM32F4 hand posture application code folder.
To program the board's flash and run the program, follow these steps:
- Program
Binary/STM32F4-GettingStarted-HandPosture.hexusing STM32CubeProgrammer. - Reset the board.
Double-click Application/NUCLEO-F401RE/STM32CubeIDE/.project to open the project in STM32CubeIDE. Build and run the project.
The application sends output data over the serial COM port using the ST-Link USB port. To read the output, follow these steps:
- Connect the board to your PC via USB.
- Open a serial terminal application (e.g., Tera Term, PuTTY).
- Configure the serial port with the following settings:
- Baud Rate: 921600
- Data Bits: 8
- Stop Bits: 1
- Parity: None
- Flow Control: None
- Start the terminal session to view the application header.
- Enter "enable" and press Enter to start hand posture classification.
- Place your hand in front of the ToF sensor to see real-time posture classification results.
Note: you can enter "help" to display available commands.
Alternatively, you can use the Hand Posture EVK software, which provides access to a graphical user interface. The software contains the documentation necessary for its use.
The application performs real‑time hand posture classification using data streamed from a Time‑of‑Flight (ToF) sensor. Each acquisition produces a frame shaped 8 x 8 x 2:
- 8 x 8: spatial grid of sensing zones
- 2 channels per zone:
ranging: measured distancepeak: received photon count (signal strength proxy)
The processing pipeline transforms each raw frame into a stable posture label:
The sensor delivers a frame at a rate configured by its timing budget and inter‑measurement period. Frame rate therefore depends on your chosen sensor settings.
ValidateFrame: Discard or flag frames where the subject is outside the configured valid distance range (avoids meaningless inference).NormalizeData: Scale/shift distance and peak values into the numeric domain expected by the neural network.
The normalized tensor is passed to the C AI model (generated by STEdgeAI). The network outputs a vector of class scores (FLOAT32 probabilities) for the supported hand postures.
- Argmax over the network output → predicted class index.
- Temporal smoothing filter → reduces jitter by suppressing short‑lived fluctuations (require consistency over 3 frames).
The stable predicted posture label is then transmitted over the serial COM port.
The neural network model files (network.c/h, etc.) included in this project were generated using STEdgeAI version 3.0.0.
If you use a different version of STEdgeAI to generate these model files, please follow the STEdgeAI instructions on How to update my project with a new version of ST Edge AI Core to update your project.
- Supports only neural network models whose size fits within the SoC internal memory.
- Supports only non-quantized neural network models.
- Supports only neural network models with an input shape of 8×8×2.
- The model's input layer supports data only in FLOAT32 format.
- The model's output layer provides data only in FLOAT32 format.