🛠 Caméra DVP 8 bits sur le connecteur CSI et vision OpenCV

Banana Pi BPI-M2 Zero (Allwinner H2+ / H3) · avance · Schéma : IMG-bananapi-m2-zero-avance-2-camera-dvp-csi-opencv-m2-zero.svg — nappe FPC 24 broches reliant un module caméra OV5640 (capteur DVP parallèle) au connecteur CSI du BPI-M2 Zero ; tableau des signaux D0-D7, PCLK, HSYNC, VSYNC, MCLK, I2C PE12/PE13, CSI-PWR-EN (PD14) ; écran affichant une détection de visage OpenCV.

Objectives

The 24-pin CSI connector on the BPI-M2 Zero is a rarity in this form factor: an 8-bit parallel camera bus DVP/CCIR656 (D0-D7, PCLK, HSYNC, VSYNC, MCLK, control I2C on PE12/PE13, power controlled by CSI-PWR-EN on PD14) for sensors like the OV5640 up to ~5 MP. Beware of the vocabulary trap repeated in some articles: this is parallel DVP, NOT MIPI — MIPI cameras are not compatible. You will connect the ribbon cable, verify the video pipeline on the kernel side, and run an OpenCV face detection.

Hardware

Complete Code

# 1) Le pipeline vidéo est-il présent ?
v4l2-ctl --list-devices 2>/dev/null || sudo apt install -y v4l-utils
v4l2-ctl -d /dev/video0 --all | head -25     # formats supportés (YUYV 1280x720...)

# 2) Capture d'une image de contrôle
ffmpeg -f video4linux2 -i /dev/video0 -ss 1 -frames:v 1 test.jpg 2>/dev/null

# 3) Détection de visage OpenCV (léger, adapté aux 512 Mo)
sudo apt install -y python3-opencv
python3 - <<'EOF'
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
face = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
while True:
    ok, frame = cap.read
    if not ok:
        print('pas de trame — vérifier nappe et alimentation capteur')
        break
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    for x, y, w, h in face.detectMultiScale(gray, 1.2, 5):
        cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
    cv2.imshow('BPI-M2 Zero CSI', frame)
    if cv2.waitKey(1) == 27:
        break
EOF

Expected Verification

v4l2-ctl lists the capture device with YUYV formats; the test photo is sharp and correctly exposed; the OpenCV window displays the stream and frames faces. In case of a completely black or green frame, start by checking the orientation of the FPC ribbon cable.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials