Skip to content

OpenCV on STM32

Anton Bondarev edited this page Sep 30, 2020 · 14 revisions
Clone this wiki locally

Running OpenCV on STM32F7Discovery

This section describes some experimental stuff, so there are chances that something doesn't work as expected. Feel free to create new issues, we'll try to figure it out.

Currently OpenCV works with STM32F746GDISCOVERY and STM32F769IDISCOVERY.

Following examples describe how to run example Canny filter to detect edges (source code is project/opencv/cmds/edges.cpp in Embox).


This board has enough flash memory for OpenCV, so it's pretty easy to run a simple example:

  1. Compile this template (it requires a few minutes as it builds libstdc++ and opencv from source)
 	make confload-project/opencv/stm32f769i-discovery
  1. Load Embox with openocd (more details on another wiki page)

  2. Run edges fruits.png 20 on Embox console


This board has only 1MiB flash memory, so it's a little bit more compilated. OpenCV requires too much read-only memory (it's mostly code), so you have to use QSPI flash to run it.

Brief instruction:

  1. Compile this template:
 	make confload-project/opencv/stm32f764g-discovery
  1. Extract readonly sections from ELF
	arm-none-eabi-objcopy -O binary build/base/bin/embox tmp.bin \
		--only-section=.text --only-section=.rodata \
		--only-section='.ARM.ex*' \
  1. Now load tmp.bin to QSPI memory. Refer to for more details

  2. Use goto command, jump to target memory address. Target address is a second 32-bit word of the binary image (you can find it out with mem 0x90000004). For example,

embox>mem 0x90000004
0x90000004:     0x9001f393  0x9001f389  0x9001f389  0x9001f389  
embox>goto -i 0x9001f393
  1. Run edges fruits.png 20 on Embox console