How hwarinn66/dense-object-counter works
This is a local FastAPI dense-object counter: a camera preview feeds a dashboard, motion detection triggers a full-resolution snapshot, ROI cropping and detection produce a numbered count, and images/results can be retained. The README also documents dataset preparation, model training, and count evaluation as distinct workflows. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README; several training and UI details are documented but their runtime wiring was not sampled.
Main entry points: app.py FastAPI App · counter.py Snapshot Counter · auto_trigger.py Stillness Trigger · factory.py Detector Factory
Components 21
Capture and Web
- Dashboard UI
templates/index.html - Browser Controls
static/app.js - FastAPI App
app.py - Camera Manager
camera/camera_manager.py - Runtime Settings
config.py
Counting Pipeline
- Stillness Trigger
counting/auto_trigger.py - ROI Policy
counting/roi.py - Snapshot Counter
counting/counter.py - Saved Results
output
Detection
- Detector Factory
detection/factory.py - Detector Contract
detection/base_detector.py - OpenCV Baseline
detection/opencv_detector.py - YOLO Detector
detection/yolo_detector.py - Tiled Inference
detection/tiled_inference.py
Dataset and Training
- Dataset Files
dataset - Dataset Validation
training/dataset_utils.py - Training Tiles
training/prepare_tiles.py - Model Training
training/train.py - Count Evaluation
training/evaluate_counting.py
Other components
- Operator
- Camera Source
Connections 28
- Operator → Dashboard UI: uses
README.md - Dashboard UI → Browser Controls: loads
README.md - Browser Controls → FastAPI App: polls and controls
README.md - FastAPI App → Dashboard UI: serves
app.py - Camera Source → Camera Manager: provides frames
README.md - FastAPI App → Camera Manager: starts
app.py - FastAPI App → Runtime Settings: configures
app.py - FastAPI App → Detector Factory: creates detector
app.py - FastAPI App → Stillness Trigger: manages
app.py - FastAPI App → Snapshot Counter: manages
app.py - Stillness Trigger → Camera Manager: samples frames
counting/auto_trigger.py - Stillness Trigger → Snapshot Counter: triggers count
counting/auto_trigger.py - Stillness Trigger → ROI Policy: checks scene ROI
counting/auto_trigger.py - Snapshot Counter → Camera Manager: takes snapshot
counting/counter.py - Snapshot Counter → ROI Policy: crops snapshot
counting/counter.py - Snapshot Counter → Tiled Inference: runs inference
counting/counter.py - Snapshot Counter → Saved Results: saves images
counting/counter.py - Detector Factory → OpenCV Baseline: selects
detection/factory.py - Detector Factory → YOLO Detector: selects
detection/factory.py - OpenCV Baseline → Detector Contract: implements
detection/opencv_detector.py - YOLO Detector → Detector Contract: implements
detection/yolo_detector.py - Tiled Inference → Detector Contract: calls detector
detection/tiled_inference.py - Dataset Validation → Dataset Files: validates labels
training/dataset_utils.py - Training Tiles → Dataset Validation: uses dataset tools
README.md - Model Training → Dataset Validation: validates dataset
README.md - Count Evaluation → Dataset Validation: loads annotations
training/evaluate_counting.py - Count Evaluation → Detector Factory: creates detector
training/evaluate_counting.py - Count Evaluation → Tiled Inference: evaluates pipeline
training/evaluate_counting.py