Last active
October 1, 2019 09:50
-
-
Save blacklight/d285554f8a6c4b23db6b037f7222b8a6 to your computer and use it in GitHub Desktop.
Example platypush configuration to take snapshots from a thermal camera and use an existing machine learning model to predict the presence of people and run custom actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cron.ThermalCameraSnapshotCron: | |
cron_expression: '* * * * *' | |
actions: | |
# Retrieve the existing ROOM_PRESENCE variable | |
# from the internal db if it exists | |
- | |
action: variable.get | |
args: | |
name: ROOM_PRESENCE | |
# Copy it to another variable in memory | |
- | |
action: variable.mset | |
args: | |
PREV_ROOM_PRESENCE: ${ROOM_PRESENCE} | |
# Capture an image to a tmp file | |
- | |
action: camera.ir.mlx90640.capture | |
args: | |
output_file: "/tmp/ir.jpg" | |
grayscale: true | |
# Use the ml.cv module to do predictions using | |
# the model you have previously trained | |
- | |
action: ml.cv.predict | |
args: | |
model_file: ~/models/ir.pb | |
img: /tmp/ir.jpg | |
classes: | |
- negative | |
- positive | |
# Store the output of the previous command on db | |
- | |
action: variable.set | |
args: | |
ROOM_PRESENCE: ${output} | |
- if ${ROOM_PRESENCE == 'negative' and PREV_ROOM_PRESENCE != 'negative'}: | |
- action: procedure.no_people_detected | |
- if ${ROOM_PRESENCE_LABEL == 'positive' and PREV_ROOM_PRESENCE != 'positive'}: | |
- action: procedure.people_detected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment