图像处理

图像处理使 Home Assistant 能够处理来自 摄像头 的图像。仅支持摄像头实体作为来源。

Note

构建模块集成

这个 图像处理 是一个构建模块集成,无法直接添加到你的 Home Assistant 中,但可以被其他集成使用和提供。

构建模块集成不同于典型的与设备或服务连接的集成。相反,其他将设备或服务集成到 Home Assistant 中的集成使用这个 图像处理 构建模块来提供实体、服务和其他你可以在自动化或仪表板中使用的功能。

如果你的某个集成具有这个构建模块,这个页面记录了 图像处理 构建模块所提供的功能。

图像处理实体的状态

对于人脸识别应用,图像处理实体的状态可以是检测到的人名或检测到的运动状态。

此外,实体可以具有以下状态:

  • 不可用:实体当前不可用。
  • 未知:状态尚未确定。

ALPR

ALPR 实体具有一个车辆计数属性 vehicles,所有找到的车牌存储在 plates 属性中。

在 OpenALPR 找到新的车牌后,将触发 found_plate 事件。

# 示例 configuration.yaml 自动化条目
automation:
- alias: "打开车库门"
  triggers:
    - trigger: event
      event_type: image_processing.found_plate
      event_data:
        entity_id: openalpr.camera_garage_1
        plate: BE2183423
...

以下事件属性将会存在(基于平台):entity_idplateconfidence

人脸

人脸实体具有一个人脸计数属性 total_faces,所有人脸数据存储在 faces 属性中。

在 Face 实体找到人脸后,将触发 detect_face 事件。

# 示例 configuration.yaml 自动化条目
automation:
- alias: "门口有已知的人"
  triggers:
    - trigger: event
      event_type: image_processing.detect_face
      event_data:
        entity_id: image_processing.door
        name: "汉斯·迈尔"
...

以下事件属性将会存在(基于平台):entity_idnameconfidenceagegendermotionglasses

scan_interval 和优化资源

图像处理集成以 scan_interval 指定的固定周期处理来自摄像头的图像。如果摄像头上的图像没有变化,则会导致过度处理,因为默认的 scan_interval 是 10 秒。您可以通过在配置中添加 scan_interval: 10000(将间隔设置为 10,000 秒)来覆盖此设置,并在实际想要进行处理时调用 image_processing.scan 操作。

# 示例 configuration.yaml
sensor:
- platform: _AN_IMAGE_PROCESSING_PLATFORM_
  scan_interval: 10000
...
automation:
- alias: "在检测到运动时扫描人脸"
  triggers:
    - trigger: state
      entity_id: sensor.door_motion_sensor
      to: "on"
  actions:
    - action: image_processing.scan
      target:
        entity_id: image_processing.door
...