🛠 Caméra DVP 8 bits sur le connecteur CSI et vision 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
- BPI-M2 Zero + vendor Debian image kernel 4.4 (most complete CSI coverage; mainline sun6i-csi support for this board remains partial)
- OV5640 camera module (or compatible 8-bit DVP) with 24-pin FPC ribbon cable
- HDMI screen or network stream for visualization
- Optional heatsink: capture + OpenCV heats up the 4 Cortex-A7 cores
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
- Plugging in a MIPI camera (identical ribbon cable, different protocol): the connector is parallel DVP, only an 8-bit DVP sensor is suitable.
- Reversing the FPC ribbon cable: partial contact, noisy image, or sensor missing from the I2C bus.
- Requiring CSI support on recent mainline Armbian: controller coverage for this board is incomplete, the vendor 4.4 image remains the safe path.
- Aiming for 5 MP at full OpenCV frequency: with 512 MB, stick to 640×480 for real-time vision.
- Forgetting CSI-PWR-EN (PD14): without permission to power the sensor, no second I2C device appears on the camera bus.
Other tutorials for this board
- Flasher Armbian et premier boot du BPI-M2 Zero
- LED et bouton avec libgpiod sur le port 40 broches
- Wi-Fi AP6212 : le piège de l'antenne U.FL non fournie
- Console série sur USB-OTG : dépanner sans réseau ni câble UART
- Activer le bus SPI0 et piloter un petit écran TFT
- Survivre avec 512 Mo : zram, swap compressé et services légers
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash