ERD: no DB in this repo — models in-memory Job/JobResult entities plus
filesystem artifacts (uploads/, output/job-*/, zones.json, models/),
with status state machine and restart/orphan hazards.
CHANGELOG: Keep a Changelog format covering all 83 commits grouped by
date, from 2026-09-15 init through the /upload NameError 500 fix.
Previously, app.py:123-125 tried to use and
before was defined.
This caused NameError and 500 Internal Server Error when users uploaded
new videos and pressed 'start analysis'.
The code block (lines 122-125) was duplicate logic - the later transcoding
at line 138 already handles the height check.
Fixes: # (Issue reference not provided)
- src/preview.py: added resize_video_to_max_height() using ffmpeg
(tries nvenc/v4l2m2m then libx264, atomic overwrite, only if >720p)
- app.py upload: transcode to 720p immediately after save
- app.py upload_reuse: probe first, only transcode if height > 720p
- templates/index.html: 720p output checkbox checked by default
- zones already scale correctly via build_static_roi (reference 1920x1080 -> 720p)
- 177 tests pass
Jobs are in-memory; output/job-* dirs survived restarts but never
appeared in /jobs, leaving 5.2GB undeletable. JobQueue now registers
stale job-* dirs (>5min old) as COMPLETED ghosts so the existing delete
flow rmtree's them. register_orphans=False opt-out. 177 tests pass (+3).
Platform force-resizes frames to 1280x720 before detection, so its
1500/5000 px2 thresholds are authored in that space. Applying them raw
at native 1080p made recounter's effective bar 2.25x weaker — false
divergence in double-check runs. _scaled_min_areas scales by frame area
(1080p: 3375/11250, 720p: unchanged).
Platform's get_min_valid_area perspective gate is dead code (zero call
sites) — deliberately not ported, it would make recounter stricter than
platform. 174 tests pass (+1).
- _AsyncWriter: encode+draw overlap GPU inference (queue maxsize=2
backpressure, order-preserving, first error surfaced at close, never
masks original exception) — ~15-35% higher end-to-end FPS
- MJPEG endpoint yields only on preview mtime change instead of re-sending
the same JPEG every 50ms
- 173 tests pass (+5)
No load handler existed — placeholder overlay (absolute inset:0) stayed
on top of the live stream forever. Hide on img load; toggle OFF already
re-shows it.
Throttled tracking caused ByteTrack ID switches at crossings -> counter
re-initializes new tracks without counting -> lost In counts; sup=10 put
box holds one detection-miss from expiry. Defaults back to every-frame
tracking; params kept for opt-in throttling. 720p/preview gains kept.
- index.html: checked moves from dynamic to fixed radio; preset config
visible on load (was only added on change event)
- app.js: when no zone presets exist, fall back to dynamic radio + hide
preset config (server already falls back to dynamic)
- SyntheticIdAssigner: track_id=None dets get stable negative IDs so the
stabilizer hold bridges sup_det_interval gaps -> no flicker, boxes count
- apply primary model class filter in merged path (UI checkboxes work)
- _suppress_sacks_under_boxes: sack dets overlapping box dets dropped
(models without box class label boxes as sack; stops double counting)
- default web port 9000 -> 9050 (WEB_PORT env still overrides)
- README: port refs, counting zone modes section, project tree
- 140 tests pass (+13)
Tests imported the global job_queue (bound to real OUTPUT_DIR), creating
8 junk job-* dirs per pytest run (test_app x3, test_download_compress x4,
test_preview x1). Fixture redirects _output_dir to tmp_path and clears
the job registry before each test.
- Primary model uses ByteTrackTracker.update() every frame (gives track_ids)
- Supplementary models run every 5th frame only (reduces GPU load N->1)
- Counter only receives detections with track_id (fixes zero counts)
- Dashboard draws all detections (tracker + supplementary merged)
- Multiple models run simultaneously on each frame via ThreadPoolExecutor
- Detections merged with IoU deduplication (same class, high overlap → keep highest conf)
- Single merged_annotated.mp4 output (not per-model videos)
- Single model still uses existing run_pipeline for backward compat
- Active jobs banner on upload page (polls every 5s)
- GPU warning when selecting 3+ models
- 62/62 tests pass
- Added live preview (MJPEG), auto truck detection, video reuse/delete
- Added abort button, model groups with format dropdown
- Updated API endpoints table with all current routes
- Added configuration section with env variables
- Added model formats and truck detection sections
- Updated project structure with preview.py
The legacy batch_mgr.update() method was calling update_truck() with
truck_centroid=None, which prevented the batch from transitioning
from IDLE to TRUCK_STABILIZING (centroid must be non-None).
Now pipeline computes centroid from ROI and passes it through.
Verified: old run had 0 cyan pixels (no tracking), new run has 28190
cyan pixels (tracking active, bounding boxes drawn).
When a model without 'truck' class is selected (best, karung-dimuat,
yolo11n-bbox), the pipeline now automatically loads the truck-detector
model for truck detection. This ensures the batch manager transitions
to COUNTING_SACKS state and draws bounding boxes on output video.
Changes:
- Added find_truck_detector() helper in model_registry.py
- Added truck_model_config parameter to run_pipeline()
- job.py auto-selects truck-detector when model lacks truck class
- Verified with best.engine + batch-3.mp4: bounding boxes drawn