forked from andrew/feedmill-recounter
fix(docs): scope the live-system claims and fix the RTSP instructions
This commit is contained in:
1 parent
0e76c096bb
commit
6610a466ee
3 files changed
+79
-50
No files matched your search
@@ -19,6 +19,9 @@ Feedmill Recounter: AI video analysis for counting sacks/boxes in feedmill video
|
||||
- `src/zone_config.py`: loads, validates and atomically saves the zone presets (`.bak` + temp file + `os.replace`).
|
||||
- `src/counting.py`: `LineCrossCounter` — the FCP counting gates (single count, corridor, ID switch, unload confirm).
|
||||
- Zone editor: `GET /calibrate` (`templates/calibrate.html`, `static/calibrate.js`); writes go through `POST /api/zones/<preset>` and `POST /api/zones/<preset>/reset` (localhost only).
|
||||
- Zone writes go through `POST /api/zones/<preset>` (localhost-only, validated, atomic). Do not hand-edit `zones.json` while the web app runs — the editor merges over the stored preset.
|
||||
- The counting gates live in `config.yaml` under `counting:` and are ported from the live counter's `feat/interactive-roi-line` branch.
|
||||
- `tools/calibrate_zone.py` and the `/calibrate` page produce the same geometry; keep their count-line derivation in sync (`x_start=min`, `x_end=max`, `y=round(mean(ys))`).
|
||||
- Config: `config.yaml` (tunables), `zones.json` (fixed zones, 1280x720 analysis space), `.env` (paths/secrets).
|
||||
|
||||
## Quirks
|
||||
@@ -30,7 +33,7 @@ Feedmill Recounter: AI video analysis for counting sacks/boxes in feedmill video
|
||||
- Conversion to `.engine` must start from `.pt`; Ultralytics cannot export from ONNX.
|
||||
- `.engine` conversion may take minutes on Jetson.
|
||||
- Zones live in `zones.json` in the **1280x720 analysis space**; `reference_resolution` is `[1280, 720]`, so the scale factor is 1.0. Never introduce a second coordinate space (the editor maps client -> source in the same 1280x720 space).
|
||||
- Two presets ship: `default` (the live counter's `95c031b` recalibration, count line y=182 — the active preset) and `fcp-2026-10-15` (pre-recalibration, count line y=220 — matches what the deployed live counter counts with today, because its `predict.py` hardcodes the line).
|
||||
- The unload branch in `src/counting.py` is unreachable by design (parity with the live system): `unloading` is always 0 and `net` equals the gross count. Do not "fix" it into a counted unload.
|
||||
- Two presets ship: `default` (the `feat/interactive-roi-line` branch's `95c031b` recalibration, count line y=182 — the active preset) and `fcp-2026-10-15` (pre-recalibration, count line y=220 — matches what the deployed live counter (commit `7beb820`) counts with today, because its `predict.py` hardcodes the line at y=220 and does not read `zones.json`).
|
||||
- The unload branch in `src/counting.py` is unreachable by design (parity with the deployed live counter, which runs the same gates — `7beb820` contains the gates commit `8448dcb`): `unloading` is always 0 and `net` equals the gross count. Do not "fix" it into a counted unload.
|
||||
- Zone writes are localhost-only; remote operators use an SSH tunnel (`ssh -L 9050:127.0.0.1:9050 jetson@<host>`).
|
||||
- `tools/record_rtsp.sh` records an RTSP stream to a file for live-vs-recounter parity runs; the recounter stays file-based (no RTSP input path).
|
||||
+16
-12
@@ -83,6 +83,17 @@ version tags are cut in this repo — `main` is the release line).
|
||||
counter does (horizontal at the mean y of its two endpoints).
|
||||
|
||||
### Changed
|
||||
- **`zones.json` now carries the calibration in the 1280×720 analysis space**
|
||||
(`reference_resolution: [1280, 720]`, scale factor 1.0), matching the live
|
||||
counter's geometry. Two presets ship: `default` (the
|
||||
`feat/interactive-roi-line` branch's `95c031b` recalibration, count line
|
||||
y=182 — the active preset) and `fcp-2026-10-15` (the pre-recalibration
|
||||
geometry, count line y=220), which is what the deployed live counter (commit
|
||||
`7beb820`) counts with today, because its `predict.py` hardcodes the line at
|
||||
y=220 in 1280×720 and does not read `zones.json`. The
|
||||
`feat/interactive-roi-line` branch (HEAD `95c031b`) does read `zones.json`,
|
||||
so once it is deployed `default` is the matching preset. **Published counts
|
||||
change**: the previous preset was a 1920×1080 approximation.
|
||||
- **A finished job leaves ONE compressed video** (`5e2a317`): the annotated
|
||||
output is compressed in place when the job finishes — the compressed copy
|
||||
replaces the uncompressed source under the same file name (`os.replace`,
|
||||
@@ -203,14 +214,6 @@ version tags are cut in this repo — `main` is the release line).
|
||||
- **Auto-resize uploads to 720p, 720p default output** — only transcoded when
|
||||
source is taller than 720p; default output height option set to 720p
|
||||
(`89a265c`).
|
||||
- **`zones.json` now carries the calibration in the 1280×720 analysis space**
|
||||
(`reference_resolution: [1280, 720]`, scale factor 1.0), matching the live
|
||||
counter's geometry. Two presets ship: `default` (the live counter's
|
||||
`95c031b` recalibration, count line y=182 — the active preset) and
|
||||
`fcp-2026-10-15` (the pre-recalibration geometry, count line y=220), which is
|
||||
what the deployed live counter counts with today, because its `predict.py`
|
||||
still hardcodes the line and does not read `zones.json`. **Published counts
|
||||
change**: the previous preset was a 1920×1080 approximation.
|
||||
- **Counting gates ported from the live counter's `feat/interactive-roi-line`
|
||||
branch**: a track counts at most once, a sack deep in the truck bed never
|
||||
counts, an ID switch drops the track's history, an unload needs three
|
||||
@@ -218,11 +221,12 @@ version tags are cut in this repo — `main` is the release line).
|
||||
(`capture_below_px`, `max_step_dy_px`, `max_gap_frames`,
|
||||
`unload_confirm_frames`).
|
||||
- **`unloading` is 0 on every batch and `net` equals the gross count.** The
|
||||
unload branch is unreachable by design (parity with the live system): the
|
||||
gates were ported literally, including the live counter's own unreachable
|
||||
unload branch is unreachable by design (parity with the deployed live counter,
|
||||
which runs the same gates — `7beb820` contains the gates commit `8448dcb`):
|
||||
the gates were ported literally, including the live counter's own unreachable
|
||||
unload branch — a track that already counted as a loading can never count a
|
||||
second time — and the live system publishes `unloading = 0` on every batch.
|
||||
Unloadings are not counted.
|
||||
second time — and the deployed live counter publishes `unloading = 0` on
|
||||
every batch. Unloadings are not counted.
|
||||
- The annotated output draws the calibrated counting and truck polygons
|
||||
instead of a plain bounding box.
|
||||
|
||||
|
||||
@@ -37,6 +37,33 @@ recounter-web
|
||||
# Open http://localhost:9050
|
||||
```
|
||||
|
||||
### Comparing with the live system (RTSP)
|
||||
|
||||
The recounter analyses files. The live counter streams over RTSP, so compare
|
||||
both on the **same** footage by recording the stream first:
|
||||
|
||||
```bash
|
||||
tools/record_rtsp.sh rtsp://CAMERA/stream /tmp/opencode/compare.ts 300
|
||||
```
|
||||
|
||||
Analyse the recording with the CLI — it takes any file OpenCV can open,
|
||||
including `.ts`:
|
||||
|
||||
```bash
|
||||
recounter --video /tmp/opencode/compare.ts --model v4-best.pt --filter sack --output-dir ./output
|
||||
```
|
||||
|
||||
The web upload only accepts `.mp4`, `.avi`, `.mkv`, `.mov` and `.webm`, so
|
||||
remux the recording first if you want to use the web UI:
|
||||
|
||||
```bash
|
||||
ffmpeg -i /tmp/opencode/compare.ts -c copy /tmp/opencode/compare.mp4
|
||||
```
|
||||
|
||||
Point the live system's source at the same file. A live RTSP run and a
|
||||
recorded-file run can still differ in frame timing, so compare files, not a
|
||||
live run against a file.
|
||||
|
||||
## CLI Reference
|
||||
|
||||
```
|
||||
@@ -117,6 +144,23 @@ recounter --video PATH Input video file
|
||||
|
||||
Edit `config.yaml` instead of the code for these values; restart the job / re-run the CLI to apply.
|
||||
|
||||
`config.yaml` carries the counting gates ported from the live counter's
|
||||
`feat/interactive-roi-line` branch, under `counting:`:
|
||||
|
||||
- `capture_below_px` (100) — corridor below the line: a sack deep in the truck
|
||||
bed never counts.
|
||||
- `max_step_dy_px` (120) — a per-step vertical jump of this size is an ID
|
||||
switch: the track's history resets.
|
||||
- `max_gap_frames` (15) — frames a track may vanish before its history resets.
|
||||
- `unload_confirm_frames` (3) — consecutive "above" frames needed to confirm
|
||||
an unload.
|
||||
|
||||
A track counts at most once. The unload branch is unreachable by design
|
||||
(parity with the deployed live counter, which runs the same gates — commit
|
||||
`7beb820` contains the gates commit `8448dcb`): a track that already
|
||||
counted as a loading can never count a second time. `unloading` is therefore
|
||||
always 0 and `net` equals the gross count — unloadings are not counted.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
@@ -190,12 +234,16 @@ Open `http://<host>:9050/calibrate`:
|
||||
|
||||
Two presets ship:
|
||||
|
||||
- `default` — the live counter's `95c031b` recalibration (count line y=182).
|
||||
It is the active preset (`active_preset`).
|
||||
- `default` — the `feat/interactive-roi-line` branch's `95c031b` recalibration
|
||||
(count line y=182). It is the active preset (`active_preset`).
|
||||
- `fcp-2026-10-15` — the pre-recalibration geometry (count line y=220). The
|
||||
deployed live counter counts with this geometry today: its `predict.py`
|
||||
hardcodes the line and never reads `zones.json`. Pick this preset to
|
||||
reproduce today's live numbers.
|
||||
deployed live counter (commit `7beb820`) counts with this geometry today: its
|
||||
`predict.py` hardcodes the line (`static_line_y = int(330 * scale_y)`, i.e.
|
||||
y=220 in 1280×720) and does not read `zones.json`. Pick this preset to
|
||||
reproduce today's live numbers. Once the `feat/interactive-roi-line` branch is
|
||||
deployed, `default` is the matching preset, because that branch does read
|
||||
`zones.json`. The deploy script does not copy `zones.json`, so carry it by
|
||||
hand when deploying the branch, or the box keeps the old geometry.
|
||||
|
||||
The write API (`POST /api/zones/<preset>`, `POST /api/zones/<preset>/reset`) is
|
||||
**localhost-only**. From another machine, tunnel the port over SSH:
|
||||
@@ -204,37 +252,11 @@ The write API (`POST /api/zones/<preset>`, `POST /api/zones/<preset>/reset`) is
|
||||
ssh -L 9050:127.0.0.1:9050 jetson@<host>
|
||||
```
|
||||
|
||||
then open `http://127.0.0.1:9050/calibrate` locally.
|
||||
|
||||
Writes are atomic: the previous file is copied to `zones.json.bak`, the new
|
||||
one is written to a temp file, and the temp file replaces `zones.json`.
|
||||
|
||||
### Counting gates
|
||||
|
||||
`config.yaml` carries the counting gates ported from the live counter's
|
||||
`feat/interactive-roi-line` branch, under `counting:`:
|
||||
|
||||
- `capture_below_px` (100) — corridor below the line: a sack deep in the truck
|
||||
bed never counts.
|
||||
- `max_step_dy_px` (120) — a per-step vertical jump of this size is an ID
|
||||
switch: the track's history resets.
|
||||
- `max_gap_frames` (15) — frames a track may vanish before its history resets.
|
||||
- `unload_confirm_frames` (3) — consecutive "above" frames needed to confirm
|
||||
an unload.
|
||||
|
||||
A track counts at most once. The unload branch is unreachable by design
|
||||
(parity with the live system, which runs the same gates): a track that already
|
||||
counted as a loading can never count a second time. `unloading` is therefore
|
||||
always 0 and `net` equals the gross count — unloadings are not counted.
|
||||
|
||||
## Comparing with the live system (RTSP)
|
||||
|
||||
The recounter analyses files. The live counter streams over RTSP, so compare
|
||||
both on the **same** footage by recording the stream first:
|
||||
|
||||
```bash
|
||||
tools/record_rtsp.sh rtsp://CAMERA/stream /tmp/opencode/compare.ts 300
|
||||
```
|
||||
|
||||
Upload `compare.ts` to the recounter and point the live system's source at the
|
||||
same file. A live RTSP run and a recorded-file run can still differ in frame
|
||||
timing (the live system samples every second frame), so compare files, not a
|
||||
live run against a file.
|
||||
Zone changes apply to the **next** analysis; a running job keeps the zone it
|
||||
started with. `tools/calibrate_zone.py` does the same job in an OpenCV window
|
||||
on the box itself.
|
||||
Reference in new issue
Block a user