wiki: passage confirmation — zone PoC, flow and relay rules, trials, hardening list

- passage-confirmation: unexplained passages as the audit witness and the
  phase-1 order (2026-11-19), first recordings, and the decisions of
  2026-11-22: the zone flow (last crossing counts, no decision while the zone
  is busy, an uncrossed open is abandoned) and the read-then-fire relay rules.
- zone-anpr-poc: the prototype on park-lab, its builds, the live R2 trials and
  the turn-back judged as passed; park-lab as the worst-case site.
- zone-anpr-plate-trials: plate reading measured (inverting does not help; the
  still is the main reader; the plate reads only on a short stretch of the
  approach), the day and wet-night trials, and the two fixes that followed.
- zone-anpr-poc-review: the code review of 2026-11-21 with a status table of
  what the later builds fixed.
- vision-hardening: the work list the user deferred to another session.
- zkteco-cmp200-barrier, append-only-event-chain, reconciliation,
  open-questions, overview, index, log: cross-references and updates.

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-22 18:24:48 +01:00
parent ce10c741fc
commit 726dd9803a
12 changed files with 1446 additions and 9 deletions
+3 -1
View File
@@ -128,5 +128,7 @@ the actual control is [[reconciliation]]: compare the host's signed *commanded*
payment/Z-report). **A physical open with no matching signed command is the fraud signal** — and,
with vehicle verification, **a plate that enters/exits on a different car** is too (the
plate-spoofing case). Both the witness sources and the reconciliation logic are **NOT yet built** —
this is the main open gap. Prevention (VLAN isolation so the attacker can't
this is the main open gap. The first witness is planned (2026-11-19): the camera sees a vehicle
cross the drawn line with no signed open behind it, and records an `anomaly` (`passage.unexplained`)
— [[passage-confirmation]] §Unexplained passage. Prevention (VLAN isolation so the attacker can't
reach UDP 60000) is the necessary first line; detection-via-reconciliation is the backstop.
+172 -3
View File
@@ -2,7 +2,7 @@
type: concept
tags: [parking, vision, barrier, lane, ledger, safety, design]
sources: []
updated: 2026-11-17
updated: 2026-11-22
status: open
---
@@ -166,6 +166,54 @@ Read from the cameras over ISAPI the same day; bench snapshot results are on [[l
segment with sides A and B and a direction, where A → B, B → A or A ↔ B is what counts as a
crossing. The fleet cameras have no such rule, so Setup draws it and the booth's tracker judges.
### Unexplained passage — the audit witness (user, 2026-11-19)
A vehicle that crosses a barrier's line with **no signed open behind it** is recorded as an
anomaly, for audit. Typical causes: the booth operator raising the boom with a remote control or
the operator's own button, which bypasses our relay and leaves no trace today, or a second car
through on one open (tailgating). It is the independent witness [[append-only-event-chain]] and
[[reconciliation]] call for: *a physical open with no matching signed command is the fraud
signal.*
- **Matching rule.** One open covers one car, because the barrier closes on the passage. A
crossing in the open's direction is explained when a signed `barrier_open_command` for that
barrier exists since the previous crossing there. The command may come from any source: ANPR,
ticket, QR, an operator button, or a setup test. Each command explains at most one crossing.
- **Record.** A signed `anomaly`, reason `passage.unexplained` (a new member of the closed reason
set). It carries:
- the plate and its confidence, when read;
- the direction from the line;
- the barrier and the camera;
- the evidence still;
- the crossing time, and the time of the last open that was already used.
It is listed in reports and in the shift's Z-report: the operator on duty is the person it
audits.
- **Unsigned until it is proven.** The ledger is append-only, so a false anomaly can never be
removed. Until the crossings are shown reliable on park-lab, candidates go to `device_events`
(kind `passage-unexplained`) and are checked against what really happened. Signing is switched
on afterwards.
- **An abandoned open must stop covering cars.** A turned-back open would otherwise explain the
next car through. The abandoned verdict therefore marks the open used, so the next car through
is an unexplained passage.
- **No camera, no claim.** Periods with the stream or vision down are recorded as unwatched, so a
missing anomaly is never read as "nothing happened".
- **Plates of people who are not customers** are kept as evidence. The snapshot retention applies.
Whether that is enough is a decision still to be made.
### Phase-1 order (user, 2026-11-19)
The audit record comes first, because it actuates nothing: no relay, no interlock, no safety
review.
1. **Crossing detection.** The tracker over hub frames judges each car against the drawn lines.
2. **Unexplained passages.** Unsigned candidates in `device_events` first; signed anomalies once
proven.
3. **The abandoned verdict.** The close runs as a dry run ("would close now", with the evidence
frame), and the verdict marks the open used.
4. **The real close pulse.** Last, behind the per-barrier switch, after step 0 of the test plan
(the interlock) and the safety tests, and after [[barrier-not-a-door]] is revised.
### Phase-1 shape (proposed)
- **Built (uncommitted).** Setup → camera → *Crossing line* draws the segment over the live
@@ -189,13 +237,134 @@ Read from the cameras over ISAPI the same day; bench snapshot results are on [[l
so "nothing in view" is never true there. The recordings decide whether Setup also needs a lane
area.
## First recordings — AA890XX manoeuvres (2026-11-19, night)
Clips were taken by a dev recorder: both 102 streams, 25 s before to 15 s after each server event,
stored in `.local-parklab/recordings/`. A prototype ran YOLOX-S on every 3rd/4th frame, with a
greedy IoU tracker following the bottom-centre point, against the lines drawn in Setup.
| Time (UTC) | Ledger | What happened | Entry cam `.6` | Exit cam `.7` |
|---|---|---|---|---|
| 16:24:09 | `vehicle_entry` | drove in | A → B at 16:24:12 | no crossing |
| 16:24:46 | `vehicle_exit` | drove out | B → A at 16:24:51 | no crossing |
| 16:25:20 | `vehicle_entry` | **turned back** | A → B 16:25:12, B → A 16:25:19 | car never reached it |
- **The turn-back is visible**, and the ledger holds a false entry for it: the subscriber now has
an open stay. This is the case this page exists for.
- **The entry line sits where cars stop to be read.** In the turn-back the car crossed A → B eight
seconds **before** the open, then went back over the line. With "A → B after the open" as the
rule, a car already over the line when the boom rises and then driving on would never cross
again. It would be judged abandoned, and a close would come down on it. The line must lie
**beyond the stopping point and the boom**, where a car only gets after passing.
- **The exit line is off the cars' path.** It is drawn in the bottom-left corner, while cars drive
along the right half of the frame. Near the frame edge the car is cut off, and the bottom-centre
point jumps.
- **On this one-lane rig the entry camera alone saw both directions** (A → B in, B → A out). The
shared-lane open question leans toward one well-placed line per barrier, with direction from
the crossing.
- **The boom swings through the exit camera's view** when it opens (16:24:11–15, 16:24:48–51) and
stayed in view after the turn-back (16:25:22 onwards, boom still up). That would let a camera see
that the boom is up, a direct witness of an open by remote control. Not yet confirmed with the
user.
## Field trials — zone PoC (2026-11-21)
A standalone prototype tried this design on park-lab with the real relays: R1 live, R2 as a dry
run. The entry camera judged every move of a night drive right, including nose over the line and
reverse. The user set the close rule, and the exit camera was dropped because the rising boom
crosses its image. The details are on [[zone-anpr-poc]].
**2026-11-22:** the flow and relay rules below were built into the prototype and run with R2
live. By day the entry visits were judged as driven, except one turn-back at the boom that was
decided `passed` while the zone ended short of the picture's edge; the boom came down at every
abandonment the camera judged.
On a wet night the plate and the detector did not hold ([[zone-anpr-plate-trials]]). The user
closed the trials there; what is left to harden is on [[vision-hardening]].
## Decided with the user (2026-11-22) — the zone flow and the relay rules
### The flow
- **A → B is in, B → A is out.** The two are mutually exclusive: a later crossing replaces the
earlier one, so only the **last** crossing counts.
- **No decision while the zone is busy**, neither passed nor abandoned. The watch keeps running.
- **The decision is made when the zone becomes free:**
| Zone | Last crossing | Decision | R2 |
|---|---|---|---|
| busy | any, or none | none yet | — |
| free | A → B | passed | nothing |
| free | B → A | abandoned | fire |
| free | none: the vehicle did not cross | abandoned | fire |
- **The rule behind the last two rows (user):** *"We care if the boom is up (the barrier is open)
and the transient or subscriber do not cross the barrier, so we flag that entry as abandoned,
and fire R2 to close the boom."* It holds for ticket holders and subscribers alike.
- R2 fires only for an open made in that busy period, as before ([[zone-anpr-poc]]).
- This replaces the six verdicts of the PoC ("moving away", "other direction", "stayed beyond").
The PoC implements it since 2026-11-22: [[zone-anpr-poc]], "The 2026-11-22 build".
**Not settled** (raised by [[zone-anpr-poc-review]], not yet confirmed by the user). The PoC
build had to pick a default for each; they are listed on [[zone-anpr-poc]]:
- **What counts as busy.** The review recommends any vehicle in the zone, on every camera bound to
the barrier. The PoC build looks at any vehicle in the camera's own zone.
- **A vehicle the detector loses while it stands in the zone** makes the zone look free. With no
crossing, that gives abandoned and a close on a standing car (finding 1 there). The review
recommends that the zone counts as free only when the vehicle was seen leaving it.
- **A drive-out on park-lab's shared lane is also B → A.** R2 then fires behind a car that has
left. With the zone empty that harms nothing, but "abandoned" is the wrong word for it once the
verdict feeds the ledger.
### Relay rules
- **The close does not look at the boom (user).** No "boom is down" signal is needed for it. What
matters is that the boom was opened and the vehicle did not cross. *"If the boom is already
closed that R2 firing will do nothing."* Not yet tried on the unit: a `DOWN` pulse on a closed
boom belongs in the bench tests above.
- **A vehicle under the boom is the barrier's concern, not the host's (user, 2026-11-22).** The
barrier's own radar or infrared sensors keep the boom up while something is under it, whatever
the relay commands. The close therefore only has to know that the open was not used.
- So the limit contacts (`O.LM OUT`, `C.LM OUT` on [[zkteco-cmp200-barrier]]) are **not** wired
for the close. Their use as an audit witness is a separate matter.
- **What the board reports.** The status read returns each relay's coil state and the inputs
(`packages/devices/src/drivers/access-dingtian.ts`, command `0x00`). A coil is on only during
its 500 ms pulse, so this never says where the boom is. The PoC reads it before every pulse.
- **Read, then fire (user, 2026-11-22).** Before a relay is pulsed, the board's status is read. If
the other relay of the pair is off, the pulse goes out. Switching a relay off takes no time
beyond the network, and a pulse lasts 500 ms, so the other relay is almost always off.
- **When the other relay reads on (user, 2026-11-22).** Send it an off command and read again.
Once it reads off, fire. If it still reads on, keep trying. The rule is the same in both
directions.
- **When the read fails (user, 2026-11-22).** Check whether the relay controller is online. If it
is, keep looping. If it is not, there is no controller on the network to drive, and the relay
is flagged **offline**.
- **Contradiction, noted.** Being the same in both directions, the rule lets a close switch R1 off.
That is "last command wins", where [[zkteco-cmp200-barrier]] and the phase-1 shape above ask for
"open wins". It can only bite when an open from another source (the app on the dev machine, an
operator button) lands in the half second before a close: that open is cut and the boom comes
down in front of the car it was for. The series interlock still makes open win on the wire.
- **Built this way in the PoC (2026-11-22), not yet confirmed by the user:**
- "online" is a TCP connect to the board's web port, a different probe from the status read;
- 0.1 s between tries; one worker per board, and a newer command replaces one still trying;
- a close that is still looping when the zone turns busy again is dropped, since the flow
decides nothing while the zone is busy.
- The read and the pulse are separate datagrams, and the dev machine drives the same board, so
the check is not atomic. It does not replace the series interlock, which stays a precondition
for a live R2.
## Open questions
- **One lane, both directions (park-lab rig).** Every car crosses both cameras' views. Does the far
- **Hardening the vision side** after the field trials: the work list, deferred on 2026-11-22, is
[[vision-hardening]].
- **One lane, both directions (park-lab rig).** The PoC lets one camera own the lane at a time,
and the entry camera alone judges both directions ([[zone-anpr-poc]]). Every car crosses both cameras' views. Does the far
camera's motion push for a car moving *away* count as nothing (direction from the track decides),
and may the far camera's sighting corroborate the passage? Undecided.
- Re-export YOLOX at 416 vs YOLOX-Tiny for the tracker — accuracy on far cars at the line?
- Window cap and "lane clear" dwell before a close (start: cap 60 s, dwell 3 s).
- ~~Window cap and "lane clear" dwell before a close (start: cap 60 s, dwell 3 s).~~ Decided by
the user (2026-11-21): no window, no dwell. The close fires as soon as the zone is free and the
verdict is abandoned. See [[zone-anpr-poc]].
- Does the DS-2CD1043G2-LIU keep pushing VMD for a car *reversing*? (It should — motion is motion.)
- Stream-to-event latency and frame drop rate on the booth PC (measure, don't assume).
- Which barrier operator model is at the sites? The unit on hand is a [[zkteco-cmp200-barrier]]:
+3 -1
View File
@@ -24,6 +24,8 @@ Only design for that if it's genuinely true. The network-free fallback controls
- the signed, hash-chained log ([[append-only-event-chain]]),
- physically **pre-numbered ticket stock**,
- **end-of-shift signed Z-reports**,
- **CCTV/LPR footage** as an independent record (see [[lpr-camera]]).
- **CCTV/LPR footage** as an independent record (see [[lpr-camera]]). The planned form of this is
the camera witnessing a crossing with no signed open behind it, recorded as an
unexplained-passage anomaly ([[passage-confirmation]]).
Establishing *some* periodic reconciliation channel is [[open-questions]] #4.
+172
View File
@@ -0,0 +1,172 @@
---
type: concept
tags: [parking, vision, anpr, passage, night, glare, hardening, poc, park-lab]
sources: []
updated: 2026-11-22
---
# Vision hardening — what the zone PoC left open
The work list for hardening the vision side of [[passage-confirmation]], drawn from the trials of
the [[zone-anpr-poc]] on park-lab (2026-11-21 and 2026-11-22). **Deferred by the user on
2026-11-22 to a later session.** Nothing here is built unless it says so.
Evidence for every item is on [[zone-anpr-poc]] (flow, relays, live closes) and
[[zone-anpr-plate-trials]] (plates, day and night). The findings of the first code review are on
[[zone-anpr-poc-review]].
## Where things stand
- **Works on a live barrier:** the zone flow (nothing decided while the zone is busy; the last
crossing decides) and the read-then-fire relay rules. By day the entry visits were judged as
driven, with one miss (item 14), and the boom came down at every abandonment the camera judged.
- **Does not hold at night on a wet lens:** the plate (5 decided in 11 visits, 2 of them wrong),
and the detector's boxes, which swell with the headlight flare.
- **The user's reading (2026-11-22):** the wet lens is the culprit and the weather cannot be
fixed. park-lab is also the worst case there is: one lane for both directions, and a boom that
crosses the exit camera's picture.
## The picture itself (camera side)
Nothing in the software removes flare from a wet lens. None of these has been tried:
- **Keep water off the lens:** a hood or visor over the camera, and a water-shedding coating on
the glass.
- **The camera's own exposure controls at night:** a shorter shutter, lower gain, highlight
compensation. [[lpr-camera]] has the model and what is known about it.
- **Where the camera looks.** Two limits of the park-lab entry camera come from its position, not
from the weather:
- a car standing at the line is seen almost edge-on, so its plate cannot be read there;
- the boom is outside the picture, so a car waiting in front of it is mostly out of view.
## Detection
1. **Glare boxes act like cars.** At night the detector at times returns a box nearly as large as
the picture.
- One started a visit with no car at the line (17:01:18): R1 opened and R2 closed again two
seconds later.
- Others ended visits, which came out `abandoned` only because `close_on_lost` is on.
- A real car driving through close to the camera also gives a box about 78% of the picture
wide, against 81–99% for the glare boxes, so size alone will not separate them.
- **To try:** a visit starts only on a box that has held for a few looks; a box that touches
both the left and the right edge of the picture is not a car.
2. **The followed car goes unmatched more often at night.** The detector held its 5 looks a second
throughout (`metrics.jsonl`), but in several night visits the car was matched in only 3.1–4.1 of
them. Each miss is a look in which the car's side is not known. Not investigated.
3. **One followed car.** The tracker follows one car by box overlap. A track that breaks or jumps
to another car ends in `unclear` or a late decision. A second car that enters the zone before
the first has left gets no open of its own.
## Plates
4. **Read the plate before the visit starts** (the main fix).
- Every right read was taken with the car's front edge left of about x = 900–1030 of 1280.
Reading starts when the car enters the zone, which is the end of that stretch. A faster car
is past it by the first still.
- **What it must respect (discussed with the user, 2026-11-22):**
- a reading belongs to a followed vehicle, never to the lane or the camera. If that vehicle
enters the zone, the visit takes its votes over; if its track ends first, they are dropped.
Nothing waits in memory for "the next car";
- each vehicle starts its own reading when it is first followed inside a drawn approach
area, larger than the zone;
- the risk is a mixed-up identity: two cars close together, and the first car's votes land
on the second. With the real rule, open on a known plate, that opens for the wrong car and
writes the wrong plate in the ledger. It is also a trick someone could play on purpose.
Guards: votes carry over only along an unbroken track, and a decision needs at least one
agreeing read taken inside the zone;
- only vehicles in the approach area are read, or the street traffic in the picture would be
read all day;
- it needs more than one track, which the PoC does not have (item 3).
5. **A hazy flare over the plate.** On the wet lens a ghost of the headlight lay over the first
three characters, and two stills read `27AU`, each sure. The built check only catches
burnt-out pixels beside the plate; this haze is bright (about 200 of 255) without being burnt
out. No measure for it yet.
6. **The rear plate at a steep angle.** Three stills read `AA927AJ`, each sure, and the plate was
decided wrong. No flare was involved.
7. **A plate cut off by the edge of the still's crop** still votes (`AA927`, sure, once by day).
**To try:** no vote when the plate's box touches the crop's edge.
8. **The same mistake three times is a consensus.** All the wrong decisions came from stills of a
standing car that all showed the same fault. **To try:** votes must come from different
positions of the car.
9. **Stills time out:** 9 in 67 tries by day, 4 in each night run, each followed by a 2–4 s pause. Most
hit the second still of a visit, half a second after the first. Cause not found; a longer gap
between stills (about 0.8 s, as in the first build) has not been tried.
10. **The stream frames are the weaker reader.** They read right only with the plate 65–90 px
wide. The 5% size gate for stream votes was chosen on the same reads it is scored on; every
read's plate width is recorded, so it can be set again from more drives.
11. **No format rule (user, 2026-11-21).** Items 5–8 are checks on the picture. A rule about what
a plate looks like stays out.
## Flow and the close
12. **A car the detector loses inside the zone.** The code's default gives `unclear` and no close.
park-lab runs with `close_on_lost` on since the user's point that the barrier's own sensors
cover the space under the boom. The user has not ruled on which is the rule for the product.
13. **A drive-out reads as B → A,** so it is called `abandoned` and R2 fires behind the car.
Harmless on park-lab; the wrong word once the verdict feeds the ledger.
14. **The zone must reach the picture's edge on the boom's side.** A car waiting at the boom showed
only as a strip at the edge, and the visit was decided `passed` while it stood there. Fixed on
park-lab by redrawing the zone; the product's Setup has to enforce it or draw it so.
15. **A car that passes and one standing out of view at the boom look the same** once nothing of
it is in the picture. Only a camera that sees the boom, or the far camera, can tell.
16. **One recorded visit changed with the truth unknown:** a three-frame visit of 2026-11-21
(16:36:41) went from `passed` to `abandoned` with the two-looks rule.
## The shared lane (park-lab only)
17. **The exit camera opens and cannot close.** It has an open relay and no close relay. Several
times it took the lane for a car the entry camera should have judged, and fired R1 again.
Taking `relay_open` off it is a config change; the user has not decided.
18. **The lane lock** gives a second open when the car reaches the far zone late, clears on one
weak frame, and never serves a car waiting on the far side (findings 7–9 of the review).
## Relays and the barrier
19. **The off command is the same in both directions,** so a close can cut an open: "last command
wins", where [[zkteco-cmp200-barrier]] asks for "open wins". Noted on
[[passage-confirmation]]; the series interlock is what makes open win on the wire.
20. **Still not done before R2 is used anywhere else:** the interlock checked with a meter, the
`DET`/`PHO` reversal proven on the unit, [[barrier-not-a-door]] revised. The user ran the
park-lab trial without them.
21. **No close relay exists at park-2 or park-buzi** ([[passage-confirmation]], relay maps).
## The PoC itself
- The web page is open on all interfaces with no login: it arms the relays and redraws the zone.
- Clips, stills and logs are pruned by count of visits, not by size.
- The timers count processed frames, not seconds.
- The rest is on [[zone-anpr-poc-review]], with what has been fixed since.
## What carries over to the parking system
- The flow table and the relay rules on [[passage-confirmation]].
- The checks in `poc/zone-anpr/test_flow.py`, which describe each rule as a case.
- The recorded visits in `poc/zone-anpr/recordings/`, which replay the real drives of both days
through the judging code (`replay_recordings.py`). Of the 21 where the driver said what he
did, 20 are judged right with `close_on_lost` on; two of those (2026-11-21 16:35 and 16:37)
would be `unclear` without it.
- The measured limits, all provisional: the plate's readable stretch, the 65–90 px window for
stream reads, the glare strip.
## A possible order
1. Decide the two rules that are the user's: item 12 (the lost car) and item 17 (the exit camera).
2. Items 1 and 7: small, and they remove the spurious open and one kind of wrong read.
3. Item 4 with item 3: more than one track, then the approach area and the reading before the
visit. The largest piece, and the one the plate result depends on most.
4. The camera side, on the park-lab unit, before any more software against the flare.
## Picking it up again
- **Code:** `poc/zone-anpr/` in this repository. `zone_anpr.py` is the service; `test_flow.py`
(65 checks) and `replay_recordings.py` (48 recorded visits) run with no camera, model or relay.
The detector model (`yolox_tiny.onnx`, 20 MB) is not in the repository; it lies beside the code
on park-lab.
- **On park-lab:** container `zg2`, page on port 8094, files in `~/zone-anpr-gpu`. It runs the
committed `zone_anpr.py` with `close_live` and `close_on_lost` on, and starts disarmed. Earlier
versions are kept beside it as `zone_anpr.py.bak-20261122-*`.
- **Records there:** `out/visits.jsonl`, `out/relays.jsonl`, `out/reads.jsonl`,
`out/reads-all.jsonl`, and per visit `out/clips/<start>_<camera>/` with every processed frame,
its box, and the kept stills with their reads.
- **After a drive:** `trial_report.py`, run on park-lab, prints one line per visit (speed,
verdict, plate, source of the votes, seconds to the decision).
+277
View File
@@ -0,0 +1,277 @@
---
type: concept
tags: [parking, vision, anpr, plate, night, glare, poc, park-lab]
sources: []
updated: 2026-11-22
---
# Zone ANPR PoC — plate reading, and the day and night trials
How the [[zone-anpr-poc]] reads the plate, what was measured about it, and the trials of
2026-11-22 by day and on a wet night. The flow and the relays are on [[zone-anpr-poc]]; what is
left to harden is on [[vision-hardening]].
**In short:**
- The plate reads only on a **short stretch of the approach**. Once the car stands at the line the
camera sees it almost edge-on.
- The **hi-res still is the main reader**. The stream frames are a faster, weaker second source.
- Re-toning the picture (inverting, contrast, darkening) does not help.
- On a **wet night** the headlight flare decided the result: 5 plates decided in 11 entry visits
with a plate in view, 2 of them wrong.
- The night also showed a pass judged abandoned. Two fixes followed, and held on the next run.
## What the 2026-11-21 night showed
- **When it works:** the plate reads reliably in the 1–2 s **while the car approaches**.
- **When it fails:** once the car stops close to the camera, the plate is at a steep angle next
to the car's own headlight, and comes out burnt white. At 16:59 that gave 37 reads, all garbage
("AAJ27").
- **The plate is not needed for the verdict.** Several visits were judged right without one.
- **Camera-side fix, not tried yet:** a faster night shutter or lower exposure.
## Would inverting the picture help? (measured 2026-11-22)
The user asked whether inverting the picture would help. The PoC's own plate reader was run on
the 1280×720 frames of three night visits, as recorded and re-toned three ways. Counted: reads of
`AA927AU` with every character ≥ 0.9.
| Visit | Frames | As recorded | Inverted | Contrast (CLAHE) | Darkened |
|---|---|---|---|---|---|
| 17:28, approaching and driving through | 46 | 38 | 18 | 41 | 20 |
| 17:00, stopped close | 51 | 0 | 0 | 0 | 0 |
| 17:59, standing 50 s | 78 | 0 | 0 | 0 | 0 |
- **Inverting makes it worse**, and helps nowhere.
- **The stopped plate is not burnt white**, which corrects the second bullet of the section
above: no pixel of the plate area is clipped in the 17:59 visit, and at most 9% in the 17:00
one. Its brightness is ordinary (mean 116 of 255).
- **It is seen almost edge-on.** The plate is 82 px wide while the car approaches, and 26–40 px
wide once it stands at the line, for seven characters. No re-toning brings that back.
- **Limit:** this used the stream frames. The 8MP stills of failed reads were not kept, so what
they looked like is not known.
## Correction: the stream frames are the weaker reader
The 17:28 visit above was a favourable one. All 20 entry visits of that night were then replayed
through the stream frames alone:
| | Visits decided, of 20 |
|---|---|
| Hi-res stills, as run that night | 8 |
| Stream frames alone | 3 (after 1.5 s, 1.8 s and 2.4 s) |
- Every visit the stream decided, the stills had decided too.
- **Why:** a stream read is only right when the plate is large enough. Of 652 stream reads:
| Plate width in the 1280 px frame | Reads | Sure and right | Sure and wrong | Unsure |
|---|---|---|---|---|
| under 65 px | 465 | 1 | 2 | 462 |
| 65–90 px | 172 | 133 | 0 | 39 |
| over 90 px | 15 | 0 | 0 | 15 |
The plate is that size for only part of the approach. The still has three times the pixels.
- **Caveats:** one car, one night; the recorded frames are re-compressed (quality 80); the 20
visits include drive-outs, which show no front plate.
**What follows for the parking system:** the hi-res still stays the main reader. The stream
frames are a second, faster source that costs the camera nothing: five tries a second against one
still in 450–850 ms. Do not expect a read from a car standing at the line with this camera
position.
## The plate build (2026-11-22)
- **Two sources, one consensus.** Every processed stream frame is read in the background, and a
still is fetched at most every 0.5 s. Both vote for the same decision (3 votes, 75% agreement,
every character ≥ 0.9), and reading stops when it is reached.
- **The stills alone can also decide,** so a sure but wrong stream vote cannot block them. The
17:36 visit had two such votes ("AA927XU").
- **A small plate in the stream does not vote:** under 5% of the frame's width (64 px of 1280),
`stream_min_plate_w`. Provisional: it was chosen on the same 652 reads it is scored on.
- **Tries are capped only while the car stands** (75 stream reads, 20 stills, starting again when
the car moves), so a slow approach is read all the way.
- **Every still's car crop is kept with its read** beside the visit's clip (`still_NN_…jpg`,
`stills.jsonl`, the first 15 per visit), so failed night reads can be looked at afterwards.
- **A new HTTP client for every still,** which removes the permanent `digest auth failed` state
of finding 13 on [[zone-anpr-poc-review]].
- **Recorded for each read:** source, plate width, seconds into the visit (`reads-all.jsonl`).
**For each visit:** tries, reads and votes per source, and seconds until the decision
(`reads.jsonl`).
- `test_flow.py` had 57 checks at this build.
- **Deployed to park-lab** at 11:15 UTC on 2026-11-22; `zg2` came up disarmed. The file before it
is kept as `zone_anpr.py.bak-20261122-preplate`.
- **Daytime baseline, before this build** (stills only, 2026-11-22 10:02–10:18 UTC): the plate
was decided in all eight visits where the car showed its front.
## Day trial (2026-11-22, 11:25–11:29 UTC, AA927AU)
The user drove a pass in and out, then abandonments, at higher speeds than in the morning.
| Start | Camera | Verdict | Speed | Plate | Decided after | Stream votes / reads | Still votes / reads / tries |
|---|---|---|---|---|---|---|---|
| 11:25:33 | entry | abandoned (dry run, before arming) | 0.02 | undecided, 1 vote | – | 0 / 23 | 1 / 2 / 25 |
| 11:27:10 | entry | passed | 0.05 | no read | – | 0 / 6 | 0 / 1 / 8 |
| 11:27:48 | exit | abandoned (the drive-out) | 0.04 | undecided, 1 vote | – | 0 / 8 | 1 / 3 / 6 |
| 11:28:12 | entry | abandoned, R2 | 0.07 | **decided** | 4.8 s | 2 / 9 | 2 / 2 / 4 |
| 11:28:24 | entry | abandoned, R2 | 0.08 | **decided** | 5.8 s | 1 / 10 | 2 / 4 / 10 |
| 11:28:45 | entry | abandoned, R2 | 0.05 | undecided, 1 vote | – | 0 / 4 | 1 / 1 / 9 |
| 11:29:00 | entry | abandoned, R2 | 0.08 | undecided, 2 votes | – | 1 / 15 | 1 / 1 / 5 |
Speed is how fast the car's box crossed the picture in its first 1.5 s, in picture widths a
second. The morning's visits were 0.02–0.04.
- **Verdicts and relays: all right.** Every entry visit was judged as driven, and R2 went out on
each of the four armed abandonments. Detection stayed at 4.9–5.0 a second with the stream reads
running; the process used 9–15% of the host during a visit, against 6% idle.
- **Plates: worse than the morning.** Two of the six entry visits were decided, and late. In the
morning, on stills only and at lower speed, all eight were, within about a second.
- **The readable moment is short when the car comes faster.** One second after the visit starts,
the car's box was 790–877 px wide in this trial, against 634–712 px in the morning: the car is
already close and seen from the side. The kept stills show it: in the 11:28:45 visit, stills 1
to 8 show no plate at all, and still 9, taken as the car backed away, reads right.
- **Stills timed out 9 times in 67 tries**, none in the morning's about 20. Each one costs a 2–4 s
pause, in the part of the visit that matters. Most came on the second still of a visit, half a
second after the first. In the old build the gap between stills was about 0.6–0.85 s.
**Hypothesis, not shown:** the camera's picture endpoint hangs when asked again too soon.
- **The stream added little:** 67 reads with a plate, 10 of them with the plate at 64 px or
wider, 4 votes, all right. Under 64 px there were 3 right and 1 wrong sure reads, so the size
gate held.
- **Why the morning was better (user's question, worked out from the kept stills and the
recorded boxes):** the plate can be read only on a short stretch, and reading starts near its
end.
- Of the 42 kept stills, every right read was taken with the car's front edge left of about
x = 900 of 1280. Past that the car is side-on and no still found a plate.
- A visit, and with it the reading, starts when the car enters the zone: front edge at 853–904
in the morning and 757–930 in this trial. That is already the end of the stretch.
- In the morning the front edge moved at 70–113 px a second, so the three stills (one about
every 0.4 s) were all taken in time. In this trial it moved at 136–249 px a second, so the
first still already showed the car past the stretch. The one slow visit of this trial
(11:25:33, 54 px a second) had its first still read right.
- **Ruled out:** the zone redrawn at 10:36 starts a visit on the same frame as the old one, on all
twelve recorded visits. The crop cut for the still was too far behind the car in only 3 of 42
stills. The timeouts hit later stills, when the car was already past the stretch.
## Night trial, wet lens (2026-11-22, 16:25–16:29 UTC, AA927AU)
Relays armed at 16:26:27, close live. What the car did is read from the recorded frames. **The
user confirmed the 16:27:00 visit was a crossing.**
| Start | What the frames show | Verdict | R2 | Plate | Decided after |
|---|---|---|---|---|---|
| 16:27:00 | stood 26 s at the line, then **drove through** | **abandoned (wrong)** | sent 3 s after the car had passed | no read: 0 of 14 kept stills found a plate | – |
| 16:28:12 | came up, reversed out | abandoned | sent | decided AA927AU | 1.3 s (2 stream votes, 1 still) |
| 16:28:27 | came up, stood, reversed out | abandoned | sent | decided AA927AU | 2.8 s (3 stills) |
| 16:28:47 | came up, stood, reversed out | abandoned | sent | **decided A927AU (wrong)** | 2.8 s (3 stills) |
Two entry visits before arming (16:25:30, 16:25:50) were dry runs; what was driven is not clear
from the frames.
- **Glare on a wet lens is the night problem.** In every frame the near headlight is a burnt-out
blob about a quarter of the car wide, with flare spread by the drops. The car's box swells and
shrinks with it, twice to the whole picture. In one visit the followed car was matched in only
3.8 of the detector's 5 looks a second.
- **A pass was judged abandoned (16:27:00), and R2 fired behind the car.** The car stood on the
line and then drove through fast and blurred. The very last matched box, on the blur, lay on
side A outside the zone. That one frame turned the last side from "line" to "a" and counted as
"seen leaving the zone". Replayed without that frame the verdict is `passed` and no R2. This is
the single-frame weakness that the review could not show at the time ([[zone-anpr-poc-review]]),
now seen for real. In the product this would write a real entry as abandoned.
- **A wrong plate was decided with full agreement (16:28:47).** The flare covered the plate's
first letter, and three stills in a row read `A927AU`, each sure. The consensus cannot catch
it, because every still has the same flare. Night reads in all: stills 4 right and 3 wrong,
stream 3 right and 2 wrong, all the wrong ones this same text.
- **Plates were otherwise faster than at midday:** 1.3 s and 2.8 s. The car came slower (0.05–0.06
picture widths a second), and the right reads were again taken with the front edge left of
about x = 1030.
- **A car standing side-on in the glare reads nothing:** 143 stream tries and 35 stills at
16:27:00, three of them timed out.
- **The exit camera** took five visits with no plate, one of them 145 s long, and sent R1 once,
18 s after the pass.
- **The barrier opened at 16:27:00 without a plate, because the PoC opens for any car** (a trial
setting, [[zone-anpr-poc]]). The user asked why. With the real rule, open on a known
plate, this car would have got no open from the camera: it was never read. And a car that
reaches the line unread is side-on there and cannot be read any more, so the real design needs
the plate before the line, or another way in (ticket, operator).
### Day and night side by side
Entry visits with the relays armed:
| | Midday | Night, wet lens |
|---|---|---|
| Verdicts right | 5 of 5 | 3 of 4 (a pass judged abandoned) |
| Plate decided | 2 of 5 | 3 of 4, one of them wrong |
| Time to the plate | 4.8 s, 5.8 s | 1.3 s, 2.8 s, 2.8 s |
| Approach speed | 0.05–0.08 | 0.05–0.06 |
## The two fixes after the night trial
Built and deployed on 2026-11-22 at 16:54 UTC; `zg2` came up disarmed.
1. **A side must hold before it counts.**
- A new side (A, on the line, B) is taken only after two looks in a row (`side_hold`).
- "Seen outside the zone" needs two looks in a row as well.
- The leaving edge is judged on the last box that agreed with the car's side.
- One exception, found by replaying the older recordings: a last look that has not held still
counts when its box is at the picture's left or right edge and the box before it was not. That
is a car driving out of view, which cannot be seen twice. Without it, the plain rule turned
the pass of 2026-11-21 17:01 into an abandonment.
2. **A read does not vote when the picture is burnt out right beside the plate.**
- Measured in the strip just left and just right of the plate, each a quarter of the plate
wide: the share of pixels at 250 or more in every channel. From 5% up, no vote
(`plate_glare_max`).
- On the 20 kept stills with a read: the four with the flare on the plate scored 18–43%, the
other sixteen 0%. All three sure reads of `A927AU` are now barred, and all ten right and
sure reads still vote.
- It is a check on the picture, not a rule about the plate's format.
- Each read's value is recorded (`glare` in `reads-all.jsonl` and `stills.jsonl`).
**Checked before deploying:**
- `test_flow.py`: 65 checks pass, locally and inside the container.
- Every recorded entry visit of both days, 39 in all, replayed through the code before and after:
37 come out the same. The 16:27:00 pass is now `passed` with no R2. One three-frame visit of
2026-11-21 (16:36:41) changes from `passed` to `abandoned`; what that car did is not known.
- **Not covered:** a plate cut off by the edge of the still's crop still votes (`AA927`, sure, at
11:28:12). The flare and the wet lens themselves are not cured, only kept from voting.
- The file before this is kept as `zone_anpr.py.bak-20261122-prefixes`.
## Second night run, after the fixes (2026-11-22, 17:00–17:04 UTC, wet lens)
Relays armed at 17:01:10. What the car did is read from the recorded frames and stills; the user
has not confirmed it.
| Start | Camera | What the frames show | Verdict | Relays | Plate |
|---|---|---|---|---|---|
| 17:00:49 | entry | car seen from behind, stood, left | abandoned | dry run | decided AA927AU, 2.2 s |
| 17:01:01 | entry | car seen from behind, stood 15 s, left | abandoned | R2 | **decided AA927AJ (wrong)**, 4.8 s |
| 17:01:18 | entry | **no car at the line: a glare box as the car backed away** | abandoned (B → A) | **R1, then R2 two seconds later** | – |
| 17:01:32 | entry | drove through | passed | R1 | no read |
| 17:01:48 | exit | the same car, driving on | abandoned | R1 | no read |
| 17:02:06 | entry | drove out past the entry camera | abandoned (B → A) | R1, R2 | – |
| 17:02:26 | entry | came up, left | abandoned | R1, R2 | undecided, **27AU** twice |
| 17:02:43 | entry | drove through | passed | R1 | undecided, AA927AU twice |
| 17:03:11 | exit | a drive-out | abandoned | R1 | decided AA927AU, 0.3 s |
| 17:03:35 | entry | came up, backed away | abandoned | R1, R2 | undecided, AA927AU twice |
| 17:03:50 | entry | came up, backed away | abandoned | R1, R2 | no read |
- **Fix 1 held:** both drive-throughs were judged `passed`, with no R2 behind the car.
- **Fix 2 bars burnt-out flare only.** It barred one sure still and 22 stream reads. Two other
kinds of sure, wrong read got through, both scoring 0 on the check:
- `AA927AJ`, three stills: the **rear** plate seen at a steep angle, the last letter misread;
- `27AU`, two stills: a **hazy** flare ghost from the wet lens lay over the first three
characters. It washes the picture out without burning it out (brightness about 200 of 255
beside the plate, nothing at 235 or more).
- **Glare boxes act like cars.** At night the detector at times returns a box nearly as large as
the picture. One started a visit two seconds after an abandonment (17:01:18): R1 opened and R2
closed again. Two others ended the last two visits; those came out `abandoned` only because
`close_on_lost` is on.
- **The followed car went unmatched more often:** in four visits it was matched in only 3.1–4.1
looks a second. The detector itself held 5 a second throughout (`metrics.jsonl`).
- **Plates on the wet night, both runs together:** 5 decided in 11 entry visits with a plate in
view, 2 of them wrong.
## What is left
The open items from these trials (the readable stretch and reading before the visit, the hazy
flare, the steep rear plate, the plate cut by the crop, the still timeouts) are collected, with
their evidence, on [[vision-hardening]].
+205
View File
@@ -0,0 +1,205 @@
---
type: concept
tags: [parking, vision, anpr, passage, relay, poc, park-lab, review]
sources: []
updated: 2026-11-22
---
# Zone ANPR PoC — code review (2026-11-21)
A review of `poc/zone-anpr/zone_anpr.py` as it stood on 2026-11-21 (uncommitted), against the
design on [[passage-confirmation]] and the trial record on [[zone-anpr-poc]].
**How it was checked.** The tracking logic (`Camera.step`) was replayed offline with a scripted
detector and a recording relay stub, on the entry and exit zones and lines from the local
`config.json` (2026-11-20). No camera, relay or park-lab data was touched. Each finding says
whether it was **replayed**, found **by reading**, or is a **hypothesis**. The live park-lab
config and its `visits.jsonl`, `relays.jsonl` and clips were not read.
The two cases the night drive judged right replay correctly: a drive-through gives `passed` with
no close, and an approach followed by a reverse gives `abandoned` with a close.
## The close decision (R2)
The verdict is computed from where the tracked car was **last seen**. It is not told **how the
visit ended**. Everything below follows from that.
| Precondition on [[passage-confirmation]] | In the PoC |
|---|---|
| An abandoned verdict | checked |
| Nothing between the line and the boom, nothing approaching | **not checked**: only the tracked car's own share of the zone |
| No new open since | **not checked**: `Relays.last_open` is written and never read |
| The watch is alive (stream up, verdict fresh) | **not checked**: a car that is no longer detected counts as gone |
| Clear on every camera bound to the barrier | **not checked**: the other camera is not asked |
| Vision down ⇒ no close | **inverted**: losing the car produces a close |
The user's rule (2026-11-21) removed the dwell and the window. It did not remove these.
1. **A lost car is judged abandoned (replayed).** A car approaches on side A and stands in the
zone. The detector stops reporting it for 3 s. The visit ends, the verdict is `abandoned`, and
R2 fires with the car standing in front of the boom. On the next frame the car is seen again,
and R1 opens. The table on [[zone-anpr-poc]] promises "unclear" for a lost car; that holds only
when the car was last seen on the line. Item 8 there records 3 s drop-outs of a standing car in
glare at the old 0.4 threshold. How often they still happen at 0.15 is not known.
2. **A track that breaks is judged abandoned (replayed).** If the car's box moves so far between
two frames that it no longer overlaps the last one, the tracker counts misses for 3 s and
ignores the car, although it is detected on every frame on side B. Result: `abandoned`, R2,
then a second R1.
3. **"Zone free" means the tracked car left, not that the zone is empty (replayed).** Car 1
reverses out while car 2 stands in the zone on the far side of the line, waiting to drive out.
R2 fires. One frame (200 ms) later car 2 starts a visit and R1 fires. Each pulse is sent from
its own thread, so the order on the wire is not fixed, and no rule makes the open win.
4. **The track can jump to another vehicle (replayed).** A visit continues on any detection that
scores ≥ 0.15 and overlaps the last box by ≥ 0.15. Car 1 is on the line, car 2 is close behind
on side A, car 1 is missing from one frame: the track moves to car 2 and stays there, although
car 1 is reported again on every later frame. Car 2 backs out, and R2 fires while car 1 is
detected on the line. R1 follows on the next frame.
5. **A car first seen near the line that turns back is "moving away" (replayed).** R1 opened for
it, it reversed, and the boom stays up. `approached` needs the car to have come 3% of the frame
closer after the visit started. At night the visit starts late. This is the free pass the
feature exists to prevent.
6. **Opens by anyone else are invisible (by reading).** The dev machine drives the same board
([[passage-confirmation]], park-lab rig). The PoC cannot tell that R1 was opened by another
controller just before it closes. `Relays.status()` reads the board's relay state and is never
called.
## The lane lock
7. **A second open when the car reaches the far zone late (replayed).** The far camera yields
only if it sees the car **while** the owner's visit is running. The entry visit ends 1 s after
the car leaves the entry zone. A car that reaches the exit zone after that gets a visit and a
second R1.
8. **One weak frame cancels the yield (replayed).** The yield is cleared by a single frame with
no candidate at ≥ 0.4. A car in the exit zone that scores 0.35 for one frame is a new visit on
the next, with a second R1.
9. **A car waiting on the far side is never served (replayed).** A car that stands in the exit
zone while the entry camera owns the lane stays ignored after the owner lets go, for as long as
it stands there: 60 s in the replay, with no open.
## Liveness and timing
10. **Time does not count, only processed frames (replayed).** After a 60 s gap in frames the
visit continues on whatever stands in the same place. A visit has no maximum length, so a
vehicle parked in the zone holds the lane lock until it leaves.
11. **The timers assume 5 detections a second (measured).** On the dev machine on 2026-11-20 the
detector ran at 2.5–2.8 a second for 27 minutes (360–400 ms a detection, `out/metrics.jsonl`).
"Lost for 3 s" was then about 6 s and "zone free for 1 s" about 2 s.
12. **An empty zone spins a core (replayed).** With fewer than three zone points the worker loop
never advances its frame counter: 2.6 million iterations in 2 s, one full core per camera.
`config.example.json` ships with empty zones.
## Bottlenecks
The numbers are from the dev machine on 2026-11-20 (`out.log`, `out/metrics.jsonl`), with both
cameras on their main streams in `stream` mode. park-lab runs the 1280×720 MJPEG streams and the
iGPU ([[zone-anpr-poc]]), so its numbers differ and were not read.
- **Decoding costs more than detecting.** With an empty lane the process used about 2.2 cores and
760 MB. `stream` mode decodes every frame of a 3840×2160 and a 2560×1440 stream to keep the
newest one. `mjpeg` mode decodes only the frames it checks. The local `config.json` still
starts the expensive mode.
- **One detector, one lock, all cameras (by reading).** Each camera's frame waits for the
other's. The measured detection time includes that wait: in the slow period both cameras
reported the same time to the millisecond (357.7 and 357.5 ms).
- **The detector never rests.** Both cameras are checked five times a second with an empty lane.
The design on [[passage-confirmation]] runs nothing until a motion push. A lower rate while no
visit is running would halve the idle load.
- **Disk writes sit on the tracking thread:** one JPEG for every processed frame of a visit, and
the verdict image at the end. A slow disk delays the next frame's verdict.
- **The frame counters stretch** when any of the above slows the loop (finding 11).
## Plate stills
13. **The still opener can die for good, with the message `digest auth failed` (mechanism
replayed; that it is what happened on park-lab is a hypothesis).** The opener is built once
per camera. Python's digest handler counts a retry whenever the authenticated request raises
(a 503 or a timeout), and resets the count only on success. After six such failures in a row
it refuses every later request **without sending credentials**. In the replay against a mock
camera: six failures, then `401 digest auth failed` on every attempt, with the camera healthy
again and no authenticated request reaching it. Plate reads stay dead until the process
restarts, and the back-off does not cure it.
- This fits item 5 on [[zone-anpr-poc]]: 503s first, then `digest auth failed` at the frame
rate.
- A camera that really answers 401 to an authenticated request ends in the same message, so
the park-lab log alone does not tell the two apart. In that case the lockout risk recorded
there stands.
- What tells them apart in the container log: exactly six 503 or timeout failures before the
first `digest auth failed`, and the video stream still logging in at the time.
14. **The back-off carries over to the next car (by reading).** `read_pause_until` is not reset
when a visit ends. A 30 s pause from one car covers the 1–2 s approach of the next, which is
the only time the plate reads at night.
15. **Stills are pulled back to back with no cap (by reading).** A car that stands with an
unreadable plate draws a hi-res still as fast as the camera answers, for the whole stay.
16. **Cause of the night hangs (hypothesis).** [[lpr-camera]] records that a second concurrent
still request draws a 503. The dev machine's app pulls stills for the same car at the same
time. The PoC's own back-to-back pulls add to it.
## Smaller items (by reading)
- **Web page.** It listens on all interfaces with no login. `POST /arm` arms the real open relay,
and `POST /zone` and `POST /line` redraw what opens it.
- **Relays.** The board's reply is stored but not checked. `opened` is set when the pulse was a
dry run or failed.
- **Disk.** Clips are pruned by count of visits, not by size, and a visit has no frame cap.
`saves/` and the `.jsonl` files are never pruned. `/status` reads three whole files every
700 ms for each open page, without the write lock.
- **Clip and verdict images are written on the tracking thread.**
- **Credentials.** `${VAR}` is pasted into the URL unencoded, so a password containing `@`, `/` or
`:` breaks the URL, and `safe_url` does not mask a password containing `/`.
- **RTSP client.** The socket is not closed on an error, no `TEARDOWN` is sent, the body read has
no end-of-stream check, `DESCRIBE` is sent one time too many, and the RTP extension bit is
ignored.
- **Dead code.** `inside()`, the `xs`/`ys` lists in `step()`, `Relays.last_open`,
`Relays.status()`, `onvif.py`.
- **Stale text.** The module docstring and the page heading still say "log only, no barrier
action". `bench-parklab.sh` names containers that no longer exist. `.gitignore` misses
`out.log`, `__pycache__/` and `models/`.
## Status after the 2026-11-22 builds
The PoC was changed three times on 2026-11-22 ([[zone-anpr-poc]], "The 2026-11-22 build" and
"Since the first build"). What is still open is collected on [[vision-hardening]].
| Finding | Now |
|---|---|
| 1 lost car judged abandoned | `unclear`, no close (default; `close_on_lost` reverses it) |
| 2 broken track, 4 track jumps to another car | tracker unchanged; no close can go out while a vehicle is in the zone |
| 3 "zone free" ignores other cars | fixed: busy is any vehicle in the zone, checked again before the close is sent |
| 5 "moving away" leaves the boom up | fixed: an uncrossed open is abandoned |
| 6 opens by others invisible | partly: the board's status is read before every pulse |
| 7–9 lane lock | open |
| 10–12 liveness and timing | open, except that a close needs a frame under 1 s old |
| 13 the still client dies for good | fixed: a new client for every still |
| 14 the back-off carries over to the next car | open |
| 15 stills back to back with no cap | fixed: at most one every 0.5 s, capped while the car stands |
| 16 cause of the still hangs | open; still seen, by day and by night |
| One frame at the end decides the verdict (found by reading, not replayed then) | seen for real on 2026-11-22 night; fixed: a side counts after two looks |
| Relay pulses on unordered threads; dead `last_open`, `status()` | fixed |
| Other smaller items | open |
## What to change, in order
1. **Give the verdict the end reason.** `left the zone`, `left the frame at an edge` and `lost`
are three different endings. Only the first two may give `abandoned`. `lost` is `unclear`.
2. **Close only on an empty zone.** At close time: no detection of any vehicle in the zone on any
camera bound to the barrier, the last frame younger than about 1 s, and no open since the
visit's own. This adds no dwell.
3. **"Moving away" is gone (user, 2026-11-22).** An open that the vehicle does not cross is
abandoned, whatever the vehicle did before: the flow on [[passage-confirmation]]. That
settles finding 5. Changes 1 and 2 are still needed under the new flow, and are listed there
as not settled.
4. **Re-acquire before giving up.** When the overlap match fails, take the nearest detection in
the zone before counting a miss, and refuse a match that jumps to a box already present on the
previous frame.
5. **Add a wall-clock limit beside the frame counts.** Counting in frames was deliberate, so that
a stall does not end a visit. Keep it, and end the visit as `unclear` when the newest frame is
older than a few seconds.
6. **Make the lane lock a short hold after the owner's visit ends,** and clear a yield only after
several empty frames in a row.
7. **Build a fresh opener for each still,** reset the back-off at the start of a visit, and cap
stills at about two a second.
8. **Keep the replay as a regression test** next to the PoC.
To confirm on park-lab data: how many visits ended `abandoned` with a path of only `a` and no
frame of the car leaving the zone (findings 1 and 2), and whether `digest auth failed` lines stop
only at a container restart (finding 13).
+374
View File
@@ -0,0 +1,374 @@
---
type: concept
tags: [parking, vision, anpr, passage, relay, poc, park-lab]
sources: []
updated: 2026-11-22
---
# Zone ANPR PoC — field trials on park-lab
A vendor-neutral, NVR-style prototype of [[passage-confirmation]], run on park-lab against the real
lane, relays and barrier. Code: `poc/zone-anpr/` (`zone_anpr.py`, with its checks in `test_flow.py`
and the recorded drives in `recordings/`). It runs on park-lab as container `zg2`, with its page
on port 8094. Camera and relay credentials come from the environment only.
**Status (user, 2026-11-22):** the PoC has served its purpose. The flow and the relay rules work on
a live barrier; the plate and the detector do not hold on a wet night. Further hardening is
deferred to a later session, and the work list is on [[vision-hardening]].
- **Seeing the car:**
- the **low-res MJPEG stream** (1280×720), about 5 frames a second through YOLOX-Tiny on the Intel
iGPU;
- the same frames give the car's position against the drawn line: side A, on the line, or side B.
- **Reading the plate** ([[zone-anpr-plate-trials]]):
- **hi-res stills**, and the stream frames as a second source, CPU OCR, in the background;
- consensus of 3 votes and 75% agreement, every character ≥ 0.9;
- **no country or format rule** (user: the Albanian rule was "unacceptable").
- **Records:**
- `out/visits.jsonl` (the verdict per visit);
- `out/relays.jsonl` (every pulse, live or would-be);
- `out/reads.jsonl` (the plate per visit) and `out/reads-all.jsonl` (every read);
- `out/clips/` (every processed frame of a visit with its box, and the stills with their
reads).
## The flow (user, 2026-11-21)
> **Replaced (user, 2026-11-22).** The new flow is on [[passage-confirmation]], "Decided with the
> user (2026-11-22)", and is built: see [[#The 2026-11-22 build — new flow, relay rules, R2 live]].
> What follows is the 2026-11-21 flow, kept for the record of that night's trials.
1. **A car comes into a zone.** It counts when the detector is ≥ 0.4 sure and ≥ 20% of the car's
box lies in the zone. If the **other camera already owns the lane**, the car is ignored (see
[[#Shared lane]]). Otherwise a **visit** starts, and **R1 opens**.
2. **While the car is in the zone**, its side is noted on every frame. The plate is read on the
side, and nothing waits for it.
3. **The visit ends when the zone is free**:
- the car has been out of the zone for 1 s, or
- the car has not been seen at all for 3 s.
4. **The decision is made at once:**
| What the car did | Verdict | R2 |
|---|---|---|
| From A, ended fully on B | passed | nothing |
| Came toward the line or onto it, went back to A | **abandoned** | **close** |
| Stayed on A and never came closer | moving away | nothing |
| From B to A | other direction | nothing |
| Lost while on the line, or similar | unclear | nothing — the boom stays up |
| Started on B and stayed there | stayed beyond | nothing |
R2 fires only if R1 opened in the same visit.
**The user's rule for the close:** *"As soon as the zone is free and the crossing is abandoned we
fire R2."* How long a car stands in the lane does not matter. There is no dwell timer and no
window. This answers the dwell/window open question on [[passage-confirmation]].
**Trial settings, not the design:**
- R1 opens for **any** car. In the design it opens on a known plate or a ticket.
- R2 is a **dry run**: it is logged as "WOULD PULSE R2" and closes nothing, until the
preconditions on [[passage-confirmation]] are met.
- Relays are **disarmed by default** and arm for 30 min. A restart disarms them. The lane has
no wifi, so arming was done remotely (`POST /arm` on park-lab).
## The 2026-11-22 build — new flow, relay rules, R2 live
`zone_anpr.py` now implements the flow and the relay rules decided on [[passage-confirmation]]
("Decided with the user (2026-11-22)").
**Deployed to park-lab on 2026-11-22** (user: "Deploy"), container `zg2` restarted at 09:56 UTC:
- `"close_live": true` is set in its config, so R2 is live once the relays are armed;
- it came up **disarmed**, with both streams live and the board answering (all relays off);
- the 44 checks also pass inside the container;
- the previous file and config are kept beside it as `zone_anpr.py.bak-20261122-preflow` and
`config.json.bak-20261122-preclose`.
**`close_on_lost` is on, on park-lab (user, 2026-11-22).** After the user's point that the
barrier's own sensors cover the space under the boom, the config got `"close_on_lost": true` and
`zg2` was restarted at 10:00 UTC. A car the detector loses inside the zone now gives `abandoned`
and R2, like any other uncrossed open. The code's default stays off.
**The flow, as built:**
- A visit is one **busy period of the zone**. It starts as before, on a sure car in the zone, with
one R1.
- **Busy** means any vehicle in that camera's zone, at the low keep threshold (0.15), not only
the car being followed.
- A **crossing** is the followed car changing from fully on one side to fully on the other. The
last one replaces the one before. A car last seen on the line with its box at the picture's
edge counts as having left on that side, as before.
- Nothing is decided while the zone is busy. When it is free: last crossing A → B is `passed`;
anything else is `abandoned`, and R2 is asked for if R1 opened in that period.
- The line's `direction` is ignored: A → B is always in. The page has only "Swap A/B" left.
**Three defaults the user has not ruled on** (the "not settled" list on [[passage-confirmation]]):
- **A car that vanishes inside the zone gives `unclear` and no close.** The zone counts as free
only when the followed car was seen outside it. A car that drops out with its box at the
picture's edge does not count either. `"close_on_lost": true` in the config turns this off and
closes on a lost car too.
- **Busy looks at the camera's own zone only**, not at the other camera's.
- **A drive-out (B → A) is `abandoned` and fires R2**, as the flow says.
**The relay rules, as built:**
- One worker sends everything to the board, in order.
- Before a pulse it reads the status. Other relay off: fire. Other relay on: off command, read
again, and so on until it reads off. This is the same for open and close.
- A failed read or pulse is followed by an **online probe**: a TCP connect to the board's web
port (`relays.http_port`, default 80). Online: keep looping. Not online: the command is dropped
and the page shows **RELAY CONTROLLER OFFLINE**.
- **Immediately before every datagram** the command is checked again: still armed, not replaced
by a newer command, and still valid. A close is valid only while no visit is running, the zone
is not busy, and the last processed frame is under 1 s old. So an open never waits behind a
close that is still trying.
- While disarmed, or for a close with `close_live` off, **nothing** is sent: no pulse, no off
command, no read.
- Timing: 0.4 s for a reply, 0.1 s between tries (`relays.timeout_s`, `relays.retry_s`).
- The page has a "Read board" button (a status read, which moves nothing).
**Checked against the real board** (one status read from inside `zg2`, 2026-11-22): the reply was
`ffaa5a00000f`, session and command echoed, relays all off, in 42 ms. The web port 80 is open.
**Tests.** `poc/zone-anpr/test_flow.py` had 44 checks at this build, all passing, in three parts:
the flow on scripted boxes; the relay rules against a mock board, datagram by datagram; and a real
camera object wired to the real relay code and the mock board, armed with the close live. It
needs no camera, model or relay.
**Replay of the recorded night drive.** The boxes park-lab recorded for each visit
(`out/clips/*/frames.jsonl`) were fed through the new code, with the line that was in force
during the drive. Of the 23 entry visits, 21 have an old record to compare with, and the side
paths came out identical for all 21.
| Old verdict | Visits | New |
|---|---|---|
| passed | 7 | passed, no R2 |
| abandoned, the car followed out of the zone (17:02, 17:03, 17:36, 17:55, 17:56) | 5 | abandoned, R2 |
| abandoned, the recording ends with the car inside the zone (16:35, 16:37, 17:04, 17:05) | 4 | unclear, no R2 |
| other direction (16:34, 17:00, 17:54) | 3 | abandoned (B → A), R2 |
| stayed beyond | 1 | passed |
| moving away | 1 | unclear |
| cut off by a restart (17:33, 17:58) | 2 | abandoned and unclear |
- Of the nine entry drives the user confirmed live, the seven from 17:28 on come out as before,
except 17:54: the drive-out is now `abandoned` with R2, which is what the new flow says.
- The two confirmed abandonments at 16:35 and 16:37 become `unclear`, and so do 17:04 and 17:05.
In all four the old tracker lost the car while it was still in the zone:
- 16:35 and 16:37 have gaps of 6 s and 3 s between frames (the tracking loop was blocked);
- at 17:04 and 17:05 the reversing car was dropped with a quarter of its box still in the zone.
All four were recorded before the 17:20 restart. The three abandonments recorded after it
(17:36, 17:55, 17:56) were followed until the car was fully out of the zone, and they close.
**This is what the "no close on a lost car" default costs:** a turn-back the detector drops
inside the zone leaves the boom up.
- 16:35 is partly an artefact: the replay treats a gap between recorded frames as frames with no
car, where the real loop was standing still.
- A second replay ran the real detector on the saved frames (on the CPU, where park-lab uses the
iGPU). No visit was held open by other vehicles in the zone. Two short visits came out
differently because the boxes differ slightly between the two devices.
- The clips hold only frames in which the old tracker matched the car, so the replay cannot show
how often something else keeps the zone busy after a visit.
**Limits of this build:**
- The tracker is unchanged: one followed car, matched by overlap. A track that breaks or jumps to
another car now ends in `unclear`, or in a late decision, never in a close with a vehicle in
the zone.
- A second car that enters the zone before the first has left gets no open of its own.
- The exit camera has `relay_open` and no `relay_close`. While it owns the lane the entry camera
yields, so no close can come for that car.
- The lane lock, the plate stills and the disk items of [[zone-anpr-poc-review]] are untouched.
**R2 live (user, 2026-11-22: "this time we will try live firing of R2").** `close_live` is set on
park-lab; arming on the page is all that is left.
The three preconditions under "Still open" are **not met**: the interlock has not been checked
with a meter, the `DET`/`PHO` reversal has not been proven on the unit, and [[barrier-not-a-door]]
has not been revised. The user chose to run the trial anyway.
**Under the boom is the barrier's job (user, 2026-11-22):** *"The barrier always has radars or
infrared sensors that monitor the under the boom... If there is something the boom will not get
down whatever the relay commands."* So the PoC's "zone free" does not have to cover the space
under the boom, and nothing needs checking on the page before arming. This is the same split as
[[barrier-not-a-door]]: safety is in the barrier's firmware, the host only expresses intent. The
bench test of it on the park-lab unit ([[passage-confirmation]], test plan steps 2–3) has not
been run.
### Since the first build
The same day brought two more builds, both described on [[zone-anpr-plate-trials]]:
- **The plate build (deployed 11:15 UTC):** the stream frames as a second source beside the
stills, the stills kept with their reads, a new HTTP client for every still.
- **Two fixes after the night trial (deployed 16:54 UTC):**
- a side, and "outside the zone", count only after two looks in a row, and the leaving edge is
judged on the last box that agreed with the car's side. A stray last box had turned a
crossing into `abandoned`, and R2 had fired behind the car;
- a read does not vote when the picture is burnt out right beside the plate.
- **Checks now:** `test_flow.py` has 65. `replay_recordings.py` replays the 48 recorded entry
visits of both days from their recorded boxes: of the 21 where the driver said what he did, 20
are judged right with `close_on_lost` on (two of them would be `unclear` without it). The one
miss is the turn-back of 10:18 below, recorded while the zone still ended short of the picture's
edge.
- **park-lab runs the file that is in the repository** (checked 2026-11-22), with `close_live` and
`close_on_lost` on. It starts disarmed.
## Live R2 trial (2026-11-22, AA927AU, UTC, daylight)
Relays armed at 10:00:50 with the close live and `close_on_lost` on. The table is what the PoC
logged. **The user confirmed that the boom came down at every abandonment** of the first run.
| Time | Camera | What the user did | Verdict | Relays |
|---|---|---|---|---|
| 10:02:45 | entry | drove through | passed (A → B at 10:02:54) | R1 |
| 10:03:15 | exit | the same car, driving on | abandoned (lost in the zone) | **R1 again**, no close possible |
| 10:03:42 | entry | abandoned the crossing | abandoned, zone free at 10:03:49 | R1, then **R2 sent** |
| 10:03:59 | entry | stood in the zone for 2 min 50 s, then abandoned | abandoned, zone free at 10:06:49 | R1, then **R2 sent** |
| 10:09:57 | entry | drove in | passed (A → B at 10:10:05) | R1 |
| 10:10:24 | exit | drove out | abandoned (lost in the zone) | R1, no close possible |
| 10:10:49 | entry | abandoned the crossing | abandoned, zone free at 10:10:57 | R1, then **R2 sent** |
- **All three closes went out live** and the board acknowledged them. The first two are the first
live R2 pulses.
- **The drive-out at 10:10:24 was handled by the exit camera alone.** It owned the lane, so the
entry camera yielded and saw no B → A crossing. The exit camera opened R1 and judged the pass
`abandoned`, which is the wrong word for it; it has no close relay, so nothing was sent.
- **Nothing was decided while the car stood in the zone** (10:03:59 to 10:06:49).
- **Every pulse was preceded by a status read**, and the other relay never read on.
- **The exit camera opened the barrier a second time for a car that had passed** (10:03:15,
twenty seconds after the crossing). The entry visit had ended, so the lane lock no longer held
it: finding 7 on [[zone-anpr-poc-review]]. The exit camera has no close relay, so that open
stayed until the next close.
### A turn-back judged as passed (10:18–10:22)
The user drove up, stood in front of the boom for three minutes and then reversed. The PoC
recorded `passed` at 10:21:08, and the boom stayed up.
- **The entry camera does not see the boom.** A car waiting in front of it stands mostly to the
right of the picture: from 10:18:14 only its rear was in view, and by 10:21:05 a strip between
x 0.91 and the edge.
- **That strip lay right of the line** (x 0.85–0.91), so the car read "on side B": a crossing
A → B.
- **The zone ends at x 0.94–0.95, short of the picture's edge.** Only a fifth of the strip was
inside it, so the zone read free a second later, and the visit was decided: passed.
- **The reversal was not seen.** With the entry visit over, the exit camera took the lane at
10:21:19 and fired R1. The entry camera ignored the car as it backed through its zone (10:22:00,
"lane busy with exit"). The exit camera judged `abandoned`, and it has no close relay.
Replayed on the recorded boxes with the **zone drawn to the picture's right edge**: the strip is
57% inside the zone, the visit stays busy, and then a car that drives on gives `passed`, and one
that reverses gives B → A, `abandoned` and R2. So the fix is the zone drawing, plus taking the
exit camera out of the lane (below).
### park-lab is the worst case (user, 2026-11-22)
The user's reading of the trial: park-lab is the hardest site there is. One lane serves entry and
exit, and the raised boom crosses the exit camera's picture.
- **Only park-lab has these problems:** the lane lock between two cameras, a drive-out that reads
as B → A on the entry line, and the exit camera opening for a car the entry camera should judge.
park-2 and park-buzi have two lanes and two barriers ([[passage-confirmation]]), so each camera
sees one direction.
- **Every site has these:** the camera has to see the car up to the boom, the zone has to reach
the picture's edge on that side, and a car the detector loses must be handled.
- **What the trial showed regardless of the site:** the flow and the read-then-fire relay rules
work on a live barrier, and the boom came down at every abandonment the entry camera judged.
## Night drive results (2026-11-21, AA927AU, UTC)
The user drove and confirmed each move live.
| Time | Camera | What the user did | Verdict | Right? |
|---|---|---|---|---|
| 16:35 | entry | stopped, reversed out | abandoned | ✅ |
| 16:37 | entry | stopped short of the line, reversed out | abandoned | ✅ |
| 17:28 | entry | drove through | passed | ✅ |
| 17:36 | entry | to the line, reversed | abandoned, R2 would close | ✅ |
| 17:52 | entry | drove through | passed | ✅ |
| 17:54 | entry | drove out toward the street | other direction | ✅ |
| 17:55 | entry | up to the line, reversed | abandoned, R2 would close | ✅ |
| 17:56 | entry | **nose over the line**, reversed | abandoned, R2 would close | ✅ |
| 17:59 | entry | stood ~50 s, then drove through | passed | ✅ |
| 17:32 | exit | drove out | moving away | ❌ |
| 17:53 | exit | reversed | abandoned | ✅ |
| 18:00 | exit | drove out | moving away | ❌ |
**Entry: every move judged right**, including the hard one (nose over the line, then back).
**Exit: not usable** (below).
## The back-and-forth — what failed and what replaced it
1. **R2 on "the car left the zone" (first try).** On the recordings it missed both turn-backs,
because a reversing car still overlaps the zone. It also produced a false close on a car waiting
outside the zone.
2. **R2 on retreat distance: 0.12 of the frame, held 2 s (second try).** It never fired on the
real drive. Once fully back on side A, a reversing car is in view for well under a second. The
user rejected waiting at all. That led to the flow above.
3. **The visit ended only when the car left the camera's view.** A car reversing down the street
was followed for minutes, so the verdict and R2 never came. Fix: the zone counts as **free**
after 1 s out of the zone.
4. **Plate stills blocked the tracking loop.** A hung still (3 s timeout, 11 times in 3 minutes
at night) froze the track, so a reversing car vanished between two frames. Fix: the plate read
runs in the background, at most one at a time per camera.
5. **The camera was being hammered.** Failed stills were retried on every frame. The camera
answered `503`, then `digest auth failed` about 5 times a second. That risks an account
lockout, which would cut the video stream too. Fix: back off 2, 4, 8 … up to 30 s after a
failure. **Root cause not found:** a still normally takes about 200 ms, and the night hangs are
unexplained.
**Likely cause, from [[zone-anpr-poc-review]] (finding 13):** `digest auth failed` is also what
the PoC's own HTTP client says once it has given up, which it does for good after six failed
stills in a row. It then sends no credentials, and the back-off does not cure it. Not yet
checked against the container log.
6. **Both cameras opened for the same car.** At 16:36 a car got an open from the entry camera
and another one 6 s later from the exit camera. Fix: a **lane lock**, see
[[#Shared lane]].
7. **A crop around the zone cut a close car in half.** The exit camera then saw no car at all.
Fix: detection runs on the whole frame. It costs the same, because the detector resizes anyway.
8. **Detection flickered in headlight glare.** A standing car scored 0.4–0.5 and dropped out for
3 s at a time. Each drop ended the visit, and the next sighting opened the barrier again. Fix:
a visit **starts** at ≥ 0.4 and **keeps** the car down to 0.15.
### Shared lane
park-lab is one lane for both directions ([[passage-confirmation]] "park-lab rig"), so every car
passes both cameras. The PoC lets **one camera own the lane at a time**. The other camera ignores
cars until the owner's visit has ended **and** its own zone has been empty once. Without that
second condition, the car just handled would start a new visit there, with a new open. On the
drive the far camera ignored the car every time, and no double open happened after the fix.
### Plates
Plate reading, what was measured about it, and the day and night trials of 2026-11-22 have their
own page: [[zone-anpr-plate-trials]]. In short:
- the plate reads only on a short stretch of the approach, and is not needed for the verdict;
- the hi-res still is the main reader, the stream frames a faster and weaker second source;
- on a wet night, 5 plates were decided in 11 entry visits, 2 of them wrong;
- a pass was judged abandoned that night, and two fixes followed (above, "Since the first build").
### The exit camera is out (user, 2026-11-21)
The user's verdict: *"Fuck the exit, it's flawed. The barrier interferes with the camera image when
it's open."*
- The boom swings through the exit camera's view when it rises. This was first seen in the
2026-11-19 recordings on [[passage-confirmation]].
- The exit line is also drawn off the cars' path.
- Exit verdicts were wrong on 2 of 3 drives.
- **On park-lab the entry camera alone judges the crossing in both directions:** it saw drive-ins
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.
## Still open
Deferred by the user on 2026-11-22. The work list, with the evidence for each item, is on
[[vision-hardening]]. The points that are the user's to rule on:
- **A car the detector loses inside the zone:** no close (the code's default) or a close
(`close_on_lost`, on at park-lab).
- **The exit camera on park-lab:** it still opens R1 and cannot close.
- **R1 on known plates only,** which is the real design. The PoC opens for any car.
Before R2 is used anywhere else, the preconditions on [[passage-confirmation]] still stand: the
interlock checked with a meter, the `DET`/`PHO` reversal proven on the unit
([[zkteco-cmp200-barrier]]), and [[barrier-not-a-door]] revised. The Dingtian "Mutually
Exclusive" mode does not replace the wiring.
+5 -1
View File
@@ -2,7 +2,7 @@
type: decision
tags: [parking, decisions, open]
sources: [parking-system-architecture]
updated: 2026-11-20
updated: 2026-11-22
status: open
---
@@ -191,6 +191,10 @@ procurement. (See [[parking-system-architecture]] §10.)
evidence. Settles when the park-lab tests (loop/photocell override, reversal, tailgate, vision
down) pass and [[barrier-not-a-door]] is revised with the results attached. Needs a camera and
a barrier operator on park-lab first.
_(Update 2026-11-22: tried on park-lab with a prototype and a live close ([[zone-anpr-poc]]).
The flow and the relay rules worked by day, with one turn-back misjudged; the plate and the
detector did not hold on a wet night. Still undecided: what a car lost inside the zone does, and the bench tests of the
barrier's own safety. The open work is on [[vision-hardening]], deferred.)_
## Cloud takeover mode vs. the signed ledger (2026-10-22, parked)
+10 -1
View File
@@ -2,7 +2,7 @@
type: entity
tags: [parking, hardware, barrier, relay, wiring]
sources: []
updated: 2026-11-14
updated: 2026-11-22
---
# ZKTeco CMP200 Barrier Gate
@@ -63,10 +63,19 @@ The v1.0 board has no RS485 and no `CAR`. The 4-pin `REMOTE` header takes the 43
permanent close command; closes on controller power loss). Per the manual a `DET` or `PHO`
contact reverses a falling boom, so the close is not blind **if a detector is fitted** — to be
proven on the unit (test plan steps 2–3 there) before any use.
- **Dingtian "Mutually Exclusive" is not this interlock (user, 2026-11-21).** The board can pair two
relays so that switching A on turns B off ("to protect the motor"). That makes the **last**
command win: a close on relay 2 would cut a held open on relay 1. The series wiring above makes
**open** win (relay 2 is dead while relay 1 is on), which is what [[barrier-not-a-door]] needs.
The board setting may be enabled as well, but it does not replace the wiring, nor the `DET`/`PHO`
proof on the unit.
- **Status back to the host:** `O.LM OUT` and `C.LM OUT` are volt-free contacts, so they can go
straight onto two Dingtian inputs (contact to GND, like the button). That gives the host a real
"boom reached open / closed" signal for [[device-status-monitoring]] and for the anomaly "boom
opened with no signed host command" ([[threat-model]]).
- **The close does not need that signal (user, 2026-11-22).** R2 fires on an abandoned open
without looking at the boom, and a close on a closed boom is expected to do nothing (not yet
tried on the unit). The relay rules are on [[passage-confirmation]], "Relay rules".
- **Sharing a detector:** a radar/loop with one dry contact cannot feed both `DET` and a Dingtian
input directly (two different supplies on one contact). Use a detector with two relay outputs
or an interposing relay.
+5 -1
View File
@@ -104,7 +104,11 @@ Counts: 4 sources · 19 entities · 47 concepts · 9 decision records.
- [[booth-exit-flow]] — manned booth: pay → voucher (self-exit later) or immediate exit; active sessions; audited barrier re-open.
- [[park-2-event-loop-stall]] — INCIDENT 2026-10-24: `/api/sessions/active` ran ~2 s synchronously (per-row unindexed ledger scans × 664 open unpaid tickets), froze the event loop, and made healthy Dingtian pulses report "timeout" (timers run before socket I/O) → signed entries with no snapshot/session row. Fix: fold-once pricing, hot-path indexes (0032), deferred UDP timeout, evidence before pulse. Rule: bounded request cost whatever the operator data.
- [[park-2-disk-growth]] — INCIDENT 2026-11-20 (open, deferred): nightly full backups on the data disk push park-2 past 70%, where the snapshot valve deletes all but 500 snapshots and likely freezes the server. Old backups deleted by hand (disk 29%); retention unchanged, 70% again ~2026-12-05. 66% of snapshots are Car Wash `pass:` samples nothing deletes. Code fixes wait.
- [[passage-confirmation]] — DESIGN 2026-10-24 (open): confirm a car actually crossed after the open, on the booth PC (cheap cameras have no line-crossing): sub-stream watcher + YOLOX tracker + a drawn segment → signed `vehicle_passed` / `entry.abandoned`; lane free on passage; evidence-driven (never timed) close on a spare relay after an abandonment; phase 1 = the close only (dry run first); A→B/B→A/A↔B line editor in Setup built; relay maps per site; park-lab test plan.
- [[passage-confirmation]] — DESIGN 2026-10-24 (open): confirm a car actually crossed after the open, on the booth PC (cheap cameras have no line-crossing): sub-stream watcher + YOLOX tracker + a drawn segment → signed `vehicle_passed` / `entry.abandoned`; lane free on passage; evidence-driven (never timed) close on a spare relay after an abandonment; phase 1: crossings → unexplained-passage anomaly (audit) → abandoned verdict (dry-run close) → real close; line editor built; relay maps. Zone flow and relay rules decided 2026-11-22: last crossing counts, no decision while the zone is busy, an uncrossed open is abandoned → R2.
- [[zone-anpr-poc]] — PROTOTYPE of passage confirmation on park-lab (2026-11-21/22, `poc/zone-anpr/`): the zone flow (nothing decided while the zone is busy, the last crossing decides) and read-then-fire relay rules, run with a live close; lane lock for the shared lane, exit camera dropped, park-lab as the worst case. Trials closed by the user 2026-11-22.
- [[zone-anpr-plate-trials]] — PLATE READING in the zone PoC, measured (2026-11-22): the plate reads only on a short stretch of the approach; hi-res still is the main reader, stream frames a weaker second source; inverting does not help; day and wet-night trials (5 plates decided in 11 night visits, 2 wrong); a pass judged abandoned and the two fixes that followed.
- [[zone-anpr-poc-review]] — CODE REVIEW 2026-11-21 of the zone PoC, replayed offline: a lost car or a broken track is judged abandoned and closes; "zone free" ignores other cars; lane-lock gaps; the still client dies for good after six failed stills; bottlenecks; a status table of what the 2026-11-22 builds fixed.
- [[vision-hardening]] — WORK LIST, deferred 2026-11-22: what the zone PoC left open on the vision side — glare boxes at night, reading the plate before the visit (with its identity risks), hazy flare and steep-angle misreads, the lost-car rule, the exit camera on the shared lane, relay and barrier preconditions; a possible order and how to pick it up.
- [[operator-issued-entry]] — operator mints an entry ticket when the physical button is broken; presence-gated (radar AND camera, both sides), flagged (source=manual + operatorInitiated + anomaly), capacity-override allowed; needs `session:create` (2026-07-01).
- [[plate-reconciliation]] — ANPR plate-as-invariant catches the ticket-swap fraud (paid car let out on a fresh $0 ticket, original lingers "inside"); exact/high-conf match vs open sessions; booth = flag + operator override, reader = log-only fail-open (2026-07-01).
- [[shift]] — manned-only accountability period; explicit Start/End; End → signed + printed Z-report; drawer float carries across shifts. Drawer cash movements (operator records, admin reviews via signed cash_review — a flag, not a reversal) live at the /drawer route (2026-07-01).
+217
View File
@@ -3760,6 +3760,33 @@ own channel from the start, and early frames are held until the open. Not yet ch
desktop app. Also recorded that both park-lab cameras now push to the dev machine. Updated
[[desktop-shell-tauri]], [[camera-live-view]], [[passage-confirmation]].
## [2026-11-19] decide | Passage confirmation — unexplained passages as the audit witness; phase 1 reordered
User proposed that a vehicle crossing the line with no ticket, subscription or other signed open
behind it, e.g. after the operator raises the boom with a remote, be recorded with its plate as an
anomaly for audit. Agreed and recorded:
- the matching rule: one signed open covers one crossing;
- `anomaly` reason `passage.unexplained`, kept unsigned in `device_events` until crossings are
proven, and shown in reports and the Z-report;
- the abandoned verdict marks its open used;
- unwatched periods are recorded.
Phase 1 reordered to: crossing detection → unexplained passages → abandoned verdict with a dry-run
close → the real close last. Updated [[passage-confirmation]], [[append-only-event-chain]],
[[reconciliation]] and the index.
## [2026-11-19] query | Passage confirmation — first recordings (AA890XX entry, exit, turn-back)
Started a dev clip recorder (both cameras, around each server event). The user drove AA890XX in,
out, then in-and-back. A YOLOX and IoU-tracker prototype over the clips:
- the entry camera saw in (A → B), out (B → A) and the turn-back (A → B → A); the ledger recorded
the turn-back as an entry;
- the entry line sits where cars stop (crossed before the open), and the exit line is off the
cars' path;
- the boom is visible in the exit camera's view.
Recorded on [[passage-confirmation]].
## [2026-11-20] query | park-2 disk growth — backups, pass samples, and the snapshot valve
User asked how long before park-2's disk fills (`parking.sqlite` 6.1 GB and growing). Measured
@@ -3784,3 +3811,193 @@ so the disk reaches 70% again around 2026-12-05. The user deferred the code fixe
feature work on `stage` is deployable. Recorded the new state, the next deadline and the
corrections from the code review (freeze length, compression, no threshold knob, partial files)
on the page.
## [2026-11-21] query | Dingtian "Mutually Exclusive" vs the close interlock
The board mode makes the last relay command win (a close cuts a held open); the series wiring makes open win. Recorded on [[zkteco-cmp200-barrier]]; R2 stays dry-run in the zone PoC.
## [2026-11-21] query | Zone ANPR PoC — night drive, the close rule, exit camera dropped
The user drove AA927AU on park-lab with R1 live and R2 as a dry run, confirming each move live.
The entry camera judged every move right, including nose over the line and reverse. The user set
the close rule: abandoned and zone free means R2 at once, with no dwell or window. The exit camera
was dropped because the rising boom crosses its image and its line is off the path. On the way:
- a lane lock for the shared lane;
- the visit ends when the zone is free, not when the car leaves the view;
- plate reads moved off the tracking loop, with backoff after the camera answered 503 and
`digest auth failed` under load;
- detection on the whole frame;
- separate start and keep detection thresholds.
Wrote [[zone-anpr-poc]]. Updated [[passage-confirmation]] (field trials section; the dwell/window
open question closed) and the index.
## [2026-11-21] query | Zone ANPR PoC — code review
The user asked for logical flaws, bottlenecks and bugs in `poc/zone-anpr`. The tracking logic was
replayed offline with a scripted detector and a relay stub; park-lab was not touched. Main
findings: the verdict does not know how a visit ended, so a car the detector loses, or a track
that breaks, is judged abandoned and closes; "zone free" looks only at the tracked car; the lane
lock gives a second open in two cases and starves a waiting car in a third; the still opener dies
permanently after six failed stills in a row, the likely source of `digest auth failed` (not yet
checked against the park-lab log).
Wrote [[zone-anpr-poc-review]]. Noted the correction and the open item on [[zone-anpr-poc]];
updated the index.
## [2026-11-22] query | Passage confirmation — the zone flow and the relay rules
The user set the flow: A → B is in, B → A is out, only the last crossing counts, and nothing is
decided while the zone is busy. When the zone becomes free, a last crossing of A → B is passed;
anything else is abandoned and fires R2. The close does not look at the boom: a close on a closed
boom is expected to do nothing, so no boom-position signal is wired for it.
Recorded on [[passage-confirmation]] ("Decided with the user (2026-11-22)"), with three points
from [[zone-anpr-poc-review]] listed as not settled (what counts as busy, a lost vehicle, the
B → A drive-out on park-lab) and the open-wins relay order as proposed. Noted on [[zone-anpr-poc]]
that its flow table is replaced, on [[zone-anpr-poc-review]] that "moving away" is gone, and on
[[zkteco-cmp200-barrier]] that the limit contacts are not needed for the close. Updated the index.
## [2026-11-22] query | Relay rule — read the status, then fire
The user set the rule: read the board's status, and pulse a relay when the other one of the pair
is off. Recorded on [[passage-confirmation]] ("Relay rules"), replacing the proposed order. What
happens when the other relay is found on, or the read fails, is listed there as proposed.
## [2026-11-22] query | Relay rule — the other relay reads on, or the read fails
The user set both cases. The other relay reads on: send off, read again, fire once it reads off,
otherwise keep trying. The read fails: check that the controller is online; if so keep looping,
if not flag the relay offline. Recorded on [[passage-confirmation]] ("Relay rules"), with the
contradiction against "open wins" noted there and three details left to define.
## [2026-11-22] query | Zone ANPR PoC — the new flow and relay rules built, R2 live trial
The user asked for the 2026-11-22 flow and relay rules in the PoC, with R2 live this time.
`poc/zone-anpr/zone_anpr.py` was changed locally: a visit is a busy period of the zone, the last
crossing decides when the zone is free, and the relays follow read-then-fire with an online probe
and a check before every datagram. Three defaults the user has not ruled on are in the build: a
car that vanishes inside the zone gives no close, busy looks at the camera's own zone, and a
drive-out is abandoned. `test_flow.py` (44 checks) passes. The recorded night drive was replayed:
passes stay passes, the abandonments recorded after the tracking fixes still close, and the
drive-outs now close too. One status read against the real board confirmed the reply format.
park-lab was only read; nothing was deployed or armed.
Wrote the build section on [[zone-anpr-poc]], with the R2 preconditions that are still unmet.
Updated [[passage-confirmation]], [[zone-anpr-poc-review]] (status table) and the index.
## [2026-11-22] query | Zone ANPR PoC — the 2026-11-22 build deployed to park-lab
The user said to deploy. The previous file and config were backed up on park-lab, the new
`zone_anpr.py` and `test_flow.py` copied, `close_live` set to true, and `zg2` restarted at 09:56
UTC. It came up disarmed, both streams live, the relay board answering with all relays off; the
44 checks pass inside the container. Arming is left to the user. Recorded on [[zone-anpr-poc]].
## [2026-11-22] query | The space under the boom is the barrier's concern
The user: the barrier always has radar or infrared sensors under the boom, and it will not come
down on something whatever the relay commands. Recorded on [[passage-confirmation]] ("Relay
rules") and [[zone-anpr-poc]]; the pre-arming check of the zone against the boom is dropped. The
bench test of the reversal on the park-lab unit is still listed as not run.
## [2026-11-22] query | Zone ANPR PoC — close_on_lost switched on, on park-lab
On the user's instruction `"close_on_lost": true` was set in park-lab's config and `zg2` restarted
at 10:00 UTC. The relays were armed from the page at 10:00:50, with the close live. Recorded on
[[zone-anpr-poc]].
## [2026-11-22] query | Zone ANPR PoC — first live R2 pulses
The user drove on park-lab with the close live: one crossing (passed, no R2) and two abandonments,
the second after standing in the zone for almost three minutes. Both gave `abandoned` and a live
R2 that the board acknowledged. The exit camera fired a second R1 for the car that had passed.
Recorded on [[zone-anpr-poc]] ("Live R2 trial"); what the boom did awaits the user's word.
## [2026-11-22] query | Zone ANPR PoC — live R2 confirmed by the user, second run
The user confirmed that the boom came down at every abandonment. Second run: a drive-in (passed,
no R2), a drive-out (handled by the exit camera, which opened and has no close) and an abandonment
(R2 sent). Added to the trial table on [[zone-anpr-poc]].
## [2026-11-22] query | Zone ANPR PoC — a turn-back judged as passed
The user stood at the boom for three minutes and reversed; the PoC said passed. Cause: the entry
camera does not see the boom, the waiting car showed only as a strip at the picture's right edge,
right of the line and mostly outside the zone, which ends short of the edge. The exit camera then
took the lane, so the reversal was not seen. A replay with the zone drawn to the edge judges both
continuations right. Recorded on [[zone-anpr-poc]].
## [2026-11-22] query | Would inverting the picture help night plate reads?
No. The plate reader was run on the recorded night frames, as recorded, inverted, contrast-
stretched and darkened. Inverting halved the good reads on the approach and changed nothing on
the standing car, where every variant read nothing right. The standing plate is not overexposed;
it is seen almost edge-on (26–40 px wide against 82 px on the approach). Recorded on
[[zone-anpr-poc]] ("Plates at night"), correcting the "burnt white" note there.
## [2026-11-22] query | Plate reads from the stream frames — built, and an earlier claim corrected
The user agreed to read plates from the stream frames during the approach, with the hi-res still
as a second source, and asked for it in the PoC. Built: two sources voting in one consensus, the
stills able to decide alone, a size gate for stream reads, caps that count only while the car
stands, kept still crops, a new HTTP client per still, and per-read and per-visit records of the
source and the time taken. `test_flow.py` has 57 checks.
**Correction:** the previous entry's basis, 38 of 46 stream frames read right on one visit, did
not hold for the night as a whole. Replayed over all 20 entry visits, the stream alone decides 3
and the stills decided 8. The stills stay the main reader; the stream adds speed. Corrected on
[[zone-anpr-poc]] ("Plates at night").
## [2026-11-22] query | Zone ANPR PoC — the plate build deployed to park-lab
Deployed at 11:15 UTC after the 57 checks passed inside the container; `zg2` came up disarmed,
both streams live. The speed trials by day and by night are still to be driven. Recorded on
[[zone-anpr-poc]].
## [2026-11-22] query | Zone ANPR PoC — day trial of the plate build
The user drove a pass and abandonments at higher speed. Verdicts and relays were all right (four
live R2). Plates were worse than in the morning: two of six entry visits decided, after 4.8 s and
5.8 s. The car is already close and side-on a second into the visit, stills timed out 9 times in
67, and the stream gave four votes. Speed and the new still pacing changed together, so their
shares are not known. Recorded on [[zone-anpr-poc]] ("Plates at night", day trial).
## [2026-11-22] query | Reading the plate before the visit starts — what can go wrong
The user asked what happens to the reading of a car that turns away before the zone, and what
starts the reading of the next car. Answer: a reading belongs to a followed vehicle, is dropped
when its track ends outside the zone, and each vehicle starts its own. The risk is votes crossing
from one car to another. Recorded on [[zone-anpr-poc]] as constraints on an idea that is not built.
## [2026-11-22] query | Why the morning plate reads were better
The plate reads only while the car's front edge is left of about x = 900 of 1280; beyond that the
car is side-on. Reading starts when the car enters the zone, at the end of that stretch. In the
morning the car was slow enough for three stills there; at midday it had passed by the first
still. The zone redraw, the still crop and the timeouts were checked and ruled out as the main
cause. Recorded on [[zone-anpr-poc]] (day trial).
## [2026-11-22] query | Zone ANPR PoC — night trial of the plate build, wet lens
The user drove at night with a wet lens. From the recorded frames: one pass and three
abandonments with the relays armed. The abandonments were judged right and closed. The pass
(16:27:00) was judged abandoned and R2 fired behind the car: one last blurred box on side A
decided it; without that frame the replay says passed. One plate was decided wrong (`A927AU`,
three sure stills, the flare covering the first letter). Day and night are side by side on
[[zone-anpr-poc]] ("Plates at night"), with two fixes named and not built.
## [2026-11-22] query | Zone ANPR PoC — the two night fixes built and deployed
The user asked for both fixes. A side now counts only after two looks in a row, with the leaving
edge judged on the last agreeing box and one exception for a car driving out of view; a read does
not vote when the picture is burnt out beside the plate. 65 checks pass. Replayed over all 39
recorded entry visits, 37 are unchanged, the 16:27 pass is judged right, and one three-frame visit
of 2026-11-21 changes with the truth unknown. Deployed at 16:54 UTC; `zg2` came up disarmed.
Recorded on [[zone-anpr-poc]].
## [2026-11-22] query | Zone ANPR PoC — second night run, after the fixes
From the recorded frames: two drive-throughs judged passed (fix 1 held), the abandonments judged
abandoned and closed. The glare check barred the burnt-out flare, but two other sure and wrong
reads got through: the rear plate at a steep angle (`AA927AJ`, decided) and a hazy flare ghost
over the first characters (`27AU`). A glare box started a visit with no car at the line: R1 then
R2 within two seconds. Recorded on [[zone-anpr-poc]] ("Plates at night", second night run).
## [2026-11-22] query | Vision hardening — the work list, deferred to another session
The user closed the PoC trials and asked for the further hardening to be written down and left
for another session. Wrote [[vision-hardening]]: where things stand, the open items with their
evidence (glare boxes, reading before the visit and its identity risks, hazy flare and steep-angle
misreads, the lost-car rule, the exit camera, relay and barrier preconditions), a possible order,
and how to pick it up. The plate material moved from [[zone-anpr-poc]] to its own page,
[[zone-anpr-plate-trials]]. The recorded drives of both days went into the repository with a
replay (`poc/zone-anpr/recordings/`, 48 visits; 20 of the 21 with a known truth are judged right).
## [2026-11-22] lint | Passage confirmation and the zone PoC pages
Checked before committing: every page is in the index and has frontmatter; the five PoC pages
link to each other and are reached from [[passage-confirmation]], [[open-questions]] and the
overview's reading paths; stale statements on [[zone-anpr-poc]] (uncommitted code, the dry-run
close, the finished trial list) were brought up to date, and the review's status table now shows
what the later builds fixed. Corrected a count: 5 plates decided in 11 wet-night visits, not 12.
Found and left alone, as they predate this work: two pages with no inbound link
([[ds-2cd1047g3h-liu]], [[blocklist]]), and six links to pages not yet written
(`access-direction-is-per-relay`, `booth-deploy-networking`, `dingtian-http-api-unauthenticated`,
`g3h-anpr-push-gotchas`, `occupancy`, `snapshot-storage-optimization`).
+3 -1
View File
@@ -2,7 +2,7 @@
type: overview
tags: [parking, overview, synthesis]
sources: [parking-system-architecture]
updated: 2026-06-21
updated: 2026-11-22
---
# Parking System — Overview
@@ -54,3 +54,5 @@ modes (fail-open on exit)**, the **reconciliation channel**, and **backup/durabi
- *Hardware-first:* [[bom]] → [[dingtian-relay]] → [[access-controller-button-flow]] →
[[entry-exit-readers]].
- *Stack-first:* [[technology-stack]] → [[offline-first]] → [[device-adapter-pattern]].
- *Vision and the barrier:* [[lpr-camera]] → [[passage-confirmation]] → [[zone-anpr-poc]] →
[[vision-hardening]].