🛠 Vision par caméra : OpenCV sur le SoC x86

LattePanda Alpha · avance · Schéma : IMG-lattepanda-alpha-avance-2-camera-vision.svg — camera USB ou RealSense branchee sur un port USB 3.0 Type A de la LattePanda Alpha, pipeline OpenCV avec detection de visage

Objectives

Leverage the Alpha's x86 power for real-time vision: capture a USB camera (or Intel RealSense, explicitly cited as compatible in the official documentation) on one of the three USB 3.0 Type-A ports, and process images with OpenCV in Python — capture, resizing, face detection. This is the type of workload a microcontroller cannot handle, but the Core m3-7Y30 can manage.

Hardware

Complete Code

# vision_visage.py — capture USB + détection de visage OpenCV
import cv2

cap = cv2.VideoCapture(0)          # 0 = première caméra UVC (Windows ou /dev/video0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

assert cap.isOpened, "Caméra introuvable : vérifier /dev/video0 ou le numéro de flux"

while True:
    ok, frame = cap.read
    if not ok:
        break
    gris = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    visages = cascade.detectMultiScale(gris, scaleFactor=1.2, minNeighbors=5)
    for (x, y, w, h) in visages:
        cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
    cv2.putText(frame, f"visages: {len(visages)}", (10, 30),
                cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
    cv2.imshow("LattePanda Alpha - vision", frame)
    if cv2.waitKey(1) & 0xFF == 27:   # Échap pour quitter
        break

cap.release
cv2.destroyAllWindows

Expected Verification

The window opens within seconds displaying the 640×480 stream; a green rectangle surrounds each detected face, and the counter is displayed in red. On Linux, ls /dev/video* shows the camera; on Windows, Device Manager lists it under "Imaging devices".

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials