🛠 MicroPython + machine vision : le firmware OpenMV sur un cœur, C++ sur l'autre
Objectives
The Portenta H7 is also an embedded vision board: the official MicroPython path goes through the OpenMV firmware, and the board features a CSI camera connector (the Vision Shield adds a microphone and sensors). You will capture images in MicroPython and understand that the OpenMV firmware coexists with the dual-core model—one core can run the MicroPython/JavaScript interpreter while the other keeps compiled Arduino code, linked via RPC. This is the gateway to TensorFlow Lite and the official camera tutorials (getting-started-openmv-micropython, openmv-cheat-sheet).
Hardware
- 1 × Arduino Portenta H7 + USB-C data cable
- 1 × compatible camera on the CSI connector, or the Portenta Vision Shield (Himax HM01B0 / GC2145 type sensors supported by the
Camera,Arduino_H7_Video,Himax_HM01B0,OV7670libraries) - OpenMV firmware for Portenta (official tutorial
getting-started-openmv-micropython) - OpenMV IDE (or MicroPython REPL console)
Complete Code
# vision_openmv.py — OpenMV MicroPython sur Portenta H7
import sensor, image, time
sensor.reset # init camera sur le connecteur CSI
sensor.set_pixformat(sensor.RGB565) # couleur 16 bits
sensor.set_framesize(sensor.QVGA) # 320x240
sensor.skip_frames(time=2000) # laisse l'expo se stabiliser
clock = time.clock # horo FPS facon OpenMV
while True:
clock.tick
img = sensor.snapshot # une trame en memoire
# brique de base de la vision : trouver les blobs lumineux
for b in img.find_blobs([(0, 100, 0, 100, 0, 100)],
pixels_threshold=200):
img.draw_rectangle(b[0:4], color=(255, 0, 0))
print("fps %.1f" % clock.fps)
# >
# (forme de retour de find_blobs notamment) — la page cheat-sheet est
# JS-renderée et n'a pas pu etre verifiee ; teste dans l'OpenMV IDE.
Expected Verification
The OpenMV IDE displays the live camera feed with detection rectangles, and the FPS scrolls in the script console. The underlying hardware pipeline is that of the STM32H747: the dedicated Chrom-ART (DMA2D) graphics accelerator and JPEG encoder—the same ones used in the official LVGL GUI tutorial that drives a monitor via DisplayPort over USB-C.
Common Errors
- Looking for "standard" MicroPython for Portenta: the documented official path is the OpenMV firmware; a generic MicroPython firmware from another board will not work.
- Forgetting
skip_frames: the first two seconds are overexposed while autofocus/exposure settle—your blob thresholds will appear random. - Camera upside down or CSI ribbon cable poorly inserted: black or corrupted image without an explicit error message.
- Overwriting the OpenMV firmware with an Arduino sketch without a rollback plan: keep the two workflows separate (re-flash the Mbed core on one side, the OpenMV firmware on the other)—the double-tap RESET + flash allows switching between them.
- Believing the MicroPython core is isolated: the benefit of dual-core is coupling MicroPython (vision, prototyping) and real-time C++ (control) via RPC—see the dual-core tutorial on the C++ side.
- >
- For voice recognition, the ecosystem favors the Syntiant NDP101/120 on the Vision Shield (
syntiant_ilib/NDPlibraries,speech-recognition-enginetutorial) over MicroPython.
Other tutorials for this board
- Premier programme : installer le core et faire clignoter la LED (M7 à 480 MHz !)
- Se connecter au Wi-Fi avec le module Murata 1DX (station WPA2)
- Apprivoiser les connecteurs 80 broches : bouton, LED et entrée analogique
- Dual-core M7 ↔ M4 : appels de fonctions distants avec la bibliothèque RPC
- Client HTTPS/TLS : interroger une API sécurisée via le Murata 1DX
- Serveur web sur le port Ethernet 10/100 embarqué
Code examples for this board
clignotante.inoArduinobouton-poussoir.inoArduinopwm-respiration.inoArduinoentree-analogique.inoArduinomulti-uart.inoArduinocapteur-i2c-bmp280.inoArduino