156 Commits
Author SHA1 Message Date
jetson 1c26f9f95b feat(zones): use native 1080p zones, sync FCP main, and auto-sync default preset 2026-11-17 12:26:30 +07:00
jetson b9d4bd11b3 feat(counting): align max_step_dy (160) and unload_confirm (1) with FCP main 2026-11-17 11:15:35 +07:00
jetson 3cc0919fb1 feat(pipeline,config): sync detection thresholds, filter order, and multi-model tracking with FCP main 2026-11-17 10:19:54 +07:00
jetson ff55a733d6 feat(counting,zones): align corridor filter and default palet zone with FCP main 2026-11-17 09:39:47 +07:00
jetson f15caf8b7f docs: note Python >=3.10 requirement 2026-11-16 16:43:37 +07:00
jetson 08a0e54065 feat(ui): paste/import zone JSON in the calibrator + surface editor in nav 2026-11-12 16:19:16 +07:00
jetson 0fe59abb4a chore: tidy stale 1920x1080 docstrings and drop dead writer 2026-11-12 15:43:08 +07:00
jetson 6610a466ee fix(docs): scope the live-system claims and fix the RTSP instructions 2026-11-12 15:30:13 +07:00
jetson 0e76c096bb docs: zone calibration workflow, counting gates and the 1280x720 zone space 2026-11-12 14:39:17 +07:00
jetson 5c295c5849 feat(tools): record an RTSP stream for recounter/live parity runs 2026-11-12 14:32:05 +07:00
jetson 3ede31b554 fix(ui): harden the frame API and align the OpenCV calibrator 2026-11-12 14:21:12 +07:00
jetson c34ac85643 feat(ui): interactive zone editor over the analysis frame 2026-11-12 13:52:01 +07:00
jetson 8abc103401 fix(viz): draw the calibrated count band instead of the ROI bounds 2026-11-12 13:17:19 +07:00
jetson 6664cefd18 feat(viz): draw the calibrated counting and truck polygons 2026-11-12 13:06:09 +07:00
jetson 7662890cc5 feat(counting): port FCP's ID-switch, corridor and single-count gates 2026-11-12 11:49:40 +07:00
jetson cd596ca857 fix(zones): close the preset-space and file-handling residuals 2026-11-12 11:20:14 +07:00
jetson a0ea7d9f8e fix(zones): validate the preset space and make zone writes race-free 2026-11-12 11:04:44 +07:00
jetson b00701a936 feat(zones): validate, save and reset zone presets (localhost only) 2026-11-12 10:23:29 +07:00
jetson 7b3c5be2a9 feat(zones): ship FCP's calibrations in the 1280x720 analysis space 2026-11-12 09:40:57 +07:00
jetson 957ab0297d feat(zones): ship FCP's calibration in the 1280x720 analysis space 2026-11-12 09:29:33 +07:00
jetson 9cb32e9ec6 docs: correct AGENTS.md conversion description 2026-11-06 14:42:50 +07:00
jetson 2259cdb275 docs: add AGENTS.md for repository onboarding 2026-11-04 12:20:31 +07:00
jetson ad702faccc fix: export TensorRT engine from .pt source, not ONNX 2026-11-04 11:08:09 +07:00
jetson 7a14672b71 ui: improve contrast for convert button and model class badges 2026-11-04 10:56:13 +07:00
jetson bc537984d6 docs: sync README, ERD, changelog with model upload/conversion feature 2026-11-04 10:39:49 +07:00
jetson 1b032edfd3 feat: upload models and convert to .engine from web UI 2026-11-04 10:25:27 +07:00
jetson d3d58ffcde fix: harden the output lifecycle (range requests, temp files, job gate)
Review of the compression branch (ce93c68..d7c1415): one Important and the
cheap real Minors, each with a RED test first.

- app.py: drop the manual Content-Length override - it broke ranged
  requests (206 announcing the full length while sending a slice).
  send_file sets it and the 206/Content-Range itself.
- app.py: the download route serves video extensions only, never the temp
  of an encode in flight.
- src/compress.py: the encode temp is unique per attempt (mkstemp), is
  validated (playable video) and fsynced before it replaces the original;
  a failing os.replace keeps the original and cleans the temp up instead
  of raising into the route. The compressed video keeps the source mode.
