Skip to content

Instantly share code, notes, and snippets.

@erogol
Last active May 25, 2017 20:25
Show Gist options
  • Save erogol/c1807694d65ddfdf327b4666a2a4e0e9 to your computer and use it in GitHub Desktop.
Save erogol/c1807694d65ddfdf327b4666a2a4e0e9 to your computer and use it in GitHub Desktop.
###################################################################################
# LOGIC
###################################################################################
# check to see if the room is occupied
if text == "Occupied":
# save occupied frame
cv2.imwrite("/tmp/talkingraspi_{}.jpg".format(motionCounter), frame);
# check to see if enough time has passed between uploads
if (timestamp - lastUploaded).seconds >= conf["min_upload_seconds"]:
# increment the motion counter
motionCounter += 1;
# check to see if the number of frames with consistent motion is
# high enough
if motionCounter >= int(conf["min_motion_frames"]):
# send an email if enabled
if conf["use_email"]:
print("[INFO] Sending an alert email!!!")
send_email(conf)
print("[INFO] waiting {} seconds...".format(conf["camera_warmup_time"]))
time.sleep(conf["camera_warmup_time"])
print("[INFO] running")
# update the last uploaded timestamp and reset the motion
# counter
lastUploaded = timestamp
motionCounter = 0
# otherwise, the room is not occupied
else:
motionCounter = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment