Last active
May 25, 2017 20:25
-
-
Save erogol/c1807694d65ddfdf327b4666a2a4e0e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
################################################################################### | |
# 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