# AIPC Platform Application Manifest
# 人形检测应用 - 完整示例（SDK + 模型 + 视频流 + 事件）

apiVersion: v1
kind: Application

metadata:
  id: person-detection
  name: Person Detection
  version: 1.0.0
  description: Real-time person detection with AI inference and event publishing
  author: AIPC Team

spec:
  # Container image
  image: aipc/person-detection:1.0.0

  # Resource limits
  resources:
    cpu: "50%"
    memory: "256Mi"

  # Permission configuration
  permissions:
    # Video stream access
    video:
      - sub.raw        # Raw NV12 video stream (SHM) for zero-copy (sub publishes raw frames; main is H264-only — subscribe() on main hangs)

    # AI Inference permissions
    inference:
      models:
        - hailo_yolov8n_384_640  # YOLOv8n person-detection HEF (same model as occupancy-monitor)
      max_qps: 30
      max_concurrent: 2
      allow_register_model: false

    # Event bus permissions
    events:
      publish:
        - app/person-detection/*
        - alerts/detection
      subscribe:
        - system/*
        - model/*/detections

    # Device control (optional - for联动灯控)
    device:
      light: true
      ir_cut: true

    # Network mode
    network:
      mode: isolated

  # Environment variables
  env:
    - name: DETECTION_THRESHOLD
      value: "0.7"
    - name: ALERT_COOLDOWN_SECONDS
      value: "5"
    - name: LOG_LEVEL
      value: "INFO"

  # Volume mounts
  volumes:
    - host: /data/aipc/data/person-detection
      container: /app/data
      readonly: false
    - host: /data/aipc/logs/person-detection
      container: /app/logs
      readonly: false

  # Startup configuration
  autostart: false
  restart_policy: on-failure
  restart_max_retries: 3

  # Health check
  healthcheck:
    enabled: true
    interval: 30s
    timeout: 5s
    retries: 3
