🛠 Vision stéréo : deux caméras CSI sur un CM3
Objectives
Leverage one of the Compute Module format's key advantages: two simultaneous CSI interfaces (one 4-lane + one 2-lane) for stereo or multi-camera vision on a single module. The CM3 manages both cameras via the Pi 3 firmware, using the command raspistill -n <number>. A critical point documented by the Raspberry Pi firmware engineer on the launch blog: camera modules expose no genlock signal — hardware synchronization is impossible, and drift between the two streams is measured in milliseconds, uncorrectable in hardware.
Hardware
- CM3 on CMIO3 (both CSI connectors are present on the board)
- 2 Raspberry Pi v1/v2 cameras + 2 CSI ribbon cables
- Solid power supply: two sensors + GPU under load, allow margin on the 3.5 W VBAT
Complete code
# config.txt : activer le support multi-caméras (firmware Pi 3)
sudo tee -a /boot/firmware/config.txt <<'EOF'
start_x=1
camera_auto_detect=1
EOF
sudo reboot
vcgencmd get_camera # attendu : supported=2 detected=2
# Capture sur les deux caméras (capteur 0 = CSI 4 voies, 1 = CSI 2 voies)
raspistill -n 0 -o gauche.jpg -t 500 -w 1280 -h 720 &
raspistill -n 1 -o droite.jpg -t 500 -w 1280 -h 720
wait
# Horodater chaque trame pour mesurer la dérive de synchronisation
python3 - <<'EOF'
import subprocess, time
for n in (0, 1):
t0 = time.time
subprocess.run(['raspistill', '-n', str(n), '-o', 'cam%d.jpg' % n, '-t', '1'])
print('cam%d capture finie a +%.0f ms' % (n, (time.time-t0)*1000))
EOF
Expected verification
vcgencmd get_camera returns supported=2 detected=2; two JPEGs are produced. The small timestamping script reveals discrepancies of a few milliseconds between the two captures: this is the expected drift, without genlock. For correct stereo, plan for a static scene or a software alignment algorithm using image correlation.
Common errors
- Believing in exact frame synchronization: without hardware genlock (documented absence on the official blog), any strict real-time application (vehicles, fast 3D measurement) must compensate in software.
- Plugging both cameras into the same connector via an adapter: the CM3 has no CSI multiplexer, each ribbon cable goes to its own connector.
- Overloading the single USB 2.0 bus by transferring both streams via an external network adapter: the bandwidth of the single port is the bottleneck, write to eMMC or reduce resolution.
detected=1instead of 2: a poorly inserted ribbon cable, or a v2 camera on firmware too old for this sensor — update Raspberry Pi OS.- Forgetting the connector order: sensor 0 corresponds to the 4-lane CSI; swapping left/right breaks upstream stereo alignment.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash