
用于处理和训练面部识别图像的统一UI和API。
目前有许多优秀的开源面部识别软件,但它们的运行方式各不相同。Double Take的创建旨在抽象这些检测服务的复杂性,将其整合为易于使用的UI和API。
订阅Frigate的MQTT主题并处理图像进行分析。
yamlmqtt: host: localhost # MQTT主机地址 frigate: url: http://localhost:5000 # Frigate API地址
当frigate/events主题更新时,API开始处理来自Frigate API的snapshot.jpg和latest.jpg图像。这些图像从API传递到配置的检测器,直到找到满足配置要求的匹配项。为提高匹配几率,图像处理将重复进行,直到达到重试次数上限或找到匹配项。
当frigate/+/person/snapshot主题更新时,API将使用配置的检测器处理该图像。建议在Frigate摄像头配置中增加MQTT快照大小:
yamlcameras: front-door: # 摄像头名称 mqtt: timestamp: False # 不显示时间戳 bounding_box: False # 不显示边界框 crop: True # 裁剪图像 quality: 100 # 图像质量 height: 500 # 图像高度
如果找到匹配项,图像将保存到/.storage/matches/<文件名>。
处理图像时触发自动化/通知。
如果Home Assistant中配置了MQTT集成,将自动创建传感器。
通知自动化
此通知适用于匹配和未知结果。消息可使用实体的任何属性自定义:
yamlalias: 发送通知 # 自动化名称 trigger: - platform: state # 状态变化触发 entity_id: sensor.double_take_david # 匹配到"david"的传感器 - platform: state entity_id: sensor.double_take_unknown # 未知人员传感器 condition: - condition: template # 模板条件 value_template: '{{ trigger.to_state.state != trigger.from_state.state }}' # 状态实际变化时触发 action: - service: notify.mobile_app # 调用通知服务 data: message: |- # 通知消息 {% if trigger.to_state.attributes.match is defined %} {{trigger.to_state.attributes.friendly_name}} 在{{trigger.to_state.state}}附近,可信度{{trigger.to_state.attributes.match.confidence}}%,由{{trigger.to_state.attributes.match.detector}}:{{trigger.to_state.attributes.match.type}}检测,尝试{{trigger.to_state.attributes.attempts}}次,耗时{{trigger.to_state.attributes.duration}}秒 {% elif trigger.to_state.attributes.unknown is defined %} 未知人员在{{trigger.to_state.state}}附近,可信度{{trigger.to_state.attributes.unknown.confidence}}%,由{{trigger.to_state.attributes.unknown.detector}}:{{trigger.to_state.attributes.unknown.type}}检测,尝试{{trigger.to_state.attributes.attempts}}次,耗时{{trigger.to_state.attributes.duration}}秒 {% endif %} data: attachment: # 附加图像 url: |- {% if trigger.to_state.attributes.match is defined %} http://localhost:3000/api/storage/matches/{{trigger.to_state.attributes.match.filename}}?box=true&token={{trigger.to_state.attributes.token}} {% elif trigger.to_state.attributes.unknown is defined %} http://localhost:3000/api/storage/matches/{{trigger.to_state.attributes.unknown.filename}}?box=true&token={{trigger.to_state.attributes.token}} {% endif %} actions: # 通知操作 - action: URI # URI操作 title: 查看图像 # 操作标题 uri: |- # 图像URL {% if trigger.to_state.attributes.match is defined %} http://localhost:3000/api/storage/matches/{{trigger.to_state.attributes.match.filename}}?box=true&token={{trigger.to_state.attributes.token}} {% elif trigger.to_state.attributes.unknown is defined %} http://localhost:3000/api/storage/matches/{{trigger.to_state.attributes.unknown.filename}}?box=true&token={{trigger.to_state.attributes.token}} {% endif %} mode: parallel # 并行模式 max: 10 # 最大并行数
yamlnotify: gotify: url: http://localhost:8080 # Gotify服务地址 token: # Gotify访问令牌
匹配图像保存到/.storage/matches,可通过http://localhost:3000/api/storage/matches/<文件名>访问。
训练图像保存到/.storage/train,可通过http://localhost:3000/api/storage/train/<姓名>/<文件名>访问。
最新图像保存到/.storage/latest,可通过http://localhost:3000/api/storage/latest/<姓名|摄像头>.jpg访问。
| 查询参数 | 描述 | 默认值 |
|---|---|---|
box | 在面部周围显示边界框 | false |
token | 访问令牌 | - |
UI可通过http://localhost:3000访问:
//train/config/tokens(若启用认证)启用认证可密码保护UI。若在反向代理后运行并暴露到互联网,建议启用:
yamlauth: true # 启用认证
API文档可在Postman查看。
yamlversion: '3.7' # Compose版本 volumes: double-take: # 数据卷,用于持久化存储 services: double-take: container_name: double-take # 容器名称 image: jakowenko/double-take # 镜像名称 restart: unless-stopped # 重启策略:除非手动停止 volumes: - double-take:/.storage # 挂载数据卷到容器内存储目录 ports: - 3000:3000 # 端口映射:主机3000端口映射到容器3000端口
可配置选项保存到/.storage/config/config.yml,可通过UI(http://localhost:3000/config)编辑。默认值无需在配置中指定,除非需要覆盖。
authyaml# 启用UI和API认证(默认值如下) auth: false # 默认为false(不启用)
tokenyaml# 若启用认证 # API响应和MQTT主题中访问令牌的有效期(默认值如下) # 以秒为单位或描述时间跨度的字符串(zeit/ms格式) # https://github.com/vercel/ms token: image: 24h # 图像访问令牌有效期24小时
mqttyaml# 启用MQTT订阅和发布(默认值如下) mqtt: host: # MQTT主机地址(必填) username: # MQTT用户名(可选) password: # MQTT密码(可选) client_id: # MQTT客户端ID(可选) topics: # 订阅Frigate消息的MQTT主题 frigate: frigate/events # 订阅Home Assistant发现的MQTT主题 homeassistant: homeassistant # 按名称发布匹配结果的MQTT主题 matches: double-take/matches # 按摄像头名称发布匹配结果的MQTT主题 cameras: double-take/cameras
detectyaml# 全局检测设置(默认值如下) detect: match: save: true # 保存匹配图像 # 在API结果和MQTT消息中包含base64编码字符串 # 选项:true(包含完整图像), false(不包含), box(仅包含边界框区域) base64: false confidence: 60 # 视为匹配的最小可信度(%) purge: 168 # 匹配图像保留时间(小时),超时自动删除 min_area: 10000 # 视为匹配的最小面部区域(像素) unknown: save: true # 保存未知人员图像 # 在API结果和MQTT消息中包含base64编码字符串 # 选项:true, false, box base64: false confidence: 40 # 分类为未知人员的最小可信度(%) purge: 8 # 未知人员图像保留时间(小时) min_area: 0 # 保留未知结果的最小面部区域(像素)
frigateyaml# Frigate设置(默认值如下) frigate: url: # Frigate API地址(必填) # 是否将匹配结果作为子标签更新到Frigate # 注意:需要Frigate 0.11.0+版本 update_sub_labels: false # 找到匹配项后停止处理循环 # 若设为false,将处理所有图像尝试后确定最佳匹配 stop_on_match: true # 允许进行面部识别的对象标签 labels: - person # 仅处理"person"(人员)标签的对象 attempts: # Double Take请求Frigate latest.jpg进行面部识别的次数 latest: 10 # Double Take请求Frigate snapshot.jpg进行面部识别的次数 snapshot: 10 # 处理来自frigate/+/person/snapshot主题的Frigate图像 mqtt: true # 每次检测循环之间的延迟(秒) delay: 0 image: # 用于面部识别的Frigate图像高度 height: 500 # 仅处理特定摄像头的图像 cameras: # - front-door # 示例:前门摄像头 # - garage # 示例:车库摄像头 # 仅处理特定区域的图像 zones: # - camera: garage # 摄像头名称 # zone: driveway # 区域名称 # 按摄像头覆盖Frigate尝试次数和图像设置 events: # front-door: # 摄像头名称 # attempts: # # 请求latest.jpg的次数 # latest: 5 # # 请求snapshot.jpg的次数 # snapshot: 5 # # 处理来自frigate/<摄像头名>/person/snapshot主题的图像 # mqtt: false # # 检测循环延迟(秒) # delay: 1 # image: # # 面部识别图像高度(仅使用默认latest.jpg和snapshot.jpg时) # height: 1000 # # 替代latest.jpg的自定义图像URL # latest: http://camera-url.com/image.jpg # # 替代snapshot.jpg的自定义图像URL # snapshot: http://camera-url.com/image.jpg
camerasyaml# 摄像头设置(默认值如下) cameras: front-door: # 摄像头名称 # 处理图像前应用掩码 # masks: # # 定义区域多边形的x,y坐标列表 # coordinates: # - 1920,0,1920,328,1638,305,1646,0 # # 在最终保存的图像上显示掩码(调试用) # visible: false # # 用于调整掩码大小的摄像头流尺寸 # size: 1920x1080 # 按摄像头覆盖全局检测设置 # detect: # match: # save: true # 保存匹配图像 # base64: false # 不包含base64编码 # confidence: 60 # 匹配可信度阈值 # min_area: 10000 # 最小面部区域 # unknown: # save: true # 保存未知图像 # base64: false # 不包含base64编码 # confidence: 40 # 未知可信度阈值 # min_area: 0 # 最小区域 # snapshot: # # 处理任何JPEG编码的MQTT主题图像进行面部识别 # topic: # # 处理任何HTTP图像进行面部识别 # url:
detectorsyaml# 检测器设置(默认值如下) detectors: compreface: url: # CompreFace服务地址(必填) key: # 识别API密钥(必填) timeout: 15 # 请求超时时间(秒) # 识别面部的最小可信度(0.0-1.0) det_prob_threshold: 0.8 # 处理前要求OpenCV检测到面部 opencv_face_required: false # 面部插件的逗号分隔标识符 # https://github.com/exadel-inc/CompreFace/blob/master/docs/Face-services-and-plugins.md) # face_plugins: mask,gender,age # 示例:口罩、性别、年龄插件 # 仅处理特定摄像头图像,若省略则处理所有摄像头 # cameras: # - front-door # - garage rekognition: aws_access_key_id: !secret aws_access_key_id # AWS访问密钥ID(通过secret引用) aws_secret_access_key: !secret aws_secret_access_key # AWS密钥(通过secret引用) aws_region: # AWS区域(必填) collection_id: double-take # 人脸集合ID # 处理前要求OpenCV检测到面部 opencv_face_required: true # 仅处理特定摄像头图像 # cameras: # - front-door # - garage deepstack: url: # DeepStack服务地址(必填) key: # API密钥(必填) timeout: 15 # 请求超时时间(秒) # 处理前要求OpenCV检测到面部 opencv_face_required: false # 仅处理特定摄像头图像 # cameras: # - front-door # - garage facebox: url: # Facebox服务地址(必填) timeout: 1

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务