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:
2026-06-10 13:51:51 +02:00
parent d02cc90fee
commit 4f12f77106
5 changed files with 58 additions and 15 deletions

View File

@@ -402,6 +402,33 @@ html, body {
100% { opacity: 0; }
}
.capture-en-cours {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1.5rem;
background: rgba(0,0,0,0.6);
z-index: 15;
font-size: 1.4rem;
color: #fff;
}
.capture-spinner {
width: 60px;
height: 60px;
border: 6px solid rgba(255,255,255,0.3);
border-top-color: #fff;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.capture-info {
position: absolute;
bottom: 2rem;

View File

@@ -97,6 +97,10 @@
<span id="chiffre-car">3</span>
</div>
<div id="flash-blanc" class="flash-blanc cache"></div>
<div id="capture-en-cours" class="capture-en-cours cache">
<div class="capture-spinner"></div>
<span>Capture en cours...</span>
</div>
<div class="capture-info">
<span id="capture-compteur"></span>
</div>

View File

@@ -11,6 +11,7 @@ const EMOJI_CAR = { 3: '🤪', 2: '😱', 1: '🔥' };
function afficherErreurCapture(titre, detail = '') {
arreterPreview();
document.getElementById('capture-en-cours')?.classList.add('cache');
const el = document.getElementById('preview-erreur-camera');
if (!el) { allerA('accueil'); return; }
el.querySelector('p').textContent = titre;
@@ -129,9 +130,11 @@ async function lancerCapture() {
if (captureAbortee) return;
afficherFlash();
document.getElementById('capture-en-cours').classList.remove('cache');
const promesseCapture = apiPost('/api/capturer').catch(() => null);
let resultat = await promesseCapture;
document.getElementById('capture-en-cours').classList.add('cache');
let erreurReseau = false;
if (!resultat) {