wiki: camera live view decision; MJPEG install step; park-lab camera addresses vs 11-15 record
Build & push images / images (push) Successful in 4m31s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 12:48:50 +01:00
parent 39fb5fb7c2
commit c6087b990c
7 changed files with 159 additions and 4 deletions
@@ -198,6 +198,8 @@ the actual booth PC to test on.
- **Vision monitors the RTSP livestream continuously** for presence — rejected: rebuilds (worse) what
the camera already does (presence), pegs the appliance CPU 24/7, and the leave-detection heuristic
is no cleaner than a 30 s timeout.
(This is about *inference* on the stream. An operator **watching** a camera while a car is
present is a different thing, built 2026-11-17 — see [[camera-live-view]].)
- **Vision polls every ~1 s to track THE car, segment a queue, count cars, read make/model** — a
genuinely harder need (bumper-to-bumper cars the camera can't tell apart). Set ASIDE, not dismissed:
it needs a general vehicle DETECTOR ([[opencv-anpr-service]] is plate-only today) + "same-car-vs-new"
+14 -3
View File
@@ -107,17 +107,28 @@ Two cameras mounted on **one physical lane that serves both directions** (user,
| | Entry camera | Exit camera |
|---|---|---|
| Address | `10.0.10.6` | `10.0.10.7` |
| Model | DS-2CD1043G2-LIU (4MP) | DS-2CD1083G2-LIU (8MP) |
| Sub-stream (102) | 640×360 H.264, 12.5 fps, keyframe every 4 s | 640×360 H.264, 20 fps, keyframe every 2.5 s |
| Model | DS-2CD1083G2-LIU (8MP, V5.8.4) | DS-2CD1043G2-LIU (4MP, V5.8.10) |
| Sub-stream (102) | 640×360 **MJPEG**, 12.5 fps (was H.264, keyframe every 4 s) | 640×360 **MJPEG**, 20 fps (was H.264, keyframe every 2.5 s) |
| Line crossing / intrusion (`ISAPI/Smart/LineDetection`, `FieldDetection`) | `notSupport` | `notSupport` |
| Motion detection | on, target `vehicle`, grid drawn | on, target `vehicle`, grid drawn |
| Alarm server (`httpHosts`) | not set (`0.0.0.0`) | not set (`0.0.0.0`) |
Read from the cameras over ISAPI the same day; bench snapshot results are on [[lpr-camera]].
> **Addresses vs. the 2026-11-15 record (2026-11-17):** read again over ISAPI, `.6` answers as
> DS-2CD1083G2-LIU (8MP, V5.8.4, main 3840×2160 12.5 fps) and `.7` as DS-2CD1043G2-LIU (4MP,
> V5.8.10, main 2560×1440 20 fps) — every attribute swapped as a set against the 2026-11-15 bench
> table on [[lpr-camera]], so the two units most likely traded addresses between the bench and the
> park-lab mount. Directions hold (the OSD reads "Hyrje" on `.6`, "Dalje" on `.7`); the table above
> shows the current state. The same day both sub-streams were switched to **MJPEG** for the booth
> live view ([[camera-live-view]]): every frame is now a keyframe, so item 1's "≤ 1 s I-frame"
> concern no longer applies to these units; the watcher would decode MJPEG (OpenCV can) at
> ~300 KB/s per camera.
- The 8MP model has no line crossing either, so the constraint above holds for both: the booth PC
does the tracking.
- Both sub-stream keyframe intervals are above the ≤ 1 s this design asks for (item 1).
- ~~Both sub-stream keyframe intervals are above the ≤ 1 s this design asks for (item 1).~~
Moot since the switch to MJPEG (2026-11-17).
- Neither camera pushes to park-lab yet, and neither is in its device registry.
- [[k200l-printer]] records `10.0.10.7` as the park-lab printer's fixed address — the exit camera
now answers there. To be resolved with the user.
@@ -206,6 +206,11 @@ convention so far: `admin` / `admin123` on the first units (change per site and
2. **Streams:** the snapshot the app pulls MUST come from the **sub stream** (`102`) — the main
stream's ISAPI snapshot returns **503 instantly, always, on this model**. Set the sub stream to
the highest resolution the camera allows.
**Set the sub stream's video encoding to MJPEG** — the booth camera tiles stream it live
([[camera-live-view]]); with H.264 the tile stays on the snapshot and says why. The `102`
snapshot still returns a JPEG after the switch (measured on the G2 line, 2026-11-17).
With the snapshot stream on Sub, its resolution is also the ANPR resolution (MJPEG on the G2:
640×360, 640×480 or 1280×720).
3. **Event push:** Event → Motion Detection with the AcuSense **Detection Target = Vehicle** filter
ON, "Notify Surveillance Center" on, then Alarm Settings → **Alarm Server** →
`http://10.0.10.203/api/devices/hikvision/<deviceId>/event`. The `deviceId` exists only after
+114
View File
@@ -0,0 +1,114 @@
---
type: decision
tags: [parking, camera, ui, booth, video, hikvision]
sources: []
updated: 2026-11-17
status: settled
---
# Camera Live View — Booth Camera Tiles
The booth operator can open a small tile per camera from the [[device-status-monitoring|device
footer]] and watch that camera live while a vehicle is in front of it. **BUILT 2026-11-17**;
verified end to end against the two park-lab cameras through the real server and in a browser
(not yet in the [[desktop-shell-tauri|desktop shell]] — see *Not yet verified*).
## What the user asked for (2026-11-17)
- The camera chips in the footer are clickable; a click opens that camera's tile in the bottom
right, about 15 % of the screen wide. A second camera's tile stacks to the **left** of the first.
- A tile closes with ✕; which tiles are open is a **user preference** (restored on login).
- A tile rests on the **latest entry/exit snapshot** of that camera; when the camera's vehicle
events reach the booth, it shows **live video**.
## Decision
| Question | Choice | Why |
|---|---|---|
| Video source | The camera's **sub-stream (x02) set to MJPEG**, pulled over **RTSP** | The G2 firmware answers the HTTP MJPEG preview (`/ISAPI/Streaming/channels/102/httpPreview`) with `notSupport`; RTSP offers MJPEG as RTP/JPEG (RFC 2435). Every MJPEG frame is a whole picture, so a view is live ~150 ms after connect — H.264 would wait for a keyframe (every 2.5–4 s on these cameras) and need a decoder. |
| Where it runs | **In the server process**, as a driver capability (`LiveStreamDevice`) in `packages/devices` | No sidecar container (camera config + `localAddress` already live in the DB; the [[device-adapter-pattern]] keeps the protocol in the driver). The server reassembles JPEG frames from RTP packets — about 450 small packets/s for two cameras; it never decodes or re-encodes. |
| Fan-out | **One RTSP session per camera**, shared by every viewer, torn down 5 s after the last leaves | A camera has few stream slots and the [[lane-presence-and-anpr-entry|ANPR loop]] pulls stills from the same unit. |
| Delivery to the page | A **WebSocket per open tile** (`/api/cameras/:id/live`), one JPEG per binary message, **latest frame only**, capped at 10 fps per viewer | Works in the desktop shell, whose webview cannot carry the session cookie on an `<img>`/`<video>` request (the WS already solves that with a ticket). A viewer whose socket still holds > 256 KB unsent skips frames — server memory stays bounded. |
| When live | **Per camera**, while that camera pushes vehicle events (same 30 s TTL as lane busy/free) | On a shared lane (park-lab) only the camera that saw the car goes live; lane state would light both. |
| Auth | Same handshake as `/api/ws` (Origin allowlist, then desktop ticket or cookie), then `device:read` | One helper (`authenticateWsHandshake`) for every socket route, so they cannot drift. The resting snapshot needs `session:read` (it is evidence). |
| Preference | `users.open_cameras` (JSON id list, migration 0033), `PUT /api/auth/open-cameras` | Same shape as language / theme / font scale. |
**Advisory viewing only.** Nothing here writes to the ledger, gates a ticket or opens a barrier.
### Not a reversal of the "livestream" rejection
[[lane-presence-and-anpr-entry]] rejected *vision monitoring the RTSP livestream continuously for
presence* — inference on every frame, 24/7. This is an operator **watching** video, only while a
vehicle is present, with no inference at all.
## Measured on park-lab (2026-11-17)
Cameras (read from `ISAPI/System/deviceInfo` the same day): `10.0.10.6` entry =
**DS-2CD1083G2-LIU** (8MP, V5.8.4), `10.0.10.7` exit = **DS-2CD1043G2-LIU** (4MP, V5.8.10).
Both offer `H.264, H.265, MJPEG` on channel 102 and only two streams (101, 102). Channel 102 on
both was switched from H.264 to **MJPEG** (640×360; other settings unchanged) with the user's
agreement.
- **RTSP:** first frame 110–155 ms after PLAY; `.6` 12.5 fps ≈ 310 KB/s, `.7` 20 fps ≈ 270 KB/s;
RFC 2435 type 1 (4:2:0), Q 63 / 48 (no in-band tables), no restart markers, padding on each
frame's last packet. `Session: …;timeout=60`; a 150 s session ran without drops with and
without keepalive (a `GET_PARAMETER` is sent every timeout/2 anyway).
- **Interference with ANPR stills** (what was measured — one camera at a time, one stream):
- main-stream stills (`101/picture`, back-to-back, ~15–20 s) with an RTSP stream starting
mid-run: `.6` 0/87 → 0/110 HTTP 503; `.7` 4/55 → 4/71 (the `.7` 503s occur without the
stream too — the transient `deviceBusy` the driver retries). Starting a stream added none.
- sub-stream stills (`102/picture`, back-to-back) while 102 streams MJPEG over RTSP for 180 s:
`.6` 2121/2121 and `.7` 3187/3187 HTTP 200 (baselines without the stream, 60 s: 672/672 and
594/594); the stream held 12.0 / 20.0 fps throughout.
- Not measured: several live sessions on one camera at once (the hub opens one), a stream
alongside a browser left on the camera's web UI, and the G3H model.
- `102/picture` returns a 640×360 JPEG after the codec switch.
- **End to end** (server + scratch DB + both cameras, 2026-11-17): a simulated vehicle push →
`camera-activity` on `/api/ws`; two viewers on the entry camera and one on the exit camera went
`connecting → live` in 151 / 181 ms, 8–10 fps each, zero malformed JPEGs.
## Install step (new)
Set the camera's **sub-stream (102) video encoding to MJPEG** (web UI: Configuration → Video/Audio
→ Video → Sub Stream, or `PUT /ISAPI/Streaming/channels/102` with `videoCodecType=MJPEG`). With
H.264 the tile says *"camera stream is H264, not MJPEG"* and stays on the snapshot. Added to
[[site-device-installation]] §3. On a camera whose snapshot stream is set to **Sub** (the G3H
workaround), the sub-stream resolution is both the ANPR/evidence still and the live view — MJPEG on
the G2 offers 640×360, 640×480 or 1280×720 on channel 102; raising it costs bandwidth (~300 KB/s
at 640×360). Dahua cameras have no live view yet (tile shows the reason).
## Consequences elsewhere
- [[passage-confirmation]] planned to decode the **H.264** sub-stream. On a camera set up for live
view that stream is now MJPEG: OpenCV decodes it too, every frame is a keyframe (the "≤ 1 s
I-frame" requirement disappears), at ~5–10× the bandwidth (~300 KB/s per camera on the device
VLAN). The two consumers should share one RTSP session per camera when that is built.
- **Unverified, probably broken today:** the existing snapshot thumbnails
(`SnapshotStrip`, `WashDesk`) use `<img src="/api/snapshots/:id">` — a relative, cookie-authed
URL that the desktop shell's webview cannot authenticate. The camera tile fetches its snapshot
through `platformFetch` instead. Check on a desktop install.
## Verified in a browser (2026-11-17)
Headless Firefox against the server with both park-lab cameras and a simulated vehicle push:
footer chips open tiles bottom-right (≈ 15 % wide, first opened rightmost, next to its left), each
resting on its camera's latest snapshot with direction and time; after the entry camera's push only
the entry tile went **LIVE** (live OSD clock); a reload restored both tiles; ✕ closed one and the
saved preference followed.
## Not yet verified
- The Tauri/WebKitGTK shell (binary WS frames through `@tauri-apps/plugin-websocket` arrive as a
number array over IPC — fine at 10 fps × 25 KB, to be measured). Its CSP already allows `blob:`
images.
- Through Caddy (`reverse_proxy` upgrades WebSockets; not exercised).
- The live → snapshot return 30 s after the last push in the browser (covered by unit tests only).
- A real vehicle push from the cameras (park-lab's alarm server is not set yet — see
[[passage-confirmation]] park-lab rig).
## Where the code is
`packages/devices/src/drivers/rtsp-mjpeg.ts` (RTSP client), `rfc2435.ts` (frame reassembly,
fixture-tested against frames verified with a JPEG decoder), `camera.ts` (`openLiveStream` on
Hikvision); `apps/server/src/camera-live.ts` (hub), `camera-activity.ts`, `routes/cameras.ts`;
`apps/web/src/ui/CameraDock.tsx`, `ui/DeviceFooter.tsx`. Knob: `CAMERA_LIVE_MAX_FPS` (10).
+4
View File
@@ -235,6 +235,10 @@ replacement for the `G3H` above. Credentials are in the device registry, not her
| `channels/102/picture` (sub), 5 pulls | 5/5 **200**, 640×360 | 5/5 **200**, 640×360 |
| 8 simultaneous `101/picture` pulls, 3 rounds | 11 × 200, 13 × **503** | 10 × 200, 14 × **503** |
> As mounted at park-lab (read 2026-11-17) the two units sit at the **opposite** addresses to this
> bench table: `.6` = the 8MP 1083G2 (entry), `.7` = the 4MP 1043G2 (exit). See
> [[passage-confirmation]] "park-lab rig". Both now run the sub-stream as MJPEG ([[camera-live-view]]).
- **The 8MP `DS-2CD1083G2-LIU` does not have the `G3H` bug.** Main-stream ISAPI snapshot returns a
full-resolution JPEG every time when pulled one at a time. The 4MP `1043G2` confirms the
park-buzi `:8081` result above on a second unit.
+2 -1
View File
@@ -127,7 +127,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 9 decision records.
- [[blocklist]] — barred plates/cards refused at entry (never at exit); signed, attributed.
## Concepts — frontend / operator UI
- [[booth-console]] — operator-UI architecture: TanStack Query/Router + Zustand + Tailwind terminal theme; one /api/ws live feed (anti-CSWSH); shift control + device-status footer.
- [[booth-console]] — operator-UI architecture: TanStack Query/Router + Zustand + Tailwind terminal theme; one /api/ws live feed (anti-CSWSH); shift control + device-status footer (camera chips open live tiles — [[camera-live-view]]).
- [[i18n]] — Albanian default + English; per-user server-stored language preference (users.language), loaded on login; tickets stay Albanian.
## Dev environment (reference)
@@ -147,6 +147,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 9 decision records.
- [[device-discovery-roadmap]] — memo (open): how each known device class gets a wizard Scan — SADP + ONVIF for cameras (verified on the lab VLAN), 9100 sweep + fingerprint for printers, Dingtian relay multicast search, Dahua 37810; the reusable method and rules from the DT-008 work.
- [[forgiven-exit]] — decision + as-built (2026-10-08): owner opens the EXIT barrier with no payment — a signed zero-amount payment carrying the forgone fee as its own Z-report line (never in cash/card), exit only, admin permission + open shift, reason optional, prints nothing.
- [[vision-service-packaging]] — the vision service lives in this monorepo (apps/vision/), separate process, wired into Turbo via a package.json shim; uv-managed Python.
- [[camera-live-view]] — BUILT 2026-11-17: booth camera tiles from the device footer — latest snapshot at rest, live video while that camera sees a vehicle; sub-stream MJPEG over RTSP, reassembled in-process (RFC 2435), one shared session per camera, latest-frame WS delivery; open tiles a user preference. Measured: live in ~150 ms, no extra ANPR 503s.
- [[event-streams-split]] — split the signed business ledger (ledger_events) from unsigned device telemetry (device_events).
- [[desktop-shell-tauri]] — ✅ Tauri v2 chosen over Electron for the desktop kiosk shell; thin wrapper, server keeps all logic. Best case Ubuntu 26.04 LTS (resolves WebKitGTK); worst case Windows+WSL → kiosk browser, no native shell. Auto-updater mirrors signed releases to public `mca/public_releases` (source repo is private — field appliances have no Gitea creds).
- [[party-ledger]] — 🟡 DESIGN (2026-09-08, not built): counterparty sub-ledger for who-owes-whom across modules — parties + signed `charge` / settlement / `write_off` events, balance derived never stored, aging + statements + CSV; lands postpaid subscriptions, hotel guest-nights, fleet washes on account, supplier/utility bills. Sub-ledger only: no bookkeeping, statements are not fiscal invoices, parties per appliance.
+18
View File
@@ -3689,3 +3689,21 @@ body. With `Cookie: session=<id>` the read works — so on sw V3.1.6236A the ses
usable gate, unlike the V3.1.5461A finding. The driver supports `sessionId` but Setup has no field
for it. Filed on [[dingtian-relay]]. Resolved the same day: HTTP Auth off (needs the page's
Save), then the expected `input_link_relay` warning, fixed by the save; relay now saved on park-lab.
## [2026-11-17] query | Booth camera tiles — live entry/exit video in the footer (built)
User asked for live video of entry and exit when a vehicle is in the zone: footer camera chips open
tiles (bottom right, ~15 % wide, stacking leftwards, open set saved per user), resting on the latest
snapshot and going live on the camera's vehicle events. Probed park-lab: the G2 firmware refuses the
HTTP MJPEG preview (`notSupport`) but serves MJPEG over RTSP (RTP/JPEG); switched both cameras'
channel 102 to MJPEG with the user's agreement. Measured: live ~150 ms after PLAY, no extra 503s on
ANPR stills with a stream starting, 150 s sessions stable. Built in-process (RTSP client + RFC 2435
reassembly in the driver, one shared session per camera, latest-frame WS delivery, per-camera
activity), migration 0033 (`users.open_cameras`, snapshot device/time index). Verified end to end
through the real server against both cameras and rendered in headless Firefox; Tauri shell and Caddy
not yet exercised. 102 stills while 102 streams: 5308/5308 HTTP 200 over 180 s per camera.
Found: the cameras' addresses disagree with the 2026-11-15 record — `.6` now answers as the 8MP 1083,
`.7` as the 4MP 1043, every attribute swapped as a set (likely re-addressed when mounted); noted on
[[passage-confirmation]] and [[lpr-camera]]. Flagged: existing snapshot `<img>` thumbnails
probably do not load in the desktop shell. Filed [[camera-live-view]]; updated
[[site-device-installation]] §3 (MJPEG step), [[lane-presence-and-anpr-entry]] (rejection scope).