Add pause-on-first-frame for file sources (.continue resume)

This commit is contained in:
proitlab committed 2026-08-10 10:16:07 +07:00
1 parent 139cff7474
commit 1d1199fa04
8 files changed
+82 -22

No files matched your search

+4 -1
View File
@@ -23,12 +23,13 @@ env: .env KEY=VALUE file — all config per config.env.example
env: SHM_DIR → shared memory directory (/dev/shm/bytetrack-counter)
env: LIVE_STREAM_FRAME_PATH → JPEG snapshot path
env: RECORD_VIDEO, RECORD_DELAY_SECONDS, RECORD_END_DELAY, RECORD_RETENTION_DAYS, RECORD_CRF, RECORD_PRESET
cmd: bytetrack-counter <config.env> [--source <rtsp://|http://|/path/to/file.mp4>]
cmd: bytetrack-counter <config.env> [--source <rtsp://|http://|/path/to/file.mp4>] [--pause-on-first-frame]
db: SQLite batches(id,counting_date,batch_number,camera_name,object_label,count,start_time,end_time)
db: SQLite daily_summaries(id,counting_date,camera_name,object_label,total_count,total_batches)
file: JSON state — batch_number,count,start_time,last_detection_time,counted_event_ids[]
file: CSV crossing log — batch,frame,timestamp,chicken_id
file: SHM_DIR/.reset → trigger full state reset
file: SHM_DIR/.continue → resume processing after pause-on-first-frame
file: SHM_DIR/batch_pending_*.mp4 → confirmed when ayam detected, moved to OUTPUT_DIR/<batch counting_date>/batch_<num>_<YYYYMMDD>_<HHMMSS>.mp4 (num=batch, YYYYMMDD=counting_date, HHMMSS=move time)
sig: SIGTERM|SIGINT → shutdown_requested → graceful exit
```
@@ -51,6 +52,7 @@ V12: SHM_DIR/.reset → BatchStore::reset() — end active batch, clear memory,
V13: video recording: motion → SPECULATING (≤RECORD_DELAY_SECONDS), ayam → CONFIRMED → talenan/batch-end → STOPPING (+RECORD_END_DELAY) → move to OUTPUT_DIR/<batch counting_date>/ via fork
V14: video retention: day-dirs > RECORD_RETENTION_DAYS old → removed @ startup & @ each CUTOFF_TIME (localtime cutoff matches folder names)
V15: RECORD_CRF (lower = better, -1 unset) & RECORD_PRESET → OPENCV_FFMPEG_WRITE_OPTIONS before writer_.open() (crf;<n>|preset;<p>)
V16: pause_on_first_frame (env/--pause-on-first-frame, file source only; live ignored w/ warn): process frame 0 → idle-loop, re-write annotated frame to LIVE_STREAM_FRAME_PATH, wait for SHM_DIR/.continue → delete → resume
```
## §T — Tasks
@@ -75,6 +77,7 @@ T15|x|Graceful shutdown: SIGTERM → close batch → save state|I.sig
T16|x|Video per-batch recording: motion-triggered → speculating in shm, confirmed when ayam detected ≤ RECORD_DELAY_SECONDS, stopped RECORD_END_DELAY after batch close, moved to OUTPUT_DIR/<batch counting_date>/ via fork, retention cleanup at startup & cutoff, H.264 quality via RECORD_CRF/RECORD_PRESET (OPENCV_FFMPEG_WRITE_OPTIONS). Unconfirmed recordings deleted.|V13,V14,V15
T17|~?|Python DEBUG_TRACKING equivalent (per-frame score/track dump)|-
T18|x|CLI --source/-s/--source= override of SOURCE (rtsp|http|local mp4; file = single pass)|I.cmd
T19|x|Pause-on-first-frame for file source: process frame 0, hold annotated frame as live view, wait for SHM_DIR/.continue, resume. Env PAUSE_ON_FIRST_FRAME + --pause-on-first-frame; stale .continue cleared @ startup; live source ignored w/ warning.|V16
```
## §B — Bugs