# ============================================================================= # MBFS Sentinel - Configuration Template # ============================================================================= # # Usage: # 1. Copy this file to config.yml: cp config.example.yml config.yml # 2. Update values to match your environment # 3. Restart mbfs-sentinel to apply changes # # Notes: # - All paths can be relative (to the executable) or absolute # - Durations use seconds unless noted otherwise # - Set 'enabled: true' on any plugin you want to activate # # ============================================================================= # ============================================================================= # General Settings # ============================================================================= general: project_name: MBFS Sentinel # Display name shown in UI and logs port: 8003 # HTTP API port (Axum server) dev_mode: false # Enable development mode (extra logging, relaxed checks) device_id: c9869e48ab4a2341fe4e08587b20d6c402da59ce2e26d934b9d3d6d503e0bd5a # Unique device identifier (from mbfs-mv-core) # ============================================================================= # Database (PostgreSQL + pgvector) # ============================================================================= database: # PostgreSQL connection URL # Format: postgresql://user:password@host:port/database?sslmode=disable url: "postgresql://root:123123@localhost:5434/dev?sslmode=disable" # Secret key for signing JWT tokens (MUST change in production!) secret_key: "secret" # ============================================================================= # MinIO Storage (S3-compatible object storage) # ============================================================================= # Used for storing face crops, event snapshots, evidence images/videos. # Any S3-compatible service can be used (AWS S3, MinIO, etc.) # ============================================================================= minio: endpoint: "localhost:9000" # MinIO server host:port access_key: "minioadmin" # Access key (username) secret_key: "minioadmin" # Secret key (password) bucket: "mbfs-sentinel" # Bucket name for all stored objects secure: false # Use TLS/SSL connection (true for HTTPS) url: http://localhost:9000 # Public-facing URL for generating download links # ============================================================================= # AI Models # ============================================================================= # Directory and filenames for core ONNX models (face detection & recognition). # Plugin-specific models are configured in their respective sections below. # ============================================================================= models: dir: './models' # Path to model files directory detection_name: "" # Face detection model (RetinaFace) recognition_name: "" # Face recognition/embedding model (ArcFace) # ============================================================================= # Batch Processing # ============================================================================= # Controls how frames are batched before inference to maximize GPU throughput. # Larger batches = higher throughput but more latency and VRAM usage. # ============================================================================= batch: detection_size: 24 # Face detection batch size (frames per batch) recognition_size: 96 # Face recognition batch size (face crops per batch) collection_timeout_ms: 100 # Max wait time to fill a batch before processing (ms) # ============================================================================= # Worker Threads # ============================================================================= workers: num_ai: 3 # Number of AI inference worker threads upload: 24 # Number of upload worker threads (MinIO/S3) # ============================================================================= # Face Tracking # ============================================================================= # Settings for tracking detected faces across consecutive frames. # Used by face recognition to maintain identity continuity. # ============================================================================= tracking: high_confidence_threshold: 0.65 # Min confidence for a high-quality face match timeout: 2.0 # Seconds before a tracked face expires (no re-detection) similarity: 0.55 # Cosine similarity threshold for re-identification log_cooldown: 3.0 # Min seconds between logging the same face identity min_detections: 2 # Min detection count before a face is logged as event # ============================================================================= # Image Upload # ============================================================================= upload: queue_max_size: 100 # Max pending uploads in queue (overflow is dropped) jpeg_quality: 70 # JPEG compression quality for uploaded images (0-100) # ============================================================================= # Camera Manager # ============================================================================= # Connection to the external camera management service. # Sentinel periodically sends a survival signal to indicate it is alive. # ============================================================================= camera_manager: url: http://localhost:8000 # Camera manager API base URL survival_signal_interval: 10 # Interval in seconds for survival heartbeat # ============================================================================= # Core AI Node (Cluster mode) # ============================================================================= # URL of the central AI node when running in distributed/cluster mode. # ============================================================================= core_ai: url: http://10.8.0.3:8003 # ============================================================================= # TensorRT Configuration # ============================================================================= # TensorRT engine caching speeds up model loading after first run. # Engine files are GPU-specific and will be rebuilt if hardware changes. # ============================================================================= tensorrt: enabled: true # false = skip TensorRT, use CUDA (faster startup, slower inference) cache_dir: trt_cache # Directory for cached TensorRT engine files lib_dir: null # Custom TensorRT library path (null = system default) # ============================================================================= # License # ============================================================================= license: key: '' # License key (obtained from license server) active_key: '' # Active license key (set after successful activation) license_server: url: https://ai-mv-core.mbfs.com.vn # License server URL check_interval_secs: 86400 # License recheck interval (86400 = 24 hours) # ============================================================================= # Processing Loop # ============================================================================= # Low-level tuning for the frame processing pipeline. # Default values work well for most setups. Only adjust if needed. # ============================================================================= processing: max_batch_size: 24 # Max frames per processing batch loop_sleep_ms: 10 # Sleep between processing loops (ms) channel_buffer_size: 256 # Channel buffer for frame pipeline face_log_queue_size: 256 # Face event logging queue size face_log_workers: 2 # Face event logging worker threads dispatch_max_fps: 15 # Default max dispatch rate per pipeline runner (fps). # Coordinator drops batches dispatched faster than this # to avoid wasting Arc clones + mutex contention on frames # the runner can't keep up with. Camera decode rate is # capped separately at 15fps in mbfs-camera. # Plugins can override per-plugin via manifest.toml: # [runtime] # max_fps = 8 # ============================================================================= # Plugins - AI Pipeline Configurations # ============================================================================= # # Each plugin can be independently enabled/disabled. Common sub-sections: # # enabled - Whether the plugin is active (true/false) # confidence - Min detection confidence threshold (0.0 - 1.0) # nms_threshold - Non-Maximum Suppression IoU threshold (0.0 - 1.0) # # tracking: - ByteTrack multi-object tracker settings # enabled - Enable/disable object tracking # high_conf_threshold - High confidence detection threshold # low_conf_threshold - Low confidence detection threshold # confirm_frames - Frames needed to confirm a new track # max_lost_frames - Max frames before a lost track is removed # # alert: - Alert system settings (consecutive detection triggers) # consecutive_threshold - Consecutive detections needed to trigger alert # max_miss - Max missed frames before resetting alert counter # cooldown_secs - Cooldown between alerts for the same object # # data_lake: - Event storage configuration # enabled - Enable event logging # bucket_prefix - MinIO bucket prefix for this plugin's events # min_count - Min detection count before saving event # jpeg_quality - JPEG quality for event snapshots (0-100) # queue_size - Event processing queue size # workers - Number of event processing workers # batch_size - Events per batch write # parquet_enabled - Enable Parquet file export # parquet_batch_size - Rows per Parquet batch # save_json - Save raw JSON alongside Parquet # db_enabled - Write events to PostgreSQL # db_batch_size - DB insert batch size # db_batch_timeout_ms - Max wait before flushing DB batch (ms) # db_channel_size - DB write channel buffer size # save_crops - Save cropped detection images to MinIO # crop_jpeg_quality - JPEG quality for crop images (0-100) # # dedup: - Deduplication settings (prevent duplicate events) # cooldown_seconds - Min seconds between events for same object # grid_size - Spatial grid cell size for position-based dedup # high_confidence_threshold - Confidence above which dedup is stricter # significant_count_threshold - Detection count to consider object significant # max_tracked_per_camera - Max tracked objects per camera for dedup # # ============================================================================= plugins: # --------------------------------------------------------------------------- # Shared Models # --------------------------------------------------------------------------- # Model files referenced by multiple plugins. Avoids duplicating filenames. # These are loaded once and shared across plugins that need them. # --------------------------------------------------------------------------- shared_models: detection_model: det_10g_fp16_dynamic.onnx.enc # Face detection (RetinaFace) recognition_model: mbfs_rec_vit_b_v3.onnx.enc # Face recognition (ViT) human_detection_model: mbfs_human_det_v4.onnx # Human/person detection (YOLO) helmet_model: helmet_dt_v10.onnx # Helmet detection lpr_detection_model: lp_detection_v4.onnx # License plate detection lpr_ocr_model: mbfs_ocr_license_plate_b16_v5.onnx # License plate OCR vehicle_model: yolov8_coco.onnx # Vehicle detection (COCO classes) # --------------------------------------------------------------------------- # Face Recognition (builtin) # --------------------------------------------------------------------------- # Detects faces, extracts embeddings, and matches against enrolled identities. # Requires: detection_model + recognition_model from shared_models. # --------------------------------------------------------------------------- face_recognition: enabled: false min_detection_score: 0.7 # Min face detection confidence min_size: 32 # Min face size in pixels (width or height) min_ratio: 0.0001 # Min face area ratio relative to frame unknown_min_score: 0.50 # Min score to classify as "unknown" (below = discard) enrollment_min_detection_score: 0.7 # Stricter detection threshold for face enrollment enrollment_min_size: 100 # Min face size for enrollment (px) enrollment_max_angle: 15.0 # Max yaw/pitch angle for enrollment (degrees) data_lake: enabled: true bucket_prefix: face-recognition-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 1 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 32 db_batch_timeout_ms: 100 db_channel_size: 512 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 5.0 grid_size: 100.0 high_confidence_threshold: 0.65 significant_count_threshold: 3 max_tracked_per_camera: 50 # =========================================================================== # Dynamic Plugins # =========================================================================== # Plugins loaded at runtime from DLLs in the plugins/ directory. # Each plugin has a manifest.toml defining its models and capabilities. # Config values here override manifest defaults. # =========================================================================== dynamic_plugins: # ------------------------------------------------------------------------- # Human Detection # ------------------------------------------------------------------------- # Detects humans/persons in the frame. Foundation for many other plugins. # Model: human_detection_model from shared_models. # ------------------------------------------------------------------------- human_detection: enabled: false confidence: 0.75 nms_threshold: 0.45 alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 10.0 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: human-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Facial Expression Recognition # ------------------------------------------------------------------------- # Classifies facial expressions (happy, sad, angry, surprised, etc.). # Two-stage: face detection -> expression classification. # ------------------------------------------------------------------------- facial_expression: enabled: false confidence: 0.5 nms_threshold: 0.45 alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 10.0 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: facial-expression-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Object Detection (General) # ------------------------------------------------------------------------- # General-purpose object detection using COCO or custom classes. # Useful for counting/tracking arbitrary object types. # ------------------------------------------------------------------------- object_detection: enabled: false confidence: 0.75 nms_threshold: 0.45 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: object-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Smoke & Fire Detection # ------------------------------------------------------------------------- # Detects smoke and fire in the frame. Triggers alerts when detected # consecutively to reduce false positives. # ------------------------------------------------------------------------- smoke_fire_detection: enabled: false confidence: 0.75 alert: consecutive_threshold: 5 # Consecutive detections to trigger alert max_miss: 2 # Max missed frames before reset cooldown_secs: 10.0 # Alert cooldown (seconds) data_lake: enabled: true bucket_prefix: smoke-fire-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Behavior Detection # ------------------------------------------------------------------------- # Detects abnormal behaviors (loitering, falling, running, etc.). # Uses human detection + tracking to analyze movement patterns. # ------------------------------------------------------------------------- behavior_detection: enabled: false confidence: 0.75 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 5 # Higher confirm frames for behavior analysis max_lost_frames: 30 data_lake: enabled: true bucket_prefix: behavior-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Helmet Detection # ------------------------------------------------------------------------- # Detects whether people are wearing safety helmets (construction sites, etc.). # Triggers alerts for "no helmet" detections. # ------------------------------------------------------------------------- helmet_detection: enabled: false confidence: 0.75 alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 10.0 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: helmet-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Weapon Detection # ------------------------------------------------------------------------- # Detects weapons (guns, knives, etc.) in the frame. # Lower confidence threshold and shorter cooldown for safety-critical alerts. # ------------------------------------------------------------------------- weapon_detection: enabled: false confidence: 0.5 # Lower threshold for safety-critical detection nms_threshold: 0.45 alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 5.0 # Shorter cooldown for urgent alerts tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: weapon-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 5.0 # Longer dedup for weapon events grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Phone Usage Detection # ------------------------------------------------------------------------- # Two-stage: detect humans -> crop -> classify phone usage. # Higher confidence threshold to reduce false positives on small objects. # ------------------------------------------------------------------------- phone_usage_detection: enabled: false confidence: 0.8 # Higher threshold (small object, prone to FP) nms_threshold: 0.45 crop_padding: 0.1 # Extra padding around human crop for context alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 5.0 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: phone-usage-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 30.0 # Longer cooldown to avoid spam grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Fight Detection # ------------------------------------------------------------------------- # Detects physical fights/altercations between people. # Uses pose or interaction analysis on tracked humans. # ------------------------------------------------------------------------- fight_detection: enabled: false confidence: 0.5 nms_threshold: 0.45 alert: consecutive_threshold: 5 max_miss: 2 cooldown_secs: 5.0 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: fight-detection-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # People Counting (migrated from builtin to dynamic plugin) # ------------------------------------------------------------------------- people_counting: enabled: false confidence: 0.25 nms_threshold: 0.45 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: people-counting-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # License Plate Recognition (migrated from builtin to dynamic plugin) # ------------------------------------------------------------------------- license_plate_recognition: enabled: false confidence: 0.5 nms_threshold: 0.45 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 2 max_lost_frames: 15 data_lake: enabled: true bucket_prefix: license-plate-recognition-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 10.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ------------------------------------------------------------------------- # Traffic Violation Detection (migrated from builtin to dynamic plugin) # ------------------------------------------------------------------------- traffic_violation_detection: enabled: false confidence: 0.5 nms_threshold: 0.45 tracking: enabled: true high_conf_threshold: 0.5 low_conf_threshold: 0.1 confirm_frames: 3 max_lost_frames: 30 data_lake: enabled: true bucket_prefix: traffic-violation-events min_count: 1 jpeg_quality: 85 queue_size: 512 workers: 2 batch_size: 16 parquet_enabled: true parquet_batch_size: 1000 save_json: false db_enabled: true db_batch_size: 16 db_batch_timeout_ms: 100 db_channel_size: 256 save_crops: true crop_jpeg_quality: 90 dedup: cooldown_seconds: 3.0 grid_size: 100.0 high_confidence_threshold: 0.75 significant_count_threshold: 5 max_tracked_per_camera: 50 # ============================================================================= # Logging # ============================================================================= logging: enabled: true dir: logs # Log files directory (relative to executable) max_days: 7 # Auto-cleanup logs older than N days