6.1 KiB
6.1 KiB
Changelog
All notable changes to the chicken-counting-sukawarna-det project are documented in this file.
[Unreleased] - 2026-08-20
🚀 Features & Architectural Improvements
- Hierarchical Per-Coop & Flexible Cage/Floor Discovery (
discovery.py):- Implemented dynamic farm discovery engine (
discover_farm_structure,get_coop_for_location,resolve_floor_video_dir). - Added support for hierarchical coop folders (
VIDEOS/cycle7/<Coop>/[L1..Ln, mortality]) where all floors and mortality sit on the same level per coop. - Fully dynamic site layout discovery without hardcoding assumptions about numbers of coops (e.g. K1..K5 or custom names) or floors per coop (e.g. 2 floors vs 3 floors).
- Implemented dynamic farm discovery engine (
- Multi-Coop Mortality Pipeline & Batch Runner (
mortality.py,cli.py,run_mortality_all.sh):- Added coop and covered floor metadata resolution in
run_mortality_count(...)andmortality_report.json. - Created
run_all_coop_mortality(...)and./run_mortality_all.shto batch-process mortality detection across all discovered coops with summary reports. - Added CLI flags
--coop <ID>and--all-coopstochicken-counter mortality.
- Added coop and covered floor metadata resolution in
- Dedicated Stationary Inspection Camera Capture & Live API (
mortality.py,dashboard.py,templates/index.html):- Added support for dedicated per-coop stationary cameras (RTSP IP cameras, HTTP snapshots, and USB cameras) configured in
configs/mortality_config.yaml. - Added
POST /api/mortality/captureendpoint to grab high-res still frames from a coop's stationary camera, timestamp and save them intoVIDEOS/cycle7/<Coop>/mortality/<YYYY-MM-DD>/, and run YOLO carcass detection. - Added
GET /api/mortality/camera/previewto stream live snapshot previews to workers in the webapp before snapping. - Added
GET /api/mortality/camerasto list all registered coop stationary camera sources. - Web UI Mortality Inspector: Integrated live camera preview, one-click "📸 Snap & Count Batch from Camera" button, and support for multi-batch counting per coop per day with cumulative totals.
- Added fallback manual file upload tab for disk-based images.
- Added support for dedicated per-coop stationary cameras (RTSP IP cameras, HTTP snapshots, and USB cameras) configured in
- Dynamic Floor Config Synthesis & Sync Tool (
config.py,discovery.py,cli.py):- Implemented
load_or_synthesize_floor_configallowingchicken-counter batch --floor <ID>to dynamically synthesize settings fromcycle7_batch_optimized.yamlin memory without requiring a physical YAML file. - Implemented
sync_floor_configsand CLI commandchicken-counter sync-configsto automatically scanVIDEOS/and generate boilerplate floor YAML configs for newly added coops/floors. - Updated
run_all_coops.shto dynamically discover all floors directly fromVIDEOS/orconfigs/floor_config/and seamlessly run physical YAMLs or virtual in-memory configs.
- Implemented
- Unit Test Suite (
tests/test_flexible_discovery.py):- Added automated test cases validating dynamic coop and floor extraction, arbitrary site layout adaptation, path resolution, config synchronization, virtual floor config synthesis, and dated mortality discovery.
[1.1.0] - 2026-08-19
🐛 Bug Fixes
- Multi-Camera Tracker State Isolation (
tracking.py&batch_runner.py):- Implemented per-camera independent tracker instances keyed by
stream_idinDetectionTracker. - Fixed tracker state bleed and track ID jumping in
tensor_batchingand multi-camera batch modes when camera frames are processed or when active camera sets shrink. - Added unit test suite
tests/test_tracking.pycovering multi-stream tracker isolation.
- Implemented per-camera independent tracker instances keyed by
- Multi-Floor Script Syntax (
run_all_coops.sh):- Resolved fatal
syntax error: unexpected end of filecaused by missingdonein floor configuration discovery loop. - Expanded config discovery pattern from
K*-L*.yamlto*.yamlto support custom named coops (e.g.kandang-atas.yaml).
- Resolved fatal
- Excel Report Empty Result Crash (
export_excel_report.py):- Added empty DataFrame pre-check to prevent
IndexErrorwhen exporting reports for dates with no batch runs or newly initialized databases.
- Added empty DataFrame pre-check to prevent
- Multi-Threaded SQLite Concurrency (
dashboard.py):- Replaced global single
sqlite3connection with thread-local connections (threading.local()) to prevent cursor collision and race conditions across concurrent HTTP worker threads. - Enabled
PRAGMA busy_timeout = 5000andPRAGMA journal_mode = WALto avoid database lock conflicts during batch processing writes.
- Replaced global single
- Editable Package Installation:
- Configured
pip install -e .in environment setup to resolvechicken_counterimports and enable automatic unit test discovery without manualPYTHONPATHprefixes.
- Configured
⚡ Performance & Optimization
- Secondary Database Indexing (
dashboard.py,batch_runner.py,store_results.py):- Added
idx_batch_date,idx_batch_camera, andidx_batch_locationindexes onbatch_runsto accelerate single camera, location, and date historical queries.
- Added
- Atomic Config Persistence (
dashboard.py):- Added
_config_write_lockand atomic temporary file replacement (os.replace) in_persist_cycle_start_dateto prevent race conditions or half-written YAML reads.
- Added
- Streaming Socket Keepalive (
dashboard.py):- Added an idle keepalive heartbeat (
b"--frame\r\n\r\n") every 3 seconds to immediately detect and terminate disconnected MJPEG streaming threads during pipeline idle periods.
- Added an idle keepalive heartbeat (
- Disk Traversal Caching in Live Dashboard (
dashboard.py):- Replaced repetitive
Path.rglob()scans on every/api/mortality/*endpoint with a thread-safe 15-second in-memory TTL cache (_MORTALITY_CACHE_TTL = 15.0s). - Added
O(1)memory index lookup for serving annotated images (/api/mortality/image/<filename>), eliminating full filesystem traversals across 30GB+ video datasets.
- Replaced repetitive
📁 Configuration & Directory Structure
- Floor Configuration & Skeleton Paths:
- Created
configs/floor_config/kandang-atas.yamlextendingcycle7_batch_optimized.yaml. - Initialized missing directory skeletons for coops
K1-L1throughK5-L2under../VIDEOS/cycle7/.
- Created
- Documentation:
- Updated
README.mdandRUN.mdwith editable install steps and updated project layout.
- Updated