Skip to main content

Configuration Overview

RTSP Human Capture uses a two-tier configuration system:
  1. config.cfg file - INI-style configuration with default values
  2. CLI arguments - Runtime overrides for individual values
CLI arguments always take precedence over config file values. This allows you to use a base configuration and adjust specific parameters per run.

Configuration File (config.cfg)

Default Configuration

The default config.cfg file contains all available settings:

Configuration Sections

Controls where the application reads model files and writes output.Example:
Controls person detection sensitivity and performance.Example:

Configuration Parameters in Detail

model_dir

string
default:"model"
Directory containing YOLO model files. Can be absolute or relative path.
Valid values:
  • Relative path: model, models/yolo, ./weights
  • Absolute path: /opt/models, /home/user/yolo
What it should contain:
Usage in code (person_detector.py:44-45):

output_dir

string
default:"output"
Root directory where captured images and video clips are saved.
Behavior:
  • Single stream: Files saved directly in output_dir/
  • Multiple streams: Sub-folders created as output_dir/stream_<id>/
Example structure:
Auto-creation (stream_processor.py:56-58):

confidence_threshold

float
default:"0.5"
required
Minimum detection confidence score (0.0 to 1.0). Detections below this threshold are discarded.
How it works: Each detection has a confidence score. Only detections exceeding this threshold are kept. Recommendations:

Low (0.3-0.4)

Use when:
  • Distant cameras
  • Low light conditions
  • Prefer false positives over missed detections
Trade-off: More false alarms

Medium (0.5-0.6)

Use when:
  • Standard conditions
  • Balanced accuracy needed
  • General purpose monitoring
Trade-off: Good balance

High (0.7-0.9)

Use when:
  • High confidence required
  • Minimize false positives
  • Clear, well-lit scenes
Trade-off: May miss some detections
Implementation (person_detector.py:131):
Validation (config.py:60-63):

person_area_threshold

integer
default:"1000"
Minimum bounding box area in pixels. Detections with smaller areas are filtered out.
Purpose: Filter out:
  • Distant/small detections
  • Partial detections at frame edges
  • Noise and false positives
Calculation:
Example values: Reference frame sizes:
  • 1920×1080 (Full HD) = 2,073,600 pixels
  • 1280×720 (HD) = 921,600 pixels
  • 640×480 (SD) = 307,200 pixels
Implementation (person_detector.py:147):
For 1080p streams, person_area_threshold = 1000 means detections must be at least ~32×32 pixels (about 1.5% of frame height).

frame_skip

integer
default:"15"
Process every Nth frame. Higher values improve performance but reduce detection frequency.
Purpose: Balance between:
  • Performance: Processing every frame is CPU/GPU intensive
  • Responsiveness: Skipping too many frames delays detection
Effective detection rate:
Examples: Implementation (stream_processor.py:113):
Additional throttling: Detection runs at most once per 0.5 seconds, even if frame_skip triggers more frequently.
Recommendations:
Use when:
  • Running many streams
  • CPU/GPU limited
  • Slow detection acceptable

CLI Override Options

All configuration values can be overridden at runtime using command-line arguments.

Configuration File Selection

string
default:"config.cfg"
Path to configuration file to load.

Detection Parameter Overrides

Override Implementation

From main.py:89-94:
Overrides only apply when explicitly provided. If a flag is omitted, the config file value is used.

Complete CLI Reference

Configuration Examples

High Security Monitoring

Scenario: Bank entrance, minimize false alarms

Performance-Optimized Multi-Stream

Scenario: 16 camera warehouse monitoring

Parking Lot Monitoring

Scenario: Wide-angle distant detection

Configuration Loading

The configuration loading process (from config.py:30-77):
1

Check file exists

2

Parse INI file

3

Load values with fallbacks

4

Validate values

5

Return AppConfig object

Troubleshooting

Error:
Solution: Create a config.cfg file in your working directory or specify a custom path:
Error:
Solution: Ensure confidence_threshold is between 0.0 and 1.0:
Error:
Solution: Set frame_skip to 1 or higher:
Issue: Config file values are used instead of CLI arguments.Check:
  • Ensure flag syntax is correct: --confidence 0.7 (not --confidence=0.7)
  • CLI args must come after positional arguments
  • Use = for some shells: --confidence=0.7
Debug: Look for this output:
The values shown reflect the final configuration after CLI overrides.

Best Practices

Use Config Files for Defaults

Keep common settings in config.cfg and override specific values via CLI when needed.

Create Environment-Specific Configs

Version Control Your Configs

Commit config files (except those with secrets) to track configuration changes over time.

Document Custom Values

Add comments in config files explaining why non-default values were chosen.

Next Steps

Single Stream Processing

Learn to process a single RTSP stream

Multi-Stream Processing

Monitor multiple cameras simultaneously

GPU Acceleration

Speed up detection with CUDA

Model Setup

Configure YOLO models