{
  "name": "std_face_recognition_stream",
  "description": "1080p 人脸识别流程，包含滑窗人脸检测、人脸识别、画面叠加与视频发布。",
  "source": "configs/test_scrfd_640_recog.json",
  "slots": {
    "inputs": [
      {"name": "video_input_main", "type": "video_source", "required": true, "description": "主视频输入"}
    ],
    "services": [],
    "outputs": [
      {"name": "stream_output_main", "type": "stream_publish", "required": true, "description": "主视频输出"}
    ]
  },
  "template": {
    "executor": {
      "batch_size": 2,
      "run_budget": 6
    },
    "nodes": [
      {
        "id": "input_rtsp_main",
        "type": "input_rtsp",
        "role": "source",
        "enable": true,
        "url": "${slot:video_input_main.url}",
        "fps": 30,
        "width": 1920,
        "height": 1080,
        "use_ffmpeg": true,
        "use_mpp": false,
        "force_tcp": true,
        "reconnect_sec": 5,
        "reconnect_backoff_max_sec": 30
      },
      {
        "id": "preprocess_rgb",
        "type": "preprocess",
        "role": "filter",
        "enable": true,
        "cpu_affinity": [
          2
        ],
        "dst_w": 1920,
        "dst_h": 1080,
        "dst_format": "rgb",
        "dst_packed": true,
        "resize_mode": "stretch",
        "keep_ratio": false,
        "rga_gate": "face_recognition_pipeline_rga",
        "use_rga": true
      },
      {
        "id": "detect_face",
        "type": "ai_scrfd_sliding",
        "role": "filter",
        "enable": true,
        "cpu_affinity": [
          4
        ],
        "infer_fps": 3,
        "model_path": "./models/face_det_scrfd_500m_640_rk3588.rknn",
        "model_w": 640,
        "model_h": 640,
        "windows": [
          {
            "x": 0,
            "y": 0,
            "w": 960,
            "h": 1080
          },
          {
            "x": 960,
            "y": 0,
            "w": 960,
            "h": 1080
          }
        ],
        "conf_thresh": 0.5,
        "nms_thresh": 0.4,
        "max_faces": 50,
        "debug": {
          "stats": false,
          "stats_interval": 30
        }
      },
      {
        "id": "recognize_face",
        "type": "ai_face_recog",
        "role": "filter",
        "enable": true,
        "cpu_affinity": [
          4
        ],
        "infer_fps": 2,
        "infer_phase_ms": 120,
        "model_path": "./models/face_recog_mobilefacenet_arcface_112_rk3588.rknn",
        "align": true,
        "emit_embedding": false,
        "max_faces": 50,
        "person_class_id": 0,
        "track_state_max_age_ms": 1000,
        "input_format": "rgb",
        "input_dtype": "uint8",
        "threshold": {
          "accept": 0.45,
          "margin": 0.05
        },
        "gallery": {
          "backend": "sqlite",
          "path": "./models/face_gallery.db",
          "load_on_start": true,
          "dtype": "auto"
        },
        "debug": {
          "enabled": false,
          "log_matches": false,
          "min_log_interval_ms": 0
        }
      },
      {
        "id": "render_osd",
        "type": "osd",
        "role": "filter",
        "enable": true,
        "cpu_affinity": [
          7
        ],
        "draw_bbox": true,
        "draw_text": true,
        "draw_face_det": true,
        "draw_face_recog": true,
        "draw_face_bbox": true,
        "line_width": 2.0,
        "font_scale": 1.0,
        "use_rga_bbox": false,
        "labels": []
      },
      {
        "id": "prepare_publish",
        "type": "preprocess",
        "role": "filter",
        "enable": true,
        "cpu_affinity": [
          7
        ],
        "dst_w": 1920,
        "dst_h": 1080,
        "dst_format": "nv12",
        "resize_mode": "stretch",
        "rga_gate": "face_recognition_pipeline_rga",
        "use_rga": true
      },
      {
        "id": "publish_stream",
        "type": "publish",
        "role": "sink",
        "enable": true,
        "cpu_affinity": [
          3
        ],
        "queue": {
          "size": 2,
          "policy": "drop_oldest"
        },
        "codec": "h264",
        "fps": 30,
        "gop": 60,
        "bitrate_kbps": 4000,
        "mpp_output_timeout_ms": 50,
        "mpp_packet_wait_ms": 10,
        "use_mpp": true,
        "use_ffmpeg_mux": true,
        "outputs": [
          {
            "proto": "hls",
            "path": "${slot:stream_output_main.publish_hls_path}",
            "segment_sec": 2
          },
          {
            "proto": "rtsp_server",
            "port": "${slot:stream_output_main.publish_rtsp_port}",
            "path": "${slot:stream_output_main.publish_rtsp_path}"
          }
        ]
      }
    ],
    "edges": [
      [
        "input_rtsp_main",
        "preprocess_rgb"
      ],
      [
        "preprocess_rgb",
        "detect_face"
      ],
      [
        "detect_face",
        "recognize_face"
      ],
      [
        "recognize_face",
        "render_osd"
      ],
      [
        "render_osd",
        "prepare_publish"
      ],
      [
        "prepare_publish",
        "publish_stream"
      ]
    ]
  }
}
