File size: 31,771 Bytes
7baad7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# =============================================================================
# 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