How to perform people counting using FP-AI-VISION1 and STM32H747XI

Revision as of 15:49, 18 December 2023 by Registered User

This article shows how to run FP-AI-VISION1 function pack projects on STM32H747I-DISCO kits by using the People Counting demo as an example. For STM32H747I-DISCO kits shipped with MB1166-A09 LCD daughterboards, an additional step to update drivers is also described. Further, if you only get static on the LCD as shown below, this article may be helpful.

Figure 1: Static on LCD


1. Prerequisites

1.1. Hardware

1.2. Software

2. Hardware Setup

Connect B-CAMS-OMV camera to STM32H747I-DISCO using the Flexible Flat Cable (FFC). Ensure that the FFC is securely attached to both the ZIF connectors, and that the orientation is as shown in the image below (highlighted in yellow).

Next, attach the USB cable to the USB port labelled as "STLINK-V3E", as shown in the image below (highlighted in blue).

Figure 2: Hardware Setup


3. Import Project

If the goal is to run the project on STM32H747I-DISCO without any modifications, simply drag-and-drop the file ..\FP-AI-VISION1_V3.1.0\Projects\STM32H747I-DISCO\Applications\PeopleCounting\Binary\STM32H747I-DISCO_PeopleCounting_Quant8_IntFps_IntFlash_V310.bin on to the STM32H747I-DISCO mass storage device as shown below.

Flash dragndrop
Figure 3: Drag and drop the binary file to flash the MCU
Info white.png Information
Flashing the existing binary file will not work for STM32H747I-DISCO kits with MB1166-A09 LCD Daughterboard. If the goal is to run the project on kits with MB1166-A09 LCD, then please follow the rest of the guide, including section 4.

3.1. Import project into CubeIDE

The project can be imported into STM32CubeIDE by simply opening the .project file located at ..\FP-AI-VISION1_V3.1.0\Projects\STM32H747I-DISCO\Applications\PeopleCounting\STM32CubeIDE\.project by following the steps below:

  1. Double click the .project file
  2. STM32CubeIDE will prompt for workspace directory, as shown below. Select an appropriate location and press Launch.
    Figure 4: Select Workspace

    STM32CubeIDE will prompt once the project has been successfully imported. Press OK to proceed.
    Figure 5: Prompt after import succeeds
  3. You will now see the project under the Project Explorer.
Figure 6: Project directory Listing

3.2. Directory Overview

This project is being deployed on the STM32H747XI MCU which is a dual-core Arm® Cortex®-M7 and Cortex®-M4 MCU. In this project, we only use the M7 core and therefore we will only be working with the CM7 directory. This directory contains the source code specific to the People Counting project. Detailed information about the organization of this directory is available in Section 3.2 of UM2611: Artificial Intelligence (AI) and computer vision function pack for STM32H7 microcontrollers.

4. Update Drivers (Required only if using MB1166-A09)

Drivers for LCD daughterboard MB1166-A09 (pictured below) are currently not included in the FP-AI-VISION1 function pack. In order to deploy the project on STM32H747I-DISCO kits with MB1166-A09 LCD, follow the steps below to install the drivers.

Figure 7: STM32H747I-DISCO with MB1166-A09


  1. If you already have CubeH7 v1.11.1 or above installed, locate the directory at C:\users\<username>\STM32Cube\repository\STM32Cube_FW_H7_V1.11.1\Drivers\BSP\Components\nt35510 and skip to step 3.

    If not, download the drivers from the (1) STM32CubeH7 GitHub repo by clicking on (2) "Code", and then (3)"Download ZIP", as shown in the image below.
    Figure 7: Download ZIP from GitHub
  2. Extract the contents of STM32CubeH7-master.zip to a local directory.
  3. Copy directory ..\STM32CubeH7-master\Drivers\BSP\Components\nt35510 to ..\FP-AI-VISION1_V3.1.0\Drivers\BSP\Components\
  4. Copy files ..\STM32CubeH7-master\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_lcd.c and ..\STM32CubeH7-master\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_lcd.h, and paste both files into ..\FP-AI-VISION1_V3.1.0\Drivers\BSP\STM32H747I-Discovery\ directory
  5. Use a text editor to open ..\FP-AI-VISION1_V3.1.0\Projects\STM32H747I-DISCO\Applications\Common\CM7\Inc\stm32h747i_discovery_conf.h. On line 34, add a #define for NT35510, and change the OTM8009A #define to 0, as follows:
    /* LCD controllers defines */ 
    #define USE_LCD_CTRL_NT35510                1U 
    #define USE_LCD_CTRL_OTM8009A               0U 
    #define USE_LCD_CTRL_ADV7533                0U
    
  6. From the FP-AI-VISION1_V3.1.0\Drivers\BSP\Components\nt35510 directory, select the four source files as shown in the image below, and drag and drop the selected files to the components directory in STM32CubeIDE.
    Figure 8: Drag and drop all four files into components directory

    Then in the pop-up window, keep “Link to files” and click OK.
    Figure 9: Select "Link to files" and click OK

    Drivers should now be indexed into the project
    Figure 10: Drivers have been indexed

5. Build & Flash

Right click the project, then (1) Clean and (2) Build the project. The project should build without errors. Now you can click the (3) Run icon to flash and execute the project.

Figure 10: Clean, build and flash the project

Once execution starts, the screen will display a live output from the camera along with the number of people detected in the frame, as shown below.

Figure 12: Final output showing people counting demo on STM32H747XI


6. References

Vision Pack Video Application Notes

UM2611: Artificial Intelligence (AI) and computer vision function pack for STM32H7 microcontrollers