Overview
RTSP Human Capture uses an INI-style configuration file (default:config.cfg) to specify paths, detection parameters, and processing settings. Command-line flags override individual config values when provided.
File Format
The configuration file uses standard INI syntax with sections denoted by[section_name] and key-value pairs:
Configuration Sections
[paths]
File system paths for model files and output directories.Directory containing YOLO model files (
yolov4.weights, yolov4.cfg, coco.names).Required files:yolov4.weightsoryolov3.weights- Model weightsyolov4.cfgoryolov3.cfg- Model configurationcoco.names- Class labels (80 COCO classes)
Base directory where captured images or video clips are saved.Directory structure:Note: Directories are created automatically if they don’t exist.
- Single stream: Files saved directly to
output_dir/ - Multiple streams: Files saved to
output_dir/stream_{id}/
- Images:
person_entry_{count}_{timestamp}_{unix_time}.jpg - Videos:
person_clip_{count}_{timestamp}_{unix_time}.mp4
[detection]
Person detection parameters and processing settings.Minimum confidence score (0.0 to 1.0) for a detection to be considered valid.Valid range: Must be between 0.0 (exclusive) and 1.0 (exclusive).Validation: Raises Override: Use
ValueError if outside valid range.Behavior:- Lower values (0.3-0.5): More detections, more false positives
- Medium values (0.5-0.7): Balanced accuracy
- Higher values (0.7-0.9): Fewer false positives, may miss some people
--confidence CLI flag to override this value.Minimum bounding box area in pixels (width × height) for a detection to be considered valid.Valid range: Must be >= 0.Validation: Raises Override: Use
ValueError if negative.Purpose: Filters out very small detections which are often:- Distant persons (too far to be useful)
- Partial detections
- False positives
- A 50×50 pixel box = 2,500 pixels (passes default threshold)
- A 30×30 pixel box = 900 pixels (rejected by default threshold)
- Close-range cameras: 500-1000 pixels
- Medium-range cameras: 1000-2000 pixels
- Long-range cameras: 2000-5000 pixels
--area-threshold CLI flag to override this value.Process every Nth frame from the video stream. Frames in between are still captured for video recording but not analyzed for person detection.Valid range: Must be >= 1.Validation: Raises Override: Use
ValueError if less than 1.Performance impact:frame_skip = 1: Analyze every frame (slowest, highest accuracy)frame_skip = 15: ~2 detections/second on 30fps stream (recommended)frame_skip = 30: ~1 detection/second on 30fps stream (faster)frame_skip = 60: ~0.5 detections/second on 30fps stream (fastest)
stream_processor.py:113 and stream_processor.py:303).Example:--frame-skip CLI flag to override this value.Complete Configuration Example
Loading Configuration
Configuration is loaded using theload_config() function from the config module:
Configuration Object
The loaded configuration is returned as anAppConfig dataclass:
Validation Rules
The configuration loader validates all values and raises exceptions for invalid data:Confidence Threshold Validation
0.1, 0.5, 0.9Invalid:
0.0, 1.0, 1.5, -0.1
Person Area Threshold Validation
0, 1000, 5000Invalid:
-1, -1000
Frame Skip Validation
1, 15, 30Invalid:
0, -1
Error Handling
Missing Configuration File
If the specified config file doesn’t exist:Invalid Configuration Values
If validation fails:Default Fallback Values
If a key is missing from the config file, the system uses these defaults:| Section | Key | Default Value |
|---|---|---|
[paths] | model_dir | "model" |
[paths] | output_dir | "person" |
[detection] | confidence_threshold | 0.5 |
[detection] | person_area_threshold | 1000 |
[detection] | frame_skip | 15 |
Override Hierarchy
Configuration values can be overridden in this order (highest priority first):- CLI flags -
--confidence,--area-threshold,--frame-skip - Config file - Values from
config.cfgor custom path - Default values - Hardcoded fallbacks in
config.py
Implementation Reference
Configuration loading is implemented inconfig.py:30-77. The load_config() function uses Python’s configparser module with fallback values for all keys.