🛠 MicroPython + machine vision : le firmware OpenMV sur un cœur, C++ sur l'autre

Arduino Portenta H7 · avance · Schéma : IMG-portenta-h7-avance-1-portenta-h7-micropython-openmv.svg — Portenta H7 avec caméra branchée sur le connecteur CSI, écran OpenMV IDE affichant une image QVGA avec rectangle de détection, étiquettes MicroPython OpenMV sur un coeur et Arduino C++ sur l'autre, Vision Shield à côté

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials