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:
@@ -146,6 +146,7 @@ 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:
|
||||||
|
for attempt in range(3):
|
||||||
try:
|
try:
|
||||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||||
fichier_camera = gp.CameraFile()
|
fichier_camera = gp.CameraFile()
|
||||||
@@ -156,6 +157,10 @@ class Camera:
|
|||||||
log.info(f"Photo capturee (DSLR) : {chemin_dest}")
|
log.info(f"Photo capturee (DSLR) : {chemin_dest}")
|
||||||
return chemin_dest
|
return chemin_dest
|
||||||
except gp.GPhoto2Error as e:
|
except gp.GPhoto2Error as e:
|
||||||
|
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}")
|
log.error(f"Erreur capture DSLR : {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user