Double Take
repository·master·Indexed 23 days ago
https://github.com/jakowenko/double-takeA unified UI and API for processing and training images for facial recognition. Double Take acts as a management layer that abstracts detection engines such as CompreFace, Amazon Rekognition, Deepstack, and Facebox, integrating them with NVRs like Frigate and automation platforms like Home Assistant. It provides a REST API, MQTT publishing for match results, and a web interface for managing training images and configuration.
What's inside double-take
- Double Take is a unified UI and API designed to abstract the complexities of various facial recognition detection services. It allows you to process and train images for facial recognition by combining multiple detectors into a single workflow. It can process images from NVRs (like Frigate), publish results via MQTT, and provide a REST API for integration with other applications.
Store secrets in Home Assistant
masterIf you are using a Home Assistant Add-on, you can use the Home Assistant
secrets.yamlfile to store sensitive information like MQTT passwords or API keys using the!secrettag.Example usage in
config.yml:mqtt: password: !secret mqtt_password detectors: compreface: key: !secret compreface_keyCorresponding entry in
secrets.yaml:mqtt_password: <password> compreface_key: <api-key>mqtt: host: localhost username: mqtt password: !secret mqtt_password detectors: compreface: url: localhost:8000 key: !secret compreface_keyInstall Double Take via Docker Compose
masterYou can deploy Double Take using Docker Compose. The following configuration sets up the service with a persistent volume for storage and exposes the UI/API on port 3000.
version: '3.7' volumes: double-take: services: double-take: container_name: double-take image: jakowenko/double-take restart: unless-stopped volumes: - double-take:/.storage ports: - 3000:3000Run Double Take locally for development
masterTo develop on Double Take, you can run the services using Docker containers.
Available Services:
- UI:
localhost:8080 - API:
localhost:3000 - MQTT:
localhost:1883
Commands:
- Start development containers:
./.develop/docker up - Remove development containers:
./.develop/docker down - Build local image:
./.develop/build
# start development containers ./.develop/docker up # remove development containers ./.develop/docker down- UI:
Configure Double Take via config.yml
masterDouble Take configuration is stored in
/.storage/config/config.yml. You can edit these settings directly in the file or via the web UI athttp://localhost:3000/config.Note: You only need to specify values that differ from the default settings.
Configure Gotify notification service
masterYou can use Gotify to receive notifications from Double Take by configuring thenotify.gotifysection in your configuration.Configure camera masks and overrides
masterUse the
camerasblock to define settings for specific cameras. You can apply masks to ignore certain areas or override global detection settings for that specific camera.Masks:
coordinates: A list ofx,ycoordinates defining the polygon.visible: Iftrue, shows the mask on the final saved image (useful for debugging).size: The camera stream size used for resizing masks (e.g.,1920x1080).
cameras: front-door: # masks: # coordinates: # - 1920,0,1920,328,1638,305,1646,0 # visible: false # size: 1920x1080 # detect: # match: # save: true # base64: false # confidence: 60 # min_area: 10000 # unknown: # save: true # base64: false # confidence: 40 # min_area: 0 # snapshot: # topic: # url:Configure detectors (CompreFace, Rekognition, Deepstack, Facebox)
masterThe
detectorsblock allows you to configure various facial recognition engines. Each detector has specific requirements.CompreFace
url: CompreFace URL.key: Recognition API key.timeout: Request timeout in seconds.det_prob_threshold: Minimum confidence (0.0 to 1.0) that a recognized face is actually a face.opencv_face_required: Whether to require OpenCV to find a face first.face_plugins: Comma-separated slugs (e.g.,mask,gender,age).cameras: List of cameras to process with this detector.
AWS Rekognition
aws_access_key_id: AWS access key.aws_secret_access_key: AWS secret key.aws_region: AWS region.collection_id: Rekognition collection ID.opencv_face_required: Whether to require OpenCV to find a face first.cameras: List of cameras to process.
Deepstack / Facebox
url: Detector URL.key: API key.timeout: Request timeout in seconds.opencv_face_required: Whether to require OpenCV to find a face first.cameras: List of cameras to process.
detectors: compreface: url: "" key: "" timeout: 15 det_prob_threshold: 0.8 opencv_face_required: false # face_plugins: mask,gender,age # cameras: # - front-door rekognition: aws_access_key_id: !secret aws_access_key_id aws_secret_access_key: !secret aws_secret_access_key aws_region: "" collection_id: double-take opencv_face_required: true # cameras: # - front-door deepstack: url: "" key: "" timeout: 15 opencv_face_required: false # cameras: # - front-door facebox: url: "" key: "" timeout: 15 opencv_face_required: false # cameras: # - front-doorConfigure MQTT settings
masterUse the
mqttblock to enable subscribing to and publishing to MQTT topics. This is used for Frigate event subscriptions, Home Assistant discovery, and publishing matches.Key configuration options include:
host,username,password,client_idtls: For secure connections usingcert,key, andcafiles.topics:frigate: Topic for Frigate message subscription (default:frigate/events).homeassistant: Topic for Home Assistant discovery (default:homeassistant).matches: Topic where matches are published by name (default:double-take/matches).cameras: Topic where matches are published by camera name (default:double-take/cameras).
Configure MQTT publishing
masterDouble Take publishes results to specific MQTT topics. You must configure the
mqtt.hostto enable this.Key topics include:
double-take/matches/<name>: Publishes match details for a specific subject.double-take/cameras/<camera>: Publishes camera-specific event data.double-take/cameras/<camera>/person: Publishes the number of persons detected (resets to 0 after 30 seconds).double-take/errors: Publishes API errors.
mqtt: host: localhostConfigure Frigate integration
masterThe
frigateblock manages how Double Take interacts with Frigate for facial recognition.Key options:
url: The Frigate URL.update_sub_labels: Iftrue, sends matches back to Frigate as sub-labels (requires Frigate 0.11.0+).stop_on_match: Iftrue, stops processing once a match is found.min_area: Minimum area to ignore small detections.labels: List of object labels allowed for recognition (e.g.,person).attempts:latest: Number of times to requestlatest.jpg.snapshot: Number of times to requestsnapshot.jpg.mqtt: Boolean to process images fromfrigate/+/person/snapshottopics.delay: Delay in seconds between detection loops.
image.height: Height of the Frigate image passed for recognition.cameras: List of specific cameras to process.zones: List of specific zones to process.events: Per-camera overrides forattemptsandimagesettings.
frigate: url: "" update_sub_labels: false stop_on_match: true min_area: 0 labels: - person attempts: latest: 10 snapshot: 10 mqtt: true delay: 0 image: height: 500 cameras: # - front-door zones: # - camera: garage # zone: driveway events: # front-door: # attempts: # latest: 5 # snapshot: 5 # mqtt: false # delay: 1 # image: # height: 1000 # latest: http://camera-url.com/image.jpg # snapshot: http://camera-url.com/image.jpgConfigure Gotify notifications
masterThe
notify.gotifyblock allows you to send notifications via Gotify.url: Gotify server URL.token: Gotify application token.priority: Notification priority (e.g.,5).cameras: List of specific cameras to notify from.zones: List of specific zones to notify from (e.g.,camera: garage,zone: driveway).
notify: gotify: url: "" token: "" priority: 5 # cameras: # - front-door # zones: # - camera: garage # zone: driveway