Skip to main content

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.
string
default:"model"
Directory containing YOLO model files (yolov4.weights, yolov4.cfg, coco.names).Required files:
  • yolov4.weights or yolov3.weights - Model weights
  • yolov4.cfg or yolov3.cfg - Model configuration
  • coco.names - Class labels (80 COCO classes)
Download sources:Fallback behavior: If YOLO files are not found, the system automatically falls back to OpenCV’s built-in HOG (Histogram of Oriented Gradients) person detector.Example:
string
default:"output"
Base directory where captured images or video clips are saved.Directory structure:
  • Single stream: Files saved directly to output_dir/
  • Multiple streams: Files saved to output_dir/stream_{id}/
Filename formats:
  • Images: person_entry_{count}_{timestamp}_{unix_time}.jpg
  • Videos: person_clip_{count}_{timestamp}_{unix_time}.mp4
Example:
Note: Directories are created automatically if they don’t exist.

[detection]

Person detection parameters and processing settings.
float
default:"0.5"
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 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
Example:
Override: Use --confidence CLI flag to override this value.
integer
default:"1000"
Minimum bounding box area in pixels (width × height) for a detection to be considered valid.Valid range: Must be >= 0.Validation: Raises ValueError if negative.Purpose: Filters out very small detections which are often:
  • Distant persons (too far to be useful)
  • Partial detections
  • False positives
Calculation example:
  • A 50×50 pixel box = 2,500 pixels (passes default threshold)
  • A 30×30 pixel box = 900 pixels (rejected by default threshold)
Recommended values:
  • Close-range cameras: 500-1000 pixels
  • Medium-range cameras: 1000-2000 pixels
  • Long-range cameras: 2000-5000 pixels
Example:
Override: Use --area-threshold CLI flag to override this value.
integer
default:"15"
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 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)
Additional throttling: Detection is also limited to run at most once every 0.5 seconds (see stream_processor.py:113 and stream_processor.py:303).Example:
Override: Use --frame-skip CLI flag to override this value.

Complete Configuration Example

Loading Configuration

Configuration is loaded using the load_config() function from the config module:

Configuration Object

The loaded configuration is returned as an AppConfig dataclass:
dataclass

Validation Rules

The configuration loader validates all values and raises exceptions for invalid data:

Confidence Threshold Validation

Valid: 0.1, 0.5, 0.9
Invalid: 0.0, 1.0, 1.5, -0.1

Person Area Threshold Validation

Valid: 0, 1000, 5000
Invalid: -1, -1000

Frame Skip Validation

Valid: 1, 15, 30
Invalid: 0, -1

Error Handling

Missing Configuration File

If the specified config file doesn’t exist:
CLI output:

Invalid Configuration Values

If validation fails:
CLI output:

Default Fallback Values

If a key is missing from the config file, the system uses these defaults: This means a minimal config file can contain just the values you want to change:
All other values will use defaults.

Override Hierarchy

Configuration values can be overridden in this order (highest priority first):
  1. CLI flags - --confidence, --area-threshold, --frame-skip
  2. Config file - Values from config.cfg or custom path
  3. Default values - Hardcoded fallbacks in config.py
Example:

Implementation Reference

Configuration loading is implemented in config.py:30-77. The load_config() function uses Python’s configparser module with fallback values for all keys.