Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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
You can’t perform that action at this time.