Capture : viewfinder=0 avant prise (AF phase-détection), timeout 20s, spinner UI
- camera.py : désactiver LiveView avant capture (viewfinder=0) → miroir abaissé → AF phase-détection Canon actif. Remplace _declencher_af_liveview (autofocusdrive=1 pouvait bloquer sur certains corps Canon). activer_viewfinder() après la prise. - main.py : fix bug global _preview_actif dans api_capturer (était variable locale, le global restait True). Timeout asyncio 20s sur run_in_executor pour éviter freeze permanent si capture bloque. Logs INFO avant/après capture. - camera.js + index.html + style.css : spinner "Capture en cours..." entre le flash et l'affichage du résultat. Cacher le spinner dans afficherErreurCapture aussi. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -146,24 +146,22 @@ class Camera:
|
||||
else:
|
||||
return self._capture_simulation(chemin_dest)
|
||||
|
||||
def _declencher_af_liveview(self):
|
||||
"""Déclenche l'autofocus LiveView Canon avant la capture (best-effort)."""
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
af = cfg.get_child_by_name("autofocusdrive")
|
||||
af.set_value(1)
|
||||
self.camera.set_config(cfg)
|
||||
time.sleep(0.4) # Attendre que l'AF se verrouille
|
||||
except Exception:
|
||||
pass # Non supporté sur ce modèle ou en mode MF
|
||||
|
||||
def _capture_gphoto2(self, chemin_dest: Path) -> Path | None:
|
||||
from PIL import Image as PILImage
|
||||
|
||||
for attempt in range(3):
|
||||
try:
|
||||
with self._gp_lock:
|
||||
self._declencher_af_liveview()
|
||||
# Désactiver LiveView : miroir abaissé → AF phase-détection Canon disponible
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
vf = cfg.get_child_by_name("viewfinder")
|
||||
vf.set_value(0)
|
||||
self.camera.set_config(cfg)
|
||||
time.sleep(0.2) # Laisser le miroir descendre
|
||||
except Exception:
|
||||
pass
|
||||
log.info(f"Déclenchement capture DSLR (tentative {attempt+1}/3)")
|
||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||
fichier_camera = gp.CameraFile()
|
||||
self.camera.file_get(
|
||||
|
||||
Reference in New Issue
Block a user