- src/compress.py: a stale temp of a killed encode is swept after 2 h
  instead of the 5-day video expiry.
- src/job.py: cancelled and failed jobs are not re-encoded; the job shows
  "Compressing..." while the encode runs.
- ERD.md: the $OUTPUT_DIR/*_compressed.mp4 row is gone.

328 tests pass (was 319).
2026-10-28 15:47:28 +07:00
jetson d7c1415975 docs: changelog, README and plan for the one-video-per-job output lifecycle
CHANGELOG: a finished job leaves one compressed video (compressed in place
under the plain name) and the job videos expire after 5 days.

README: the output lifecycle - one video per job, 5-day retention.

Plan: the implementation plan this branch followed.
2026-10-28 15:13:23 +07:00
jetson 5e2a31792f feat: a finished job leaves one compressed video, expired after 5 days
The annotated output was kept uncompressed forever: a 20-minute clip left
a 724 MB file in output/job-*/, and the download route wrote a second
"_compressed.mp4" next to it (both kept).

Now the job compresses its own output when it finishes: the encode goes to
a temp file, is validated, and replaces the source atomically
(os.replace) under the SAME name. One video per job, the client never sees
a "_compressed" file, and the API's output_path stays valid. A failed
encode or a result that still overshoots the cap leaves the original
untouched, so nothing is ever lost.

The job videos are deleted 5 days after the job (scripts/purge_expired_
outputs.py, cron daily 03:17); the job dir, the thumbnail and the sample
frames stay, so the jobs list still renders.
2026-10-28 15:10:05 +07:00
jetson ce93c68dc2 docs: changelog and plan for the cross-model dedup fix
CHANGELOG: the same-class dedup dropped overlapping sacks (FCP keeps every
tracked detection) - published counts increase, the 20-minute test clip now
reports the same 161 in / 1 out as FCP.

Plan: Task 14 (dedup across models only) and the full-clip cross-check
result (161 / 1 / 160 on both sides).
2026-10-28 12:02:48 +07:00
jetson ac2a2350ad fix: dedup across models only - a same-model overlap is a real sack
The merged pipeline ran a same-class IoU-0.5 dedup over ALL detections,
including the primary model's own tracked detections. FCP keeps every
tracked detection - the detector's own NMS already removed the duplicates
inside a model (predict.py:891). Two sacks stacked on the truck overlap by
more than IoU 0.5, so the recounter dropped one of them and lost its
crossing: 54 detections dropped in 400 frames of the test clip, and 3
fewer sacks than FCP on the 20-minute clip (158 vs 161).

The dedup now compares only detections from DIFFERENT models, and the
tracked primary always wins: an extra carries a synthetic track id, and
swapping the id would lose the track's crossing history.
2026-10-28 11:31:03 +07:00
jetson f43044cc9e test: pin the status page's 'Batches closed' label 2026-10-28 10:50:23 +07:00
jetson b2c0ce0011 docs: label the batch count as closed batches and record the FCP cross-check
The status page showed "Batches: 0" for a clip with an open batch, which
reads like "no batch was counted". The number is the count of FINISHED
batches, so say so.

