Files
appRobotWebcam/doc/12_cameraConfig_roadmap.md
2026-06-07 09:08:20 +02:00

118 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Roadmap Dynamische Kamera-Konfiguration (config.html)
**Ziel:** Live-Auflösung pro Kamera zur Laufzeit umschalten, ohne Datei-Editor oder Container-Restart.
---
## Kontext
Alle drei Kameras (C270, C920, C922) unterstützen dieselben MJPEG-nativen Auflösungen:
| Auflösung | Pixel | Faktor ggü. 640×480 |
|-----------|-------|----------------------|
| 160×120 | 19'200 | 96% |
| 320×240 | 76'800 | 83% |
| 640×360 | 230'400 | 53% (16:9) |
| 640×480 | 307'200 | Referenz (aktuell) |
| 800×600 | 480'000 | +56% |
| 1280×720 | 921'600 | +200% |
Nur MJPEG-native Auflösungen verwenden sonst fällt V4L2 auf YUYV (unkomprimiert) zurück
und FFmpeg muss software-encoden (~50% CPU pro Kamera).
**Priorität:** Latenz > CPU > Bildqualität. Bandbreite ist der Engpass beim Internet-Zugriff.
---
## Geplante UI: `/config.html`
Separate Admin-Seite (kein Viewer-Umbau nötig). Pro Kamera eine Zeile:
```
┌─────────────────────────────────────────────────────┐
│ Kamera-Konfiguration │
├──────────┬────────────┬──────────┬──────────────────┤
│ cam0 │ Kamera 0 │ [320×240 ▼] │ Live: 320×240│
│ cam1 │ Kamera 1 │ [640×360 ▼] │ Live: 640×360│
│ cam2 │ Kamera 2 │ [Aus ▼] │ Live: aus │
├──────────┴────────────┴──────────┴──────────────────┤
│ [Speichern & Neu starten] │
└─────────────────────────────────────────────────────┘
```
**ComboBox-Optionen pro Kamera:**
- `Aus` → Stream deaktivieren (`stream: false`)
- `160×120`
- `320×240`
- `640×360`
- `640×480` (aktuell Default)
- `800×600`
- `1280×720`
---
## Implementierung
### Phase 1 API-Endpunkt (server.js / neues Modul)
**GET `/api/config`** → liefert aktuelle Konfiguration aller Kameras:
```json
{
"cameras": [
{ "id": "cam0", "liveSize": "320x240", "stream": true },
...
]
}
```
**POST `/api/config`** → nimmt neue Konfiguration entgegen:
```json
{
"cameras": [
{ "id": "cam0", "liveSize": "640x360", "stream": true },
{ "id": "cam1", "liveSize": "320x240", "stream": true },
{ "id": "cam2", "stream": false }
]
}
```
Ablauf im Handler:
1. Validierung (nur erlaubte Auflösungen akzeptieren)
2. `cameras.json` aktualisieren
3. Pro geänderter Kamera: Live-FFmpeg stoppen (`_killCurrentAndWait`) + mit neuen Params neu starten (`_spawnLive`) kein Container-Restart nötig
### Phase 2 `config.html` (statische Seite in `/public`)
- Liest beim Laden `GET /api/config`
- Zeigt pro Kamera ein `<select>` mit den erlaubten Auflösungen
- `[Speichern]``POST /api/config` → Erfolgsmeldung
- Keine Authentifizierung (ist im internen Netz, wie der Viewer)
### Phase 3 Hot-Reload in CameraSwitch
Neue Methode `reconfigure({ liveSize, stream })` in `CameraSwitch`:
- Wenn `stream: false``_killCurrentAndWait()`, kein Neustart
- Wenn `liveSize` geändert → `_killCurrentAndWait()` + `this.liveSize = newSize` + `_spawnLive()`
- Wenn nichts geändert → no-op
---
## Abgrenzung (nicht im Scope dieser Roadmap)
- MJPEG Re-Encode-Qualität (`-q:v`) → separates Thema, eigene Env-Variable
- `liveFps` per Kamera → triviale Erweiterung, analog zu `liveSize`
- Authentifizierung auf `/config.html` → wenn Internet-Zugang geplant
- `hiresSize` per Kamera (HD-Grab) → bereits in cameras.json, kein UI nötig
---
## Manueller Test (sofort möglich, ohne diese Roadmap)
`cameras.json` direkt bearbeiten und Container neu starten:
```json
{ "id": "cam0", ..., "liveSize": "320x240" }
```
Details: siehe unten im Gesprächsprotokoll / `09_Bug_reports.md`.