Files
parking_solution/wiki/concepts/passage-confirmation.md
T
julian b6f7ea65a4 wiki: G2 camera bench test and park-lab rig; Dingtian session check on sw V3.1.6236A
- lpr-camera: DS-2CD1043G2-LIU (4MP) and DS-2CD1083G2-LIU (8MP) both serve
  main-stream ISAPI snapshots; only concurrent pulls 503
- passage-confirmation: park-lab rig (entry .6, exit .7, one shared lane),
  camera capabilities, shared-lane open question
- dingtian-relay: 'config api timeout' = HTTP session check on; works with the
  session cookie on this firmware; resolution and triage

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 11:32:22 +01:00

143 lines
9.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
type: concept
tags: [parking, vision, barrier, lane, ledger, safety, design]
sources: []
updated: 2026-11-15
status: open
---
# Passage confirmation — did the car actually cross? (design, 2026-10-24)
**Problem (user, 2026-10-24).** A motion push opens the barrier and signs the entry/exit. If the
driver changes their mind and reverses out, the ledger holds a false entry, and — because the
barrier operator at the sites closes **only when its sensor/radar is tripped by a passage** — the
boom stays up until the next car trips it. That next car enters with no ticket, no read, no ledger
row. So an abandoned entry is both a wrong row and a free pass. Related: the FIFO stale-occurrence
problem seen on AB694XU the same day (an exit closes the oldest open occurrence; one double read
leaves a subscriber permanently one stay behind).
**Constraint (user).** The cameras are the cheap Hikvision DS-2CD1043G2-LIU: motion push with a
vehicle target, a sub-stream, and no line-crossing / smart events. The booth PC does the thinking.
Cameras are sensors; compute is ours. The Dahua bench unit has tripwire (`CrossLineDetection`) but
that is not the fleet camera.
## Design
1. **Frames: the RTSP sub-stream, not ISAPI stills.** Keep one RTSP session open per camera
permanently (avoids the keyframe start-up gap of 1–2 s; set the sub-stream I-frame interval to
≤ 1 s). Decode in the vision service (OpenCV 4.13 with FFmpeg is already in the container; no
`ffmpeg` binary needed). The still-pull loop in `anpr-entry.ts` is replaced by this — it also
removes the single-threaded picture-endpoint collisions (503s).
*Latency (user asked 2026-10-24):* RTSP itself adds nothing meaningful; the delay is the
camera's encoder (~100–300 ms) plus whatever the decoder buffers. Open the stream with a
minimal buffer (`CAP_PROP_BUFFERSIZE 1`, TCP transport, drop to the newest frame), and the
watcher sees a frame well under half a second after the event. The 1–2 s start-up gap is a
keyframe wait, which is why the session stays open. To be measured on park-lab against the
motion-push timestamp once a camera is on the bench.
2. **Trigger and window.** Nothing runs while the lane is empty. A motion push starts a *watch* on
that camera; it holds while pushes keep arriving (1–3 s apart while a car moves — see
[[lane-presence-and-anpr-entry]]) and ends a few seconds after they stop, or at a hard cap.
3. **Detection + tracking.** The existing YOLOX vehicle detector gives a box per car; a small
in-house tracker matches boxes between frames by overlap and follows each track's
**bottom-centre point** (ground contact; stable under perspective). No tracker library.
4. **The segment.** Drawn once per camera in Setup over a live frame; stored as two normalised
points + which side is A, in the same normalised frame the plate/vehicle boxes already use.
Crossing = sign change of the cross product of the tracked point against the segment. A→B on
the entry camera is a passage; the exit camera has its own line. A→B→A inside the window is a
reversal (not a passage). The verdict carries the track's plate if ANPR read one on it.
5. **One watcher, two consumers.** The same decoded frames feed the ANPR bridge (subscriber
auto-open) and the crossing tracker (confirmation).
6. **Lane state becomes positive.** Busy while any track is between the line and the boom; free
when the last track crossed or left the frame; the 30 s TTL stays only as a fallback when the
stream is down. `vehicle_passed` ⇒ lane free *unless another track is present* (tailgating).
This is the software form of the pass-through sensor [[entry-double-press]] asked for.
### Ledger semantics (append-only, unchanged open path)
- `vehicle_entry` / `vehicle_exit` remain **intent**: the barrier was commanded open. The open is
never delayed by confirmation.
- `vehicle_passed` (new, signed): the crossing was seen, with how (vision track) and the plate.
- `entry.abandoned` / `exit.abandoned` (new, signed): window ended with no crossing. Closes the
occurrence; a printed ticket is **invalidated** so the paper cannot be handed to the next car.
- *unverified*: vision/stream unavailable — recorded as such; the stay counts (benefit of doubt).
Occupancy and the active list count passed + unverified; abandoned are listed as what they are.
A subscriber's stay only exists once the car is seen to cross — which also kills the stale
FIFO occurrence at its root.
### Closing the boom after an abandonment — evidence-driven, never timed
[[barrier-not-a-door]] stays: no timed close. A close may be **expressed** (a pulse on a spare
Dingtian channel into the operator's *close* input) only when **all** hold: an abandoned verdict;
the tracker reports nothing between the line and the boom and nothing approaching, for a few
seconds; no new open since; the watch is alive (stream up, verdict fresh); and the close is itself
a signed event with the last frame attached. Vision down ⇒ no close, ever (today's behaviour).
The operator's safety devices (loop / photocell) must be verified to override a close command
on the real unit before this ships. Requires a revision (not repeal) of the standing decision,
with the test results attached.
## Test plan — on park-lab (user, 2026-10-24: "we will test it on park-lab")
1. Confirm the operator's close input; wire a spare relay to it.
2. Close with a car on the safety loop → boom must not move / must reverse.
3. Close with the photocell beam broken by a person → same.
4. Reversal: open, back out, window expires → close pulses, boom comes down.
5. Tailgate: second car approaching while the first backs out → the tracker holds the close.
6. Vision service stopped: reversal again → boom stays up, event logged unverified.
## Measured on park-lab (2026-10-24, i5-9500, vision container, CPU only)
YOLOX-S ONNX, input fixed at 640 by the exported graph (smaller inputs need a re-export):
| intra-op threads | ms / frame (p50) | ≈ fps on that budget |
| --- | --- | --- |
| 2 (service default) | 132 | 7.5 |
| 4 | 79 | 12.5 |
| 6 | 66–70 | 14 |
Decode of a 704×576 sub-stream frame is < 1 ms (MPEG-4 part 2 proxy; H.264/H.265 will be a few
ms) — negligible next to inference. So one lane at 5–6 fps costs ~0.7–0.8 of two cores during a
watch and nothing between watches; two lanes at once need 4 threads or detection on alternate
frames with the tracker interpolating. Cheaper still: re-export YOLOX at 416 (~2.4× fewer FLOPs)
or switch to YOLOX-Tiny/Nano for the tracker (the plate stage keeps its own detector).
## park-lab rig (2026-11-15)
Two cameras mounted on **one physical lane that serves both directions** (user, 2026-11-15):
| | Entry camera | Exit camera |
|---|---|---|
| Address | `10.0.10.6` | `10.0.10.7` |
| Model | DS-2CD1043G2-LIU (4MP) | DS-2CD1083G2-LIU (8MP) |
| Sub-stream (102) | 640×360 H.264, 12.5 fps, keyframe every 4 s | 640×360 H.264, 20 fps, keyframe every 2.5 s |
| Line crossing / intrusion (`ISAPI/Smart/LineDetection`, `FieldDetection`) | `notSupport` | `notSupport` |
| Motion detection | on, target `vehicle`, grid drawn | on, target `vehicle`, grid drawn |
| Alarm server (`httpHosts`) | not set (`0.0.0.0`) | not set (`0.0.0.0`) |
Read from the cameras over ISAPI the same day; bench snapshot results are on [[lpr-camera]].
- The 8MP model has no line crossing either, so the constraint above holds for both: the booth PC
does the tracking.
- Both sub-stream keyframe intervals are above the ≤ 1 s this design asks for (item 1).
- Neither camera pushes to park-lab yet, and neither is in its device registry.
- [[k200l-printer]] records `10.0.10.7` as the park-lab printer's fixed address — the exit camera
now answers there. To be resolved with the user.
- **Shared lane — not covered by the design above**, which assumes a camera sees only its own
direction. Here a car driving in passes the entry camera and then drives away through the exit
camera's view, and the reverse for a car driving out. Open in "Open questions".
## Open questions
- **One lane, both directions (park-lab rig).** 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).
- 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]]:
its close input is `DOWN` (dry contact to `G`), and the manual says `DET`/`PHO` reverse a falling
boom — steps 1–3 can be run on it.
Related: [[lane-presence-and-anpr-entry]], [[barrier-not-a-door]], [[entry-double-press]],
[[append-only-event-chain]], [[opencv-anpr-service]], [[park-2-event-loop-stall]].