Calibration Stéréo ================== Matériel nécessaire ------------------- - Damier imprimé **9×6 cases** (intérieur), case **25 mm** - Support rigide (plastifié recommandé) - Éclairage uniforme sans reflets .. warning:: Imprimer sur fond blanc mat. Plastifier sans brillance pour éviter les reflets. Ne pas utiliser d'écran LCD (déformation optique). Procédure --------- Étape 1 — Capture des paires ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash python src/calibration/stereo_capture.py - Lance les 2 webcams simultanément (USB 0 et 1) - Appuyer sur ``ESPACE`` pour capturer une paire - Objectif : **30 paires valides** minimum - Varier : distance (0.3–1.5 m), inclinaison (±30°), position dans frame .. tip:: Couvrir les 4 coins du champ + centre. Inclure des poses inclinées pour mieux contraindre les coefficients de distorsion tangentielle. Étape 2 — Calibration ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash python src/calibration/stereo_calibrate.py Résultat attendu : .. code-block:: text Chargement 30 paires de damier... Calibration stéréo... RMS reprojection error: 0.42 px ← bon si < 0.8 px Sauvegarde: config/stereo_calib.yaml Fichier YAML généré ------------------- ``config/stereo_calib.yaml`` contient : .. code-block:: yaml K1: [[fx, 0, cx], [0, fy, cy], [0, 0, 1]] # caméra gauche D1: [k1, k2, p1, p2, k3] # distorsion gauche K2: [[fx, 0, cx], [0, fy, cy], [0, 0, 1]] # caméra droite D2: [k1, k2, p1, p2, k3] # distorsion droite R: [[...], [...], [...]] # rotation C2→C1 T: [tx, ty, tz] # translation (baseline) E: [[...]] # matrice essentielle F: [[...]] # matrice fondamentale R1, P1, R2, P2, Q # rectification Paramètres OpenCV ----------------- ``stereoCalibrate`` avec flags : .. code-block:: python flags = ( cv2.CALIB_FIX_INTRINSIC # si calibration individuelle faite avant # ou cv2.CALIB_RATIONAL_MODEL # pour modèle 8 coefs ) criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 1e-5) ``stereoRectify`` avec ``alpha=0`` (recadrage maximal, pas de bandes noires). Validation ---------- Après calibration, vérifier : 1. Erreur RMS < 0.8 px (idéalement < 0.5 px) 2. Lignes épipolaires horizontales sur image rectifiée 3. Translation T ≈ [−0.11, 0, 0] m (baseline sur axe X) 4. Épipole à l'infini (caméras parallèles après rectif) .. code-block:: bash # Visualisation rectification python src/calibration/stereo_calibrate.py --show-rectified Références ---------- :cite:`bradski2008learning` — OpenCV stereoCalibrate, stereoRectify. :cite:`ferrera2019underwater` — Prise en compte réfraction eau/verre.