wiki: H.264 test on park-lab, event-driven refactor decided

- zone-anpr-poc: H.264 instead of MJPEG (load, delay, a car in the zone,
  staff traffic, bad weather); the relay-less test copy is left running
- event-driven-refactor (new): the user's decisions of 2026-11-23, what
  is not decided, what they touch in today's code; waits for the user's
  guidelines
- passage-confirmation: the 2026-11-19 phase order superseded; where the
  video work lives
- vision-hardening, zone-anpr-poc-review: on-screen label read as a
  plate (moved by the user), day-time oversized box, still pause carried
  over
- pointers on vision-service, camera-live-view, lane-presence-and-anpr-entry,
  dingtian-vs-mqtt, entry gates, standing decisions, open questions,
  overview, index

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZgP5oZdzvo92Eouc9eRv5
This commit is contained in:
2026-11-23 12:02:18 +01:00
parent 980a3e5178
commit dd2dd53d7e
17 changed files with 478 additions and 21 deletions
+179 -1
View File
@@ -2,7 +2,7 @@
type: concept
tags: [parking, vision, anpr, passage, relay, poc, park-lab]
sources: []
updated: 2026-11-22
updated: 2026-11-23
---
# Zone ANPR PoC — field trials on park-lab
@@ -20,6 +20,11 @@ deferred to a later session, and the work list is on [[vision-hardening]].
off beforehand. The user's rule for now: *the barrier is operated only with the staff's remote
control; our system is not ready to control the barrier yet.*
**Back for one test (user, 2026-11-23):** a copy with **no relay board configured** (container
`zg-h264`) runs on H.264 sub-streams, to see what decoding costs. `zg2` stays stopped. See
"H.264 instead of MJPEG" below. **Left running (user, 2026-11-23):** in this state it is
harmless, no relay is armed or configured. The cameras' sub-streams stay on H.264 with it.
- **Seeing the car:**
- the **low-res MJPEG stream** (1280×720), about 5 frames a second through YOLOX-Tiny on the Intel
iGPU;
@@ -362,6 +367,179 @@ it's open."*
as A → B and drive-outs as "other direction". The exit camera is not used for crossing
verdicts. Whether it still opens R1 or reads plates for drive-outs is not yet decided.
## H.264 instead of MJPEG (2026-11-23)
**Why (user).** The server should hold no video or image work. MJPEG let it pass frames along
undecoded, which locks the system to cameras that offer MJPEG. A camera that streams only H.264
or H.265 has to be decoded somewhere, and that place is the vision side. The test: switch the
sub-streams to H.264, decode them in the PoC, show a live picture on its page, and watch the
booth PC's load.
**Set-up.**
- Container `zg-h264` on park-lab: the same image and code, `config-h264test.json`, records in
`out-h264test/`, page on port 8094. Its config names **no relay board** and it has no relay
password, so its arm button has nothing to send to. Restart policy `no`.
- The PoC gained a **live picture** for the page (`/live/<camera>.mjpg`): every decoded frame is
re-encoded as a JPEG once, for all viewers, and only while somebody watches. Before, the page
fetched a still every 700 ms. The metrics gained the codec, the network intake, the viewers and
the time from connecting to the first picture.
- Decoding is in software (FFmpeg inside OpenCV 4.13), RTSP over TCP, with FFmpeg's `nobuffer`
and `low_delay` set. The detector stays on the iGPU.
- **Camera change:** channel 102 on both cameras went from MJPEG to **H.264** (Main profile), with
a keyframe about every second (GOP 12 on the entry camera, 20 on the exit camera). Resolution,
frame rate and the 1024 kbps VBR cap were left as they were. The settings from before are saved
on park-lab as `~/zone-anpr-gpu/h264test/cam6-102-before.xml` and `cam7-102-before.xml`; a PUT
of those files puts MJPEG back.
**Measured** (21 ten-second windows each, empty lane, one viewer on each camera's live picture):
| | MJPEG | H.264 |
|---|---|---|
| Process CPU, of 6 cores | 0.40 | 0.41 |
| Host busy | 8.0% | 7.8% |
| Memory | 309 MB | 372 MB |
| Network intake | 15.2 Mbps | 1.85 Mbps |
| Frames in and decoded a second (entry + exit) | 12.5 + 20 | 12.5 + 20 |
| Live frames a second to the viewer | 12.5 + 20 | 12.5 + 20 |
| Detector, ms a look | 21 | 32 |
| First picture after connecting (entry, exit), one connect each | 1.8 s, 2.9 s | 3.6 s, 2.6 s |
- **The codec makes no difference to the CPU.** The network intake falls to an eighth.
- The earlier figure of 6–7% CPU was also taken with every MJPEG frame decoded (mode `stream`),
not only the frames looked at.
- Eight H.264 decode errors were logged in the second the exit stream first connected
(06:47:55 UTC), and none in the five minutes after. No stream loss after the switch.
- **The user, watching the page during the MJPEG run (2026-11-23):** "7%–8% CPU load. Not
bad." The user has not yet commented on the H.264 numbers.
**Delay from the camera to the live picture** (2026-11-23). Measured as on [[camera-live-view]]:
the camera's printed clock against the arrival of the live picture's JPEG, here at a viewer on
the booth PC itself, with each camera's clock bracketed over ISAPI to ±6–14 ms. 65–75 second
flips per camera; the minute flip agrees, so the figures are not off by whole seconds.
| | Entry (12.5 fps) | Exit (20 fps) |
|---|---|---|
| MJPEG straight from the camera (2026-11-17) | 0.09–0.10 s | 0.09–0.10 s |
| H.264, decoder on its default threads | 0.51–0.61 s | 0.39–0.43 s |
| H.264, **one decode thread** | 0.12–0.24 s | 0.18 s |
- **Cause of the first figure:** FFmpeg decodes H.264 on several threads by default, and each
extra thread holds one more frame back. On the 6-core booth PC that is 5 frames: 0.40 s at
12.5 fps, 0.25 s at 20 fps, which is the drop measured. The `low_delay` capture option did
not prevent it.
- **Fix in the PoC:** config key `decode_threads` (passed to OpenCV as `CAP_PROP_N_THREADS`);
the test copy runs with 1.
- With one decode thread and nobody watching the process used 0.27 cores and 328 MB, with no
decode error and the detector still at 5 looks a second.
- What is left, about 0.1 s over MJPEG, covers the camera's H.264 encoder, the decode and the
re-encode. A browser elsewhere adds its network and drawing time, which this does not include.
**The user's readings on the booth PC (2026-11-23, H.264, default decode threads):**
| | CPU | Download | Upload |
|---|---|---|---|
| Watching both pictures | 7–8% | 1.3 Mibps | 19.5 Mibps |
| Nobody watching | 5–6% | 1.1 Mibps | 400 Kibps |
Memory is steady either way. The upload is the live picture going to the browser as JPEGs
(about 107 KB a frame from the entry camera and 63–67 KB from the exit camera).
**A car in the zone** (2026-11-23, 07:32–07:33 UTC, AA927AU, H.264 with one decode thread; the
barrier was not driven, the relay lines are "would pulse" records). Read from the frames; the
user has not yet said what was driven.
| Start (UTC) | What the frames show | Verdict | Plate |
|---|---|---|---|
| 07:32:23 | drove up, stood 17 s short of the line, backed out | `abandoned`, would close | `AA927AU` decided after 0.34 s: 2 video frames and 1 still |
| 07:32:54 | drove up further, stood 4 s, backed out | `abandoned`, would close | undecided: `AA927AU` 2 votes, `HUIJE` 1 vote |
- **The flow judged both as the frames show them.** The followed car was matched in 5.0 looks a
second in both visits.
- **Video frames read the plate as well as before.** With the plate 65–90 px wide, 4 of 4 reads
were right and sure, the same as in the MJPEG day trial of 2026-11-22 (4 of 4). The sample is
small.
- **The camera's on-screen label was read as a plate.** In the second visit the car stood with
its bumper under the label "Hyrje" that the camera prints into the picture, and its own plate
was edge-on. 21 video frames and 3 stills then read the label (`HUIJE`, `HU1JE`, `HUIJB`), and
one still was sure enough (0.986) to vote. This is not an H.264 effect: 30 such reads are in
the records of 2026-11-20 to 22, none of them sure enough to vote until today. Now on
[[vision-hardening]]. The user moved both labels to the top-right corner the same day.
- **Load with the car in the zone:** 0.36–0.42 cores while it stood, and 0.84 cores (15% of the
host) for the ten seconds with 33 plate reads; memory rose from 329 to 512 MB and fell back to
441 MB. The detector kept 5 looks a second at 25–31 ms.
- **Two stills timed out** in the second visit (2 s and 4 s pauses), as on the earlier days. No
decode error and no stream loss.
**Staff traffic** (2026-11-23, 07:52–09:11 UTC, the same test copy). The user: the staff drove,
not the user. Nobody said what each vehicle did, so the column "What the frames show" is a
reading of the recorded frames, and these visits are not part of the scored set in
`recordings/`. The barrier was not driven: all 13 rows in `relays.jsonl` have `sent: false`.
| Start (UTC) | Camera | What the frames show | Seen | Verdict | Plate |
|---|---|---|---|---|---|
| 07:52:53 | entry | a dark car drives in without stopping | 0.6 s | `passed` | none: 1 video read at 52 px (weak), the one still timed out |
| 08:00:43 | exit | the same model of car, front to the camera, behind a blur that covers most of the picture | 0.4 s | `abandoned`, lost | undecided: `AB242TD`, 1 vote from a still (0.96); 3 video reads at 49–55 px |
| 08:28:36 | exit | a dark SUV moves out of sight behind a grey mass that fills the left half of the picture | 1.2 s | `abandoned`, lost | none: 3 stills, no plate found |
| 08:33:29 | entry | a black SUV stands 20 s short of the line, then five people push it through, rear first | 26.8 s | `passed` | none: 11 stills, no plate found; 4 stills timed out |
| 08:53:16 | entry | a white off-roader drives in without stopping | 2.2 s | `passed` | none: 2 video reads at 41–44 px (weak), 1 still read weak (0.61) with the plate at the crop's edge, 1 still timed out |
| 09:01:24 | exit | the white off-roader's rear at the edge of the grey mass | 0.2 s | `abandoned` | none |
| 09:09:44 | exit | a dark hatchback stands 62 s in the zone, then moves back, away from the camera | 63.3 s | `abandoned` | none: 91 video tries, 5 weak reads; 2 weak still reads |
| 09:11:04 | exit | not looked at | 0.6 s | `abandoned`, lost | none |
- **Bad weather (user, 2026-11-23).** The cameras are outdoors and the weather cannot be
fixed. The lane is wet in every clip of that morning. The soft plates and the blur in the exit
camera's picture have to be read with that in mind; how much of them is the weather was not
separated from the rest.
- **Entry camera: 3 of 3 `passed`,** which is what the frames show, and no close would have gone
out. The pushed car was followed for 27 s at 5 looks a second with five people around it.
- **Exit camera: not scored.** It is out for verdicts (see "The exit camera is
out"). Each of its five visits would have pulsed the open relay.
- **No plate was decided in eight visits. The records do not show that H.264 is the cause, and
they do not rule it out:**
- in the two drive-ins the plate was 41–52 px wide in the video frames at the moment the visit
started, under the 64 px gate, so those reads could not vote on MJPEG either (item 4 on
[[vision-hardening]]: the plate has to be read before the visit starts);
- on the MJPEG days (2026-11-21 and 22) the entry camera's video reads under 65 px were sure
(≥ 0.90) in 10 of 120; today in 3 of 17. At 65–90 px: 6 of 36 on MJPEG, 4 of 4 today, all
four from the user's own drive;
- the exit camera's five video reads at 82–88 px (09:10:46–47) scored 0.11–0.21. In those
frames the plate is too soft to read by eye. On the MJPEG days the exit camera's reads at
that width were sure in 2 of 7.
- The sample is too thin for a comparison. A drive with a known plate is still needed.
- **The blur and the grey mass in the exit camera's picture are not decoding faults.** The blur
of 08:00 is in the hi-res still as well, which does not come from the H.264 stream. What they
are was not established from the frames ([[vision-hardening]] records that the boom crosses
this camera's picture).
- **A vehicle's box reached the moved label, and it was not read.** The off-roader's box rose to
y = 37 of 720 at the right edge (08:53:19), with the label "Hyrje" inside it. No read of the
label is in the records of any of the eight visits.
- **Still timeouts on the entry camera:** 8 in 28 tries today (the user's drive included),
against 9 in 67 on 2026-11-22 by day. Cause not known. One on the exit camera.
- **The pause carried over to the next car** (finding 14 on [[zone-anpr-poc-review]], seen
live): the fail count is reset only by a still that succeeds, so the timeout at 07:52:54
drew an 8 s pause after the two of 07:32–07:33, twenty minutes earlier.
- **The stream held:** 12.5 and 20 frames a second in every ten-second window from 07:34 to
09:14 UTC, no decode error, no reconnect.
- **Load:** 0.27 cores with an empty lane; 0.77–0.90 cores (13–15% of the host) in the windows
with a standing vehicle being read. Memory went from 329 to 497 MB over the morning in steps,
one at each visit. The MJPEG run of 2026-11-22 did the same (296 MB after a start, 448–535 MB
after visits, peaks of 0.9–1.05 cores), so neither is an H.264 effect.
**Not measured.**
- Plate reading from H.264 frames at night, and by day with a known plate on a car that drives
through (the staff's drive-ins gave no usable comparison). The user (2026-11-23): this will be
handled as work of its own; it does not hold up moving the video work to the vision side
([[event-driven-refactor]]).
- Why the detector's time rose from 21 to about 30 ms a look. It still made its 5 looks a second
on both cameras in every run.
**Side effect, as long as 102 stays on H.264.** The parking server's booth camera tiles
([[camera-live-view]]) take MJPEG only (`packages/devices/src/drivers/rtsp-mjpeg.ts` refuses any
other codec), so they show no live video for these two cameras, on park-lab and on the dev
machine.
## Still open
Deferred by the user on 2026-11-22. The work list, with the evidence for each item, is on