Skip to content

AI software application package demonstrating simple implementation of hand posture use case on STM32F4 products.

License

Notifications You must be signed in to change notification settings

STMicroelectronics/STM32F4-GettingStarted-HandPosture

Repository files navigation

Hand Posture Getting Started

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.

Image sample
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.


Table of Contents


Features Demonstrated

  • Sequential application flow
  • Software floating point AI model inference
  • ToF sensor data acquisition

Hardware Support

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

Tools Version


Quickstart using stm32ai-modelzoo-services

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.


Quickstart using Prebuilt Binaries

To program the board's flash and run the program, follow these steps:

  1. Program Binary/STM32F4-GettingStarted-HandPosture.hex using STM32CubeProgrammer.
  2. Reset the board.

Quickstart using Source Code

Double-click Application/NUCLEO-F401RE/STM32CubeIDE/.project to open the project in STM32CubeIDE. Build and run the project.


Read Application Output

Serial Communication

The application sends output data over the serial COM port using the ST-Link USB port. To read the output, follow these steps:

  1. Connect the board to your PC via USB.
  2. Open a serial terminal application (e.g., Tera Term, PuTTY).
  3. Configure the serial port with the following settings:
    • Baud Rate: 921600
    • Data Bits: 8
    • Stop Bits: 1
    • Parity: None
    • Flow Control: None
  4. Start the terminal session to view the application header.
  5. Enter "enable" and press Enter to start hand posture classification.
  6. 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.

Hand Posture EVK

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.


Application Overview

Software Architecture 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 distance
    • peak: received photon count (signal strength proxy)

The processing pipeline transforms each raw frame into a stable posture label:

Processing Workflow

1. Acquisition

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.

2. Preprocess (Network_Preprocess)

  1. ValidateFrame: Discard or flag frames where the subject is outside the configured valid distance range (avoids meaningless inference).
  2. NormalizeData: Scale/shift distance and peak values into the numeric domain expected by the neural network.

3. Inference (Network_Inference)

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.

4. Postprocess (Network_Postprocess)

  1. Argmax over the network output → predicted class index.
  2. Temporal smoothing filter → reduces jitter by suppressing short‑lived fluctuations (require consistency over 3 frames).

5. Output

The stable predicted posture label is then transmitted over the serial COM port.


How to update my project with a new version of ST Edge AI

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.


Known Issues and Limitations

  • 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.

About

AI software application package demonstrating simple implementation of hand posture use case on STM32F4 products.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages