--- type: concept tags: [parking, vision, anpr, passage, night, glare, hardening, poc, park-lab] sources: [] updated: 2026-11-23 --- # 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. - **Again on 2026-11-23 (user):** bad weather during the staff's morning traffic; the cameras are outdoors and the weather cannot be fixed ([[zone-anpr-poc]], "Staff traffic"). ## 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. - By day too (2026-11-23, 09:01 UTC, exit camera): a box 824 px wide and 703 of 720 px high over the grey mass in front of the lens, with a car's rear at its edge. It touches the left edge only, so the both-edges rule would not catch it. 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. **Added 2026-11-23:** the camera's on-screen label is read as a plate. The entry camera prints "Hyrje" into the picture, bottom right, where a car's bumper stands when it is at the line. The plate reader takes it for a plate (`HUIJE`), in video frames and in stills, and on 2026-11-23 one still was sure enough to vote ([[zone-anpr-poc]], "H.264 instead of MJPEG"). **To try:** take the label and the clock out of the picture in the camera's settings, or keep a plate box that falls on a printed overlay from voting. - **Done by the user (2026-11-23):** the labels "Hyrje" and "Dalje" now sit in the top-right corner of both cameras' pictures, in the video and in the hi-res still, away from the zone and from where a car stands. A tall vehicle reached it the same morning: an off-roader's box rose to y = 37 of 720 with the label inside it (08:53 UTC). The label was not read then, nor in any other of the staff's eight visits. That is one vehicle, so the overlay check stays on the list. ## 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 is stopped since the evening of 2026-11-22** (user: the barrier is operated only with the staff's remote control until the system is ready to control it). `docker start zg2` brings it back with `close_live` and `close_on_lost` on, and the relays disarmed. Do not start it during business hours without the user's word. Earlier versions are kept beside it as `zone_anpr.py.bak-20261122-*`. - **Since 2026-11-23** the `zone_anpr.py` on park-lab also has the live picture of the H.264 test ([[zone-anpr-poc]]); the version before it is `zone_anpr.py.bak-20261123-prelive`. The test runs as container `zg-h264`, which has no relay board configured, on the same port 8094, so `zg2` and `zg-h264` cannot run together. The user left `zg-h264` running on 2026-11-23 (harmless: no relay armed or configured). - **Records there:** `out/visits.jsonl`, `out/relays.jsonl`, `out/reads.jsonl`, `out/reads-all.jsonl`, and per visit `out/clips/_/` 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).