API für .npz empfang
This commit is contained in:
47
README.md
47
README.md
@@ -61,7 +61,7 @@ Vollständige Kamera-Metadaten. Primärer Einstiegspunkt für andere Container.
|
||||
}
|
||||
```
|
||||
|
||||
`calibrationUrl` fehlt, wenn keine `.npz` unter `data/calibration/{id}/` liegt.
|
||||
`calibrationUrl` fehlt, solange noch keine `.npz` für diese Kamera vorhanden ist.
|
||||
`encode`: `"copybsf"` (MJPEG-Copy, Default) | `"mjpeg"` (Re-Encode) | `"h264"` (GPU, MSE).
|
||||
`mseCodec`: nur bei `encode="h264"` gesetzt, z.B. `"avc1.4D001F"`.
|
||||
|
||||
@@ -87,6 +87,51 @@ K, D = d["camera_matrix"], d["dist_coeffs"]
|
||||
|
||||
---
|
||||
|
||||
### `PUT /api/cameras/{id}/calibration`
|
||||
|
||||
Nimmt eine neue `.npz`-Datei entgegen (Homing-Prozess → Webcam-Service).
|
||||
Schreibt zwei Dateien nach `data/calibration/{id}/`:
|
||||
|
||||
| Datei | Zweck |
|
||||
|---|---|
|
||||
| `calibration_YYYYMMDD_HHMMSS.npz` | Archiv (bleibt erhalten) |
|
||||
| `calibration.npz` | Aktuell — wird bei jedem PUT überschrieben |
|
||||
|
||||
Existiert beim ersten Aufruf nur `calibration.npz` (noch kein Archiv), wird sie
|
||||
anhand ihres `mtime` automatisch in `calibration_<ts>.npz` umbenannt, bevor die
|
||||
neue Datei abgelegt wird.
|
||||
|
||||
```
|
||||
Content-Type: application/octet-stream
|
||||
Body: rohe .npz-Bytes
|
||||
```
|
||||
|
||||
```json
|
||||
// Response 200
|
||||
{ "id": "cam0", "saved": "calibration_20260610_143022.npz", "size": 1284, "calibrationUrl": "/api/cameras/cam0/calibration" }
|
||||
```
|
||||
|
||||
Der In-Memory-Buffer wird sofort aktualisiert — `GET /api/cameras/cam0/calibration`
|
||||
liefert ab diesem Moment die neue Datei, ohne Server-Neustart.
|
||||
|
||||
400 bei leerem Body, 404 bei unbekannter Kamera-ID.
|
||||
|
||||
Aufruf aus Python (Homing):
|
||||
|
||||
```python
|
||||
import requests
|
||||
with open("cam0_calibration.npz", "rb") as f:
|
||||
r = requests.put(
|
||||
"http://thinkcentre.local:8444/api/cameras/cam0/calibration",
|
||||
data=f,
|
||||
headers={"Content-Type": "application/octet-stream"},
|
||||
)
|
||||
r.raise_for_status()
|
||||
print(r.json()) # {'id': 'cam0', 'saved': 'calibration_20260610_143022.npz', ...}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/snapshot/{id}`
|
||||
|
||||
Letztes Live-JPEG (Live-Auflösung, z.B. 640×480) aus dem RAM-Puffer.
|
||||
|
||||
Reference in New Issue
Block a user