This app works with Frigate and Double-Take to detect if...
If only condition 1 is met, an MQTT message is published indicating the name of the person detected. If both conditions are detected, the name of the gesture is also published.
The topic published to is from the config file plus the name of the camera, e.g.:
gestures/<cameraname>
The payload of the publications is JSON in this format:
{'person': '<name from double-take>', 'gesture': '<gesture name from gesture model>'}
When there are no recognized people, an empty name and gesture are published:
{'person': '', 'gesture': ''}
Gesture recognition is done by first detecting hands and hand positions using MediaPipe. The hand position data is then fed into a neural net model to determine the gesture.
I swiped the model and some code for using the model from https://github.com/kinivi/tello-gesture-control as I really didn't want to train my own model and copying code is easier than writing code. As such the gestures are oriented to controlling a drone. But, why shouldn't I Land my garage door?
Take a look at supportedgestures.jpg to see the supported gestures.
To make this work, you'll need...
If you aren't using Docker, check the requirements.txt file for the libraries that you need.
Configuration is via config.yml. This file is expected to be at /config/config.yml. Here you can set...
You can build this app into a docker container with the included Dockerfile and this command:
docker build -t gesturesensor .
If you are inclined to use docker-compose you can use the included docker-compose.yml file as a starting point. It will allow you to point at the location of your config file.
If you use docker run, you'll need to set up a volume to point your config file at /config/config.yml
For my garage camera, I have integrated this with Home Assistant using an mqtt sensor. I configured this sensor in configuration.yaml like so:
mqtt:
sensor:
- name: "Garage Gesture"
unique_id: garage_gestures
state_topic: "gestures/garage"
availability:
- topic: "gestures/availability"
value_template: "{{ value_json.gesture }}"
json_attributes_topic: "gestures/garage"
json_attributes_template: "{{ value }}" tojson }}"
This gives you a sensor with a value of the current gesture, and attributes of the current person and the current gesture. I then set up an automation that reacts to either of the attributes changing, and takes action if the current person and gesture match specific values.