poc(zone-anpr): passage-confirmation prototype run on park-lab

A standalone prototype of passage confirmation, tried on park-lab against the
real lane, relays and barrier (wiki: concepts/zone-anpr-poc.md).

- zone_anpr.py: vehicle detection on the camera stream, a drawn zone and
  crossing line, and the zone flow: nothing is decided while the zone is busy;
  when it is free the last crossing decides (A -> B passed, otherwise
  abandoned -> close relay). Relays follow read-then-fire with an online probe
  and a check before every datagram; disarmed by default. Plates are read from
  hi-res stills and stream frames into one consensus.
- test_flow.py: 65 offline checks of the flow, the relay rules against a mock
  board, and the plate reads. No camera, model or relay needed.
- recordings/ + replay_recordings.py: the followed car's boxes for 48 real
  entry visits of 2026-11-21/22, replayed through the judging code.
- trial_report.py: per-visit report of a drive, run on park-lab.

The detector model, local config and outputs are not committed (.gitignore).

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 78b1c99890
commit ce10c741fc
58 changed files with 7642 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Runs on park-lab: each capture mode alone for RUN_S seconds, then restores the two A/B containers.
set -u
cd ~/zone-anpr
RUN_S=${RUN_S:-120}
IMG=git.infra.msai.al/mca/parking_solution/parking-vision:stage-ef2c9f9
E=$(docker inspect zone-anpr-poc --format '{{range .Config.Env}}{{println .}}{{end}}' | grep -E '^CAM_(USER|PASS)=')
python3 - <<'PY'
import json
c = json.load(open("config.json"))
def mk(name, f):
d = json.loads(json.dumps(c)); d["http_port"] = 8093; d["out_dir"] = "out-bench"; d["metrics_s"] = 10
for cam in d["cameras"]: f(cam)
json.dump(d, open(f"config-{name}.json", "w"), indent=2)
mk("main", lambda cam: None)
mk("sub", lambda cam: cam.update(url=cam["url"].replace("/101", "/102")))
mk("mjpeg", lambda cam: cam.update(url=cam["url"].replace("/101", "/102"), mode="mjpeg"))
ip = {"entry": "10.0.10.6", "exit": "10.0.10.7"}
mk("snapshot", lambda cam: cam.update(mode="snapshot", snapshot_url="http://${CAM_USER}:${CAM_PASS}@" + ip[cam["name"]] + "/ISAPI/Streaming/channels/102/picture"))
PY
mkdir -p out-bench && chmod 777 out-bench
docker stop zone-anpr-poc zone-anpr-poc-sub >/dev/null
for m in main sub mjpeg snapshot; do
docker rm -f zb >/dev/null 2>&1
env $E docker run -d --name zb --network host -v $HOME/zone-anpr:/poc -w /poc -e CAM_USER -e CAM_PASS \
--entrypoint /app/.venv/bin/python $IMG -u zone_anpr.py config-$m.json >/dev/null
sleep "$RUN_S"
echo "== $m"
docker logs zb 2>&1 | grep -E "error|stream open|snapshot mode" | head -3
docker logs zb 2>&1 | grep metrics | tail -6 | python3 -c '
import sys, re, statistics as s
L = sys.stdin.read().splitlines()
c = [float(re.search(r"proc ([\d.]+) cores", l).group(1)) for l in L]
r = [int(re.search(r"rss (\d+) MB", l).group(1)) for l in L]
print(f" cores avg {s.mean(c):.2f} (min {min(c)}, max {max(c)}) rss {max(r)} MB")
print(" last:", L[-1][9:])'
done
docker rm -f zb >/dev/null
docker start zone-anpr-poc zone-anpr-poc-sub >/dev/null
echo restored