Plan: record the FCP cross-check that was run on this box (a 60 s excerpt,
model mode C: FCP 6/0/6 vs the recounter 6/0/6 - the same counts) with the
exact commands.
2026-10-28 10:44:28 +07:00
jetson 82896969d6 docs: changelog and plan for the batch-lifecycle parity wave
Plan: add Task 12 (a broken zone calibration degrades instead of publishing
a wrong count) and Task 13 (FCP's batch lifecycle — count every frame, the
FSM's arguments, a real truck signal), update the file structure and the
verification steps, and record the two remaining gaps as out of scope (the
dynamic-mode counting line, the truncated flag in the UI).

CHANGELOG: the batch-lifecycle change (published counts and batch_count can
change for every clip), the zone-calibration hardening and the review-wave
fixes.
2026-10-28 10:04:59 +07:00
jetson 59d8c5521d fix: require the truck to be inside the counting area (FCP predict.py:893-902)
The fixed-mode truck signal accepted any truck in the frame; FCP keeps a
truck only when at least 50% of its bbox overlaps the detection polygon
and uses that as the batch's truck signal (predict.py:964).
2026-10-28 10:02:51 +07:00
jetson 1c313d97d8 fix: match FCP's batch lifecycle (count every frame, predict.py:739-745) 2026-10-28 09:57:26 +07:00
jetson 2ca4cb6c3d fix: degrade a broken zone calibration instead of publishing a wrong count
The whole-branch review found three ways a broken zones.json could reach a
published count:

- build_static_roi indexed the truck_area points directly, so a 1-element
  point (IndexError) or an infinite coordinate (OverflowError) escaped the
  app's guard and became a 500. It now reuses _scaled_points and raises
  ValueError, which the guard already handles.
- A missing or short truck_area fell back to an invented heuristic box that
  was still published as a calibrated "fixed" zone. It now degrades to
  dynamic mode instead.
- A degenerate (zero-area) counting polygon was built successfully and
  filtered out every detection, silently publishing zero counts. It is
  now rejected like any other malformed calibration.

Also: the app guard catches IndexError/KeyError/OverflowError, the zone
preset comment no longer claims 1920x1080 coordinates are authored for
1280x720, and two FCP citations are corrected.
2026-10-28 09:45:25 +07:00
jetson 23ede68f28 docs: changelog for the FCP counting-parity branch and plan corrections
CHANGELOG: the thresholds, cadence, count-line window, batch lifecycle,
fail-fast config and truncation-flag changes, with their consequences for
the published counts. The Task 0 entry now says the annotated output is
1280x720 (an explicit output_height below 720 still downscales it).

Plan: add the Task 11 section (FCP's calibrated count-line x-window),
correct the Task 1 and Task 7 FCP citations, and refresh the file
structure and the verification snippet.
2026-10-28 09:23:19 +07:00
jetson 76b902d318 fix: harden the deferred minors from the parity branch review
- zone_config: a count_line without x_start/x_end/y fell back to the
  frame-space ROI bounds and scaled them a second time (400 -> 266).
- app: _resolve_fcp_mode answers JSON 400 when config.yaml is invalid
  instead of raising through to a Flask 500.
- config: the DEFAULTS fallback (missing/empty config.yaml) is validated
  like a real config, and a test pins DEFAULTS to the shipped config.yaml.
- job: add_job downgrades zone_mode "fixed" to "dynamic" when no calibrated
  ROI was supplied — the label now matches what the job counts against.
- counting: correct the FCP citation (src/counting.py:171).
- tests: the analyze_env stub was missing the new result fields, so every
  /upload job ended in FAILED; cover the truncation fields in both job
  endpoints, /upload/reuse zone mode and the broken-config path.
2026-10-28 09:23:14 +07:00
jetson 8a82b8b866 fix: count inside FCP's calibrated count-line x-window (predict.py:701 parity) 2026-10-28 08:41:08 +07:00
jetson 3d9cce2261 feat: flag truncated clips in the job result 2026-10-27 17:28:02 +07:00
jetson fcafc98b17 feat: fail fast on invalid config (FCP src/validation.py parity) 2026-10-27 17:12:40 +07:00
jetson 4697bda488 fix: correct the FCP batch-reset citation and cover the real on_batch_start contract 2026-10-27 17:05:57 +07:00
jetson 5e4add2238 fix: reset per-track counting state at batch start (FCP predict.py:1020 parity) 2026-10-27 16:40:03 +07:00
jetson f54521c1d8 fix: feed the batch seam the counter's own stream and harden the zone polygon builders 2026-10-27 16:27:28 +07:00
jetson fc94189040 fix: drive batch FSM with real crossing events (FCP predict.py:1064 parity) 2026-10-27 15:50:35 +07:00
jetson acc74dcb62 chore: match FCP truck detection cadence (every 5 frames) 2026-10-27 14:55:52 +07:00
jetson 70acfbb90f chore: align stabilizer max_hold with FCP (10 frames) 2026-10-27 14:54:43 +07:00
jetson 3c354c6d81 chore: align detection thresholds with FCP (sack conf 0.30, box area 1000) 2026-10-27 14:53:23 +07:00
jetson b396b0ded0 docs: move the counting-polygon entry under [Unreleased] 2026-10-27 14:39:42 +07:00