Fix capture DSLR: pause avant capture + retry si I/O in progress

- Frontend: arrete le preview 300ms avant la capture
- Backend: 3 tentatives avec 500ms entre chaque si DSLR occupe

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 19:27:54 +02:00
parent 053e5dc7b4
commit 79b0084178
2 changed files with 20 additions and 13 deletions

View File

@@ -146,18 +146,23 @@ class Camera:
return self._capture_simulation(chemin_dest) return self._capture_simulation(chemin_dest)
def _capture_gphoto2(self, chemin_dest: Path) -> Path | None: def _capture_gphoto2(self, chemin_dest: Path) -> Path | None:
try: for attempt in range(3):
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE) try:
fichier_camera = gp.CameraFile() chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
self.camera.file_get( fichier_camera = gp.CameraFile()
chemin_camera.folder, chemin_camera.name, gp.GP_FILE_TYPE_NORMAL, fichier_camera self.camera.file_get(
) chemin_camera.folder, chemin_camera.name, gp.GP_FILE_TYPE_NORMAL, fichier_camera
fichier_camera.save(str(chemin_dest)) )
log.info(f"Photo capturee (DSLR) : {chemin_dest}") fichier_camera.save(str(chemin_dest))
return chemin_dest log.info(f"Photo capturee (DSLR) : {chemin_dest}")
except gp.GPhoto2Error as e: return chemin_dest
log.error(f"Erreur capture DSLR : {e}") except gp.GPhoto2Error as e:
return None if "I/O in progress" in str(e) and attempt < 2:
log.warning(f"DSLR occupe, retry {attempt + 1}/3...")
time.sleep(0.5)
continue
log.error(f"Erreur capture DSLR : {e}")
return None
def _capture_webcam(self, chemin_dest: Path) -> Path | None: def _capture_webcam(self, chemin_dest: Path) -> Path | None:
if not self.webcam or not self.webcam.isOpened(): if not self.webcam or not self.webcam.isOpened():

View File

@@ -46,9 +46,11 @@ async function lancerCapture() {
} }
await compteARebours(); await compteARebours();
afficherFlash();
arreterPreview(); arreterPreview();
await pause(300); // Laisser le DSLR se liberer du preview
afficherFlash();
const resultat = await apiPost('/api/capturer'); const resultat = await apiPost('/api/capturer');
if (resultat.erreur) { if (resultat.erreur) {