25 KiB
25 KiB
Changelog
All notable changes to this project are documented here. Format follows
Keep a Changelog (dated entries; no
version tags are cut in this repo — main is the release line).
[Unreleased]
Added
- Annotated output filename carries the source clip name (
e963ba0):merged_annotated.mp4->merged_annotated_<source>.mp4(single model:<model>_annotated_<source>.mp4). Client upload name wins; stored file name is the fallback (/upload/reuse). Unsafe chars replaced, stem capped at 80 chars. Download name follows the file (app.pydownload_name=). - Upload models and convert to
.enginefrom the web UI (1b032ed): upload.pt/.onnx/.engineweights through/api/models/upload(aliases/api/model/upload,/api/upload/model,/models/upload,/upload/model); new weights appear in the model groups immediately. A.pt/.onnxsource can be converted to a TensorRT.enginefrom the UI or via/api/models/<stem>/convert(aliases accept the stem in the URL or body); conversion runs in a background thread in two stages (.pt->.onnxvia Ultralyticsexport(format="onnx", imgsz=640), then.pt->.engineviaexport(format="engine", device=0, half=True, imgsz=640); Ultralytics cannot export an engine from an ONNX file, so a sibling.ptis required for the engine stage), with status polling on/api/models/conversions/<id>(list/api/models/conversions, cancel/.../cancel). Known classes are derived from model metadata when the stem is not inKNOWN_MODEL_CLASSESand cached by path/mtime/size. Conversion and analysis are mutually exclusive: an in-flight conversion blocks/uploadand/api/analyze(409), and an active analysis job blocks conversion (409); only one conversion runs at a time. Newsrc/model_conversion.py(ConversionManager,ConversionJob); updatedsrc/model_registry.py(derive_known_classes,_resolve_known_classes,find_truck_detectorvia groups). POST /api/analyzemachine endpoint (540e1b5): multipart video +fcp_modeletter (A–D) or explicitmodel_stems; returns 202{"job_id","status_url"}; 409 busy guard when any job is pending/running (one GPU, atomic check+enqueue under submit lock); optionalX-API-Keyauth iff envRECOUNTER_API_KEYset; all errors JSON. For FCP → recounter clip repush (phase 1 of cross-service recount; FCP sender still TODO, seedocs/ai-handoff-fcp-recount.md).config.yaml → fcp.mode_models: FCP model-mode letter →{stem: engine_classes}, mirroring platformmodels.modes engines[].classesexactly (B/D use v4-best truck-only role, not truck-detector weights).- Network reality (verified 2026-10-20): direct
http://192.168.192.93:9050/api/analyzefrom the FCP host (.96) works (live 202 → COMPLETED). Only ICMP ping .96↔.93 is blocked — never use ping as a health check, use HTTP. A reverse-SSH-tunnel approach was built then fully reverted (e3a905e→cb483c0); direct URL is the sanctioned path. docs/ai-handoff-fcp-recount.md: AI handoff for the FCP-side phase 2.ERD.md(Mermaid ERD) + this changelog (97507f8).- Interactive zone editor at
/calibrate: drag the counting ROI, the truck ROI and the count line over a frame of an uploaded video, then save. Zone writes are localhost-only and atomic (zones.json.bak+ temp file +os.replace). The editor also accepts a pasted JSON preset (Import / Export JSON panel) and can copy or download the active preset as JSON. - Zone write API:
POST /api/zones/<preset>andPOST /api/zones/<preset>/resetvalidate, save and restore a zone preset. tools/record_rtsp.shrecords an RTSP stream to a file, so the live counter and the recounter can be compared on the same footage.
Fixed
- Overlapping sacks of one model were dropped (
ac2a235): the merged pipeline ran a same-class IoU-0.5 dedup over all detections, including the primary model's own tracked ones. FCP keeps every tracked detection — the detector's own NMS already removed 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). Consequence: published counts increase — on the 20-minute test clip the recounter now reports the same 161 in / 1 out as FCP (it reported 158 in / 1 out before). The dedup now compares only detections from different models. - Upload 500 on new video + start analysis:
/uploadreferencedvideo_pathinprobe_video(video_path)before the variable was defined (NameError→ Flask 500). Removed the duplicate premature height-check block; post-saveresize_video_to_max_height()(720p) already covers it (app.py:120-125,b1dd06e). - Single-model class filters silently dropped (
src/job.py): worker looked filters up byModelConfig.filenamewhile UI/API store them bystem—filter_<stem>now honored on single-model jobs (stem-first, filename fallback for legacy callers). tools/calibrate_zone.pynow writes coordinates in the 1280×720 analysis space (the frame is resized before the clicks are taken, so the native video resolution does not matter) and derives the count line the way the live counter does (horizontal at the mean y of its two endpoints).
Changed
- Store
zones.jsonnatively in 1080p (1920×1080), sync with FCPmain(91d8b48), and auto-sync from FCPzones.json:zones.json,DEFAULT_ZONES,/calibrate, andtools/calibrate_zone.pynow author and store presets natively in1920×1080(reference_resolution: [1920, 1080]), and runtime scaling insrc/zone_config.pyusesint(round(v * scale))to match FCPmainpredict.py:762, 781-783at1280×720.- Added
normalize_zone_preset()insrc/zone_config.py(and matching client-side support instatic/calibrate.js) so FCP flatzones.jsonpayloads (palet,truck,counting,line_y/line_x_start/line_x_end,counting_line,coord_space) and legacy1280×720presets normalize cleanly to[1920, 1080]. - Added
sync_fcp_zones()+ sharedresolve_zone()so bothapp.pyandcli.py(--zone-mode,--zone-preset,--zones-path, defaulting tofixedfromzones.json) automatically updatepresets["default"]whenever FCP'szones.jsonis newer. - Updated
presets["default"]to FCPmain(91d8b48:count_liney=215->143at 720p) andfcp-2026-10-15to native1920×1080(count_liney=330->220at 720p).
- Sync detection thresholds, filter ordering, and multi-model tracking with FCP
main(91d8b48):detection.sack_conf0.30 → 0.35, plus per-class ByteTrack NMS thresholdsiou.sack_nms(0.45) andiou.box_nms(0.7) matching FCPconfig.yaml:103-116.- Pre-stabilizer
confandmin_bbox_areafiltering (_filter_raw_detections) now runs beforeBboxStabilizerso held occlusions do not drop due to0.85xconfidence decay and sub-threshold boxes cannot suppress valid sacks; cross-class suppression (_suppress_sacks_under_boxes) now usesiou < threshold(>=drop parity) and runs after polygon/ROI filtering. truck_detection_centroidselects the largest-area valid truck instead of first match.run_merged_pipelinenow selects the first engine coveringsackfor primaryByteTrackTracker(fixing FCP Modes B/D wherev4-bestis truck-only) and runs a dedicated per-frameboxByteTrackTracker+BboxStabilizerwhen a separate engine coversbox(fixing FCP Modes C/D).
- Align corridor filter and default palet zone with FCP main (
91d8b48): the corridor filter insrc/counting.pynow keeps_initial_zonewhen a detection sits deep in the truck bed (matching FCPmain), whilecounting.max_step_dy_px(120→160) andcounting.unload_confirm_frames(3→1) now match FCPmain'sCountingConfig(src/config_loader.py:104-107). Recalibratedpresets.default.paletinzones.jsonandDEFAULT_ZONESto[[408, 1], [893, 1], [893, 178], [405, 178]](scaled from FCP's 1920×1080[[612, 1], [1340, 1], [1340, 267], [608, 267]]).fcp-2026-10-15stays unchanged. zones.jsonnow 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(thefeat/interactive-roi-linebranch's95c031brecalibration, count line y=182 — the active preset) andfcp-2026-10-15(the pre-recalibration geometry, count line y=220), which is what the deployed live counter (commit7beb820) counts with today, because itspredict.pyhardcodes the line at y=220 in 1280×720 and does not readzones.json. Thefeat/interactive-roi-linebranch (HEAD95c031b) does readzones.json, so once it is deployeddefaultis 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, atomic), so there is no second_compressed.mp4next to it, the client never sees the suffix, and the API'soutput_pathstays valid. Only files over the 250 MB cap are compressed; a failed encode or a result that still overshoots the cap leaves the original untouched, so no video is ever lost. A 724 MB annotated video becomes 218 MB. The job videos are deleted 5 days after the job (scripts/purge_expired_outputs.py, cron daily 03:17); the job directory, the thumbnail and the sample frames stay, so the jobs list still renders. - Output lifecycle hardening (review of
5e2a317): the download route no longer overridesContent-Length(it broke ranged requests — a 206 with a full-length body length), soRangedownloads work again; the encode temp is now unique per attempt and is validated (playable video, fsynced) before it replaces the original, and a failingos.replacekeeps the original and cleans up instead of 500-ing the download; the route serves video extensions only (never the temp of an encode in flight); a stale temp of a killed encode is swept after 2 h instead of 5 days; cancelled and failed jobs are not re-encoded; the job shows "Compressing…" while it runs. - Batch lifecycle now matches FCP's (
1c313d9,59d8c55): the line counter is fed on every frame (FCPpredict.py:1066-1067— it used to run only while a batch was open, so crossings before the batch opened were never counted), the batch FSM is built with FCP's arguments (predict.py:739-745: stabilize 0 s, threshold disabled, idle timeout 20 s, min duration 5 s, truck-gone tolerance 30 s), and the truck model now runs in fixed-zone mode too (predict.py:882) so the batch's truck signal is a real detection inside the counting area (predict.py:893-902) instead of the static zone's constant confidence. Consequence: published counts can change for every clip — crossings before the first batch opens now count, andbatch_countreflects the real truck sessions instead of always being0in fixed-zone mode. - A broken zone calibration degrades instead of publishing a wrong count
(
2ca4cb6): atruck_areawith a malformed point, a missing or shorttruck_area, or a degenerate (zero-area) counting polygon now drops the job back to dynamic mode instead of raising a 500, inventing a heuristic ROI, or filtering every detection away (which reported zero sacks). - Review-wave hardening (
76b902d): acount_linewithoutx_start/x_end/yno longer scales the fallback twice (the counting window moved to266...624instead of400...936); a brokenconfig.yamlanswers JSON 400 onPOST /api/analyzeinstead of a 500 HTML page; a job created withzone_mode=fixedbut no calibrated ROI is labelleddynamic, because that is what it counts against. - FCP detection thresholds and cadence (
3c354c6,70acfbb,acc74dc):detection.sack_conf0.40 → 0.30,min_bbox_area.box1500 → 1000 (FCPconfig.yaml:83-93),stabilizer.max_hold25 → 10 (FCPpredict.py:668),pipeline.truck_det_interval15 → 5 (FCPpredict.py:882). The truck ROI now refreshes 3× faster, so a batch opens and closes sooner. Consequence: published counts can change for every clip — the sac confidence gate is looser, the box area threshold is lower, and the occlusion hold is shorter (a sack hidden for more than 10 frames can be lost). - Counting happens inside FCP's calibrated count-line x-window (
8a82b8b): the counter now uses the calibratedcount_linex-range fromzones.json(384...934in the 1280x720 analysis frame, FCPpredict.py:701-703) instead of the truck-ROI bounds (400...936). The ROI x-filter (400...936, FCPpredict.py:541-548) still applies, so the effective window is400...934on both sides. Consequence: in fixed-zone mode a crossing whose bbox centre falls in(934, 936]no longer counts. - Batch lifecycle driven by real crossings (
fc94189): the batch FSM now receives the real crossing events and the real sack-in-truck-area count (FCPpredict.py:1064-1085) instead of a hardcoded "no crossing" flag, so the idle timeout and the per-batch counts follow the sacks. Per-track counting state is cleared at every batch start while the clip totals are kept (5e4add2) — FCP clears its counter after finalising a batch row (predict.py:1139-1150); the recounter clears at batch start because it reports one cumulative count per clip. Consequence: the per-batch counts in the job result can change. - Invalid configuration now fails fast (
fcafc98): a brokenconfig.yamlraises instead of silently falling back to the built-in defaults (a missing file still falls back). Detection confidences must be in(0, 1], IoU thresholds in(0, 1], minimum bbox areas>= 0; the offending key and value are named in the error. A job whose config is broken fails with that message instead of counting with the wrong thresholds. - Truncated clips are flagged (
3d9cce2): a clip whose decoded frame count is more than 2 % below the container's frame count is reported astruncated: true(withframes_expected) in the job result and inGET /api/jobs/GET /api/jobs/<id>. The counts are still reported — they cover the frames that were decoded. A cancelled job also reportstruncated: true(the decoder stopped early). - Counts limited to the calibrated counting polygon (
d74ca41): a detection is counted only when its bbox centre lies inside the calibratedcounting_area(FCP'sdetection_polygonfilter,predict.py:939-942). The polygon is FCP'sdetection_poly_ptsscaled to the 1280x720 analysis frame (predict.py:688-698). Consequence: published counts can change for every clip — detections outside the calibrated detection area no longer count. - Default counting zone is now the calibrated static zone (
f4e7b5d):zone_modedefaults to"fixed"(thezones.jsoncalibration, built in the 1280x720 analysis frame) instead of"dynamic", where the count line was derived from the detected truck bbox — a moving line. FCP always counts against its calibrated line (predict.py:715-724,:1037,:1066). Consequence: published counts change for every clip analysed without an explicitzone_mode(e.g.POST /api/analyze) — the count line no longer follows the truck; the web form already sentzone_mode=fixed."dynamic"stays available as an explicit opt-in, and a deployment with no usable calibration on disk (missing or corruptzones.json) falls back to"dynamic"automatically. - Analysis frame pinned to 1280x720, model input pinned to 640x640
(
fcdfed1): every decoded frame is resized to 1280x720 before detection (FCPpredict.py:826) and both models run with an explicitimgsz=640(FCPpredict.py:467). The annotated output is written at 1280x720 (an explicitoutput_heightbelow 720 still downscales it). The static zone ROI is built in the 1280x720 frame (build_static_roi(zone, *ANALYSIS_SIZE)), so the count line (y=220) and the ROI x-window (400...936) match FCP's for every clip. Consequence: clips whose native resolution is not 1280x720 now publish FCP's geometry; 1280x720 clips are unaffected.output_heightabove 720 is now inert — the frame is fixed at 720p. - Counting/tracking params mirrored from platform (
karung_counter_semarang):stabilizer.max_hold_frames10 → 25 (~1 s occlusion hold),cfg/tracker.yamltrack_buffer60 → 90 (~3.6 s lost-track hold),ByteTrackTrackergainediou=0.7passed tomodel.track().src/stabilizer.py,src/tracking.py,cfg/tracker.yamlnow byte-identical to the platform (37e2d3e). - Auto-resize uploads to 720p, 720p default output — only transcoded when
source is taller than 720p; default output height option set to 720p
(
89a265c). - Counting gates ported from the live counter's
feat/interactive-roi-linebranch: 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 consecutive frames above the line. Newcounting:keys inconfig.yaml(capture_below_px,max_step_dy_px,max_gap_frames,unload_confirm_frames). unloadingis 0 on every batch andnetequals the gross count. The unload branch is unreachable by design (parity with the deployed live counter, which runs the same gates —7beb820contains the gates commit8448dcb): 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 deployed live counter publishesunloading = 0on every batch. Unloadings are not counted.- The annotated output draws the calibrated counting and truck polygons instead of a plain bounding box.
Added
- Plan doc for fixed-zone mode (
.opencode/plans/fixed-zone-mode.md).
2026-10-14 — Platform parity wave
Added
- Re-attach orphaned output dirs after restart (
d09800c): jobs are in-memory;JobQueue._register_orphans()now re-attachesoutput/job-*older than 300 s as synthetic COMPLETED jobs so they stay deletable from the UI. Younger dirs skipped (may belong to a live process). config.yamlas single source of truth for tunables (7230e2b): detection,min_bbox_area,iou, roi, stabilizer, pipeline blocks; code reads config instead of scattered constants.- Start/stop/restart dashboard scripts (
d89c985):start_dashboard.sh,stop_dashboard.sh,restart_dashboard.sh.
Fixed
min_bbox_areascaled from platform's 1280x720 reference to actual frame size (c2d720e) — hardcoded pixel area mis-scaled at other resolutions. No longer scaled: the analysis frame is pinned to 1280x720 (fcdfed1), so the values are literal px² in that frame.- "Waiting for first frame" placeholder hidden once MJPEG delivers the
first frame (
2efcdb2).
Changed
- Platform detection parity + progress bars (
ce604b0): detection behaviour matched to reference repo; download and processing progress bars on the UI. - Async writer thread + MJPEG mtime guard (
92fd4cb): video encode off the pipeline thread; preview stream only re-sends when file mtime changes.
2026-09-30 — Accuracy defaults
Fixed
- Restored accuracy defaults:
detect_interval=1,sup_det_interval=5(31bfe7c) — earlier throttling to every 2nd/10th frame had cost counts.
2026-09-29 — Fixed ROI + live box counts
Added
- Fixed ROI zone mode as default selection (
f2b5644). - Live box counts + separate sack/box nets on status page (
81e6ae6). - Freeze ROI mode with deadband+sticky jitter fix and explicit
fixed/frozen ROI flags (
4bd9de5). - Stabilize secondary-model detections + box-wins suppression; web UI
moved to port 9050 (
ad41bf0).
Changed
- Tracker throttled to every 2nd frame, supplementary detector interval 10,
720p output option (
07289a4). (Later partially rolled back by31bfe7cfor accuracy.)
2026-09-28 — Counting correctness + downloads
Fixed
- Exclude
truckclass from counting; switch toMultiClassLineCounterwith real class labels (d383759) — trucks were inflating sack counts. - Consistent
Sack In/Sack Outlabels across live panel and result cards (1dbfeca). - Atomic compression writes, enforce 250 MB size limit, job status guard
(
f878110) — no more truncated_compressed.mp4on kill. - Isolate tests from the real
output/dir via conftest autouse fixture (9a276b2).
Added
- Compress downloads to max 250 MB via ffmpeg with mtime-based cache
(
6f86bca). - Propagate sack vs box counts to results and UI (
7932119).
2026-09-22 — Zones, merged pipeline, live preview
Added
- Interactive zone calibration tool (
859d6a0). - Zone config loader + static ROI builder (
4ad4284),zone_mode/fixed_zonefields onJob(7c91081), preset dropdown in the web UI (f0ea95d), visual distinction for fixed zone vs dynamic ROI (2b46231). - Merged detection output + parallel model execution (
fc20a52). - Live preview toggle, FPS indicator, live counting by object
(
09a8829). - Live preview switched from WebSocket to MJPEG streaming (
a5566f3) and 15+ FPS push groundwork (f9e411f).
Fixed
- Use tracker for counting + throttle supplementary detectors
(
5bf44d6) — detections without track IDs never reached the counter. - Absolute
OUTPUT_DIR, resolution scaling for zones, full reference-repo values (35cccd0). - Toggle preview display bug, job deletion, pipeline optimizations
(
1632800). - Show live preview img by default (was
display:nonefrom SocketIO era) (b6379e1).
Changed
- Docs: README updated with current features and API (
39b582a).
2026-09-21 — Job UX + resource management
Added
- Video reuse: re-analyze previous uploads without re-uploading
(
f779f05), delete button for uploaded videos (d353272). - Abort button for job cancellation (
6783ff3). - Video upload
requiredattr removed when an existing video is selected (42c80fd).
Fixed
- Explicit GPU memory cleanup between models to prevent OOM
(
93daa68). - Pass truck centroid to batch manager for state transitions
(
1e28eb4). - Auto-use truck-detector when model lacks
truckclass (57afb62). - Pin
numpy<2.0to resolve Jetson torch incompatibility (a75db4c).
2026-09-18 — Grouped models + TensorRT
Added
ModelGroup+scan_model_groups()for grouped model display (22c7842), grouped selection in JS (d07b3ba), grouped Flask routes (dbd79ed).- TensorRT engine export script (
d32045b).
Fixed
- Graceful error when
onnxruntimeis missing for.onnxmodels (06b013a). - Removed duplicate
v4-best (1).pt(1bc5e06). - Status page: flat progress bar,
created_atformatting (47ffede); dynamicaria-valuenow, focus-visible styles (7b19b5b).
UI wave (2026-09-17 → 09-18)
- Design system foundation, CSS tokens, base template (
fbcff78,c17d480). - Upload page: drag-drop, video preview, model cards (
f245e94); double-toggle bug + hardcoded colors (197c505). - Status page: progress bar, live preview, result cards, polling (
1c54bb1); null safety + connection-lost handling (6323583,1d35c28). - Jobs page: card grid with badges/thumbnails (
b1170f4), semantic cards + flat progress bar (20d5234), accessibility/responsive polish (441a6a8). - Video preview endpoints: thumbnail, sample frames, live frame (
dca6f6b). - Pipeline emits live annotated frames for preview (
f487b5c); clearslatest_frameon failure (87c8da3).
2026-09-16 — Initial working release
Added
- Flask web UI on port 9000 with upload, job status, APIs (
eb77e5b). - CLI entry point:
--video,--model,--filter,--list-models(f38c970). - Async job queue — thread-safe add/get/cancel/list (
e13926d). - Pipeline runner processing video through the counting pipeline
(
5a04cc5); annotated video writer wrapping OpenCV (61c9868). - Model registry scanning
models/with known-class map (f5982a4). - Core pipeline modules copied from
karung_counter_semarang(71c1ae1). - Integration tests for Flask routes (
05bdac5); complete README with usage, CLI, API reference (1377fbb).
Fixed
- Secure upload/download paths, default filter, status enum compare, upload
validation (
40e2dbe). - Final review wave: CLI kwargs, class filter, job locks, upload order
(
2b54cc3). - Relax racy
PENDINGassertion intest_queue_add_job(f14f3b5).
2026-09-15 — Project init
- Project structure and skeleton with
pyproject.toml,config.yaml,cfg/tracker.yaml, README (43a959d,927c84d,7fb0174).