add the files. Up and running

master
acastro 6 years ago
parent 04490a36c7
commit b99136a813

9
.gitignore vendored

@ -0,0 +1,9 @@
announcements_position.txt
Audio_recordings/**
**.jpg
**.pyc
LED-strips/**
__pycache__/**
trash/**

@ -0,0 +1,131 @@
#!/usr/bin/env python
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI
import time
# count of pixels:
PIXEL_COUNT = 19
# specify a hardware SPI connection on /dev/spidev0.0:
SPI_PORT = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(PIXEL_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
# colors of each character
color_guru = [146, 200, 0] # purple
color_pirate = [255, 0, 200] # yellow
color_announcer= [0, 100, 200] # aqua blue
def leds_color_intensity(color, intensity):
# color: a list of 3 rgb components 0 to 255
# intensity: between 0 and 1
# pixN: number of pixels
r = color[0]
g = color[1]
b = color[2]
for i in range(PIXEL_COUNT):
pixels.set_pixel_rgb(i,
int(r*intensity),
int(g*intensity),
int(b*intensity) ) # Set the RGB color (0-255) of pixel i
pixels.show()
# LEDs grow and shrink
def leds_color_length(color, intensity):
# color: a list of 3 rgb components 0 to 255
# intensity: between 0 and 1
# pixN: number of pixels
r = color[0]
g = color[1]
b = color[2]
led_length = int(PIXEL_COUNT * intensity)
for i in range(led_length):
pixels.set_pixel_rgb(i,
int(r),
int(g),
int(b) ) # Set the RGB color (0-255) of pixel i
time.sleep(0.01)
pixels.show()
pixels.clear()
# LEDS for pirate
def leds_pirate_blink(color):
# color: a list of 3 rgb components 0 to 255
# pixN: number of pixels
r = color[0]
g = color[1]
b = color[2]
while True:
pixels.clear()
pixels.show()
time.sleep(0.02)
for i in range(PIXEL_COUNT):
pixels.set_pixel_rgb(i,
int(r),
int(g),
int(b) ) # Set the RGB color (0-255) of pixel i
pixels.show()
time.sleep(0.01)
def leds_pirate_circle(color):
# color: a list of 3 rgb components 0 to 255
# pixN: number of pixels
r = color[0]
g = color[1]
b = color[2]
while True:
for i in range(PIXEL_COUNT):
pixels.set_pixel_rgb(i,
int(r),
int(g),
int(b) ) # Set the RGB color (0-255) of pixel i
pixels.show()
time.sleep(0.01)
pixels.clear()
pixels.show()
time.sleep(0.3)
def leds_pirate_bounce(color):
# color: a list of 3 rgb components 0 to 255
# pixN: number of pixels
r = color[0]
g = color[1]
b = color[2]
leds = list(range(PIXEL_COUNT))+ (list(range(PIXEL_COUNT))[::-1])
n = 0
while True:
n = n + 1
for i in leds:
pixels.set_pixel_rgb(i,
int(r),
int(g),
int(b) ) # Set the RGB color (0-255) of pixel i
pixels.show()
time.sleep(0.01)
pixels.clear()
pixels.show()
time.sleep(0.3)
if n > 3:
break
pixels.clear() # Clear all the pixels to turn them off.

@ -0,0 +1,18 @@
## IRIS
* scripts locations /var/www/html/lifeHackAgent
* audio recording script /var/www/html/lifeHackAgent/Audio_recordings
## test system:
* `./motion.sh`
## cronjob:
runs announcements.py
# systemd service file
* run on boot
* location: /lib/systemd/system/lifehack.service
* status: sudo systemctl ststatus lifehack.service
* start: sudo systemctl start lifehack.service
* stop: sudo systemctl stop lifehack.service

@ -1,7 +1,21 @@
#!/usr/bin/env python3 #!/usr/bin/env python
import json, random, os import json, random, os, subprocess
from pprint import pprint from pprint import pprint
from time import sleep from time import sleep
from LEDfunctions import *
def vu_2_leds(color):
while True:
data = play_process.stdout.readline()
if not data:
pixels.clear() # make LEDs dark
pixels.show()
break
data = data.rstrip()
if data.endswith("%"):
vu = float(data[:-1][-3:])/100 # 0-100
leds_color_intensity(color, vu)
# open announcer.json files # open announcer.json files
pwd = os.path.dirname( os.path.realpath(__file__) ) + "/" pwd = os.path.dirname( os.path.realpath(__file__) ) + "/"
@ -9,18 +23,38 @@ announcer_f = open(pwd + "announcer.json", "r").read()
announcer = json.loads(announcer_f) announcer = json.loads(announcer_f)
# print(announcer) # print(announcer)
position_file = open(pwd + "announcements_position.txt", "r")
#choosing next message in sequence
msg_sf_len=len( announcer['messages'] )
position= (int( position_file.read() ) ) + 1
if position == msg_sf_len:
position = 0
print(position)
position_file = open(pwd + "announcements_position.txt", "w")
position_file.write(str(position))
position_file.close()
print ("position", position)
# ANNOUNCER PART # ANNOUNCER PART
# msg = random.choice( announcer['messages'] ) #chooing a random annoncement. # msg = random.choice( announcer['messages'] ) #choosing a random intro.
sound_dir = pwd + "Audio_recordings/Announcements/" sound_dir = pwd + "Audio_recordings/Announcements/"
intro_sf = sound_dir + random.choice( announcer['introductions'] ) intro_sf = sound_dir + random.choice( announcer['introductions'] )
msg_sf = sound_dir + random.choice( announcer['messages'] ) msg_sf = sound_dir + announcer['messages'][position]
print(intro_sf, msg_sf) print(intro_sf, msg_sf)
#play audio #play audio
print(intro_sf)
#play_process = subprocess.Popen(["aplay", intro_sf, "-f", "cd", "--vumeter=mono"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
os.system('play -q "{}" gain 5'.format(intro_sf) ) os.system('play -q "{}" gain 5'.format(intro_sf) )
os.system('play -q "{}" gain 10'.format(msg_sf) ) play_process = subprocess.Popen(["aplay", msg_sf, "-f", "cd", "--vumeter=mono"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
vu_2_leds(color_announcer)
#os.system('play -q "{}" gain 1'.format(msg_sf) )

@ -3,8 +3,47 @@
"introductions" : ["jingle_01.wav", "jingle_02.wav", "jingle_03.wav", "jingle_04.wav", "jingle_05.wav", "jingle_06.wav"], "introductions" : ["jingle_01.wav", "jingle_02.wav", "jingle_03.wav", "jingle_04.wav", "jingle_05.wav", "jingle_06.wav"],
"messages" : [ "messages" : [
"announcement_msg_01.wav", "announcer_msg_01.wav",
"announcement_msg_02.wav" "announcer_msg_02.wav",
"announcer_msg_03.wav",
"announcer_msg_04.wav",
"announcer_msg_05.wav",
"announcer_msg_06.wav",
"announcer_msg_07.wav",
"announcer_msg_08.wav",
"announcer_msg_09.wav",
"announcer_msg_10.wav",
"announcer_msg_11.wav",
"announcer_msg_12.wav",
"announcer_msg_13.wav",
"announcer_msg_14.wav",
"announcer_msg_15.wav",
"announcer_msg_16.wav",
"announcer_msg_17.wav",
"announcer_msg_18.wav",
"announcer_msg_19.wav",
"announcer_msg_20.wav",
"announcer_msg_21.wav",
"announcer_msg_22.wav",
"announcer_msg_23.wav",
"announcer_msg_24.wav",
"announcer_msg_25.wav",
"announcer_msg_26.wav",
"announcer_msg_27.wav",
"announcer_msg_28.wav",
"announcer_msg_29.wav",
"announcer_msg_30.wav",
"announcer_msg_31.wav",
"announcer_msg_32.wav",
"announcer_msg_33.wav",
"announcer_msg_34.wav",
"announcer_msg_35.wav",
"announcer_msg_36.wav",
"announcer_msg_37.wav",
"announcer_msg_38.wav",
"announcer_msg_39.wav",
"announcer_msg_40.wav"
] ]

@ -0,0 +1,87 @@
# import the necessary packages
import imutils
from imutils.video import VideoStream
import argparse
import datetime
import time, sys
from time import sleep
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-a", "--min-area", type=int, default=5000, help="minimum area size")
args = vars(ap.parse_args())
# using picamera as default
vs = VideoStream(usePiCamera=True).start()
sleep(2.0)
# initialize the first frame in the video stream
firstFrame = None
occupied = False
# loop over the frames of the video
while True:
# grab the current frame and initialize the occupied/unoccupied
# text
frame = vs.read()
frame = frame if args.get("video", None) is None else frame[1]
text = "Unoccupied"
# if the frame could not be grabbed, then we have reached the end
# of the video
if frame is None:
break
# resize the frame, convert it to grayscale, and blur it
frame = imutils.resize(frame, width=500)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (210, 210), 0)
# if the first frame is None, initialize it
if firstFrame is None:
firstFrame = gray
continue
# compute the absolute difference between the current frame and
# first frame
frameDelta = cv2.absdiff(firstFrame, gray)
thresh = cv2.threshold(frameDelta, 25, 255, cv2.THRESH_BINARY)[1]
# dilate the thresholded image to fill in holes, then find contours
# on thresholded image
thresh = cv2.dilate(thresh, None, iterations=2)
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
# loop over the contours
for c in cnts:
# if the contour is too small, ignore it
if cv2.contourArea(c) < args["min_area"]:
continue
# compute the bounding box for the contour, draw it on the frame,
# and update the text
(x, y, w, h) = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
text = "Occupied"
if not occupied:
occupied = True
print ('occupied')
sys.exit()
if occupied and text == "Unoccupied":
occupied = False
print ("Unoccupied")
# show the frame and record if the user presses a key
# cv2.imshow("Security Feed", frame)
cv2.imwrite('normal.jpg', frame)
#cv2.imshow("Thresh", thresh)
cv2.imwrite('thereshold.jpg', thresh)
#cv2.imshow("Frame Delta", frameDelta)
cv2.imwrite('Gaussianblur.jpg', frameDelta)
#key = cv2.waitKey(1) & 0xFF
# cleanup the camera and close any open windows
vs.stop() if args.get("video", None) is None else vs.release()
#cv2.destroyAllWindows()

@ -1,7 +1,29 @@
#!/usr/bin/env python3 #!/usr/bin/env python
import json, random, os import json, random, os, subprocess
from pprint import pprint from pprint import pprint
from time import sleep from time import sleep
from LEDfunctions import *
def vu_2_leds(color):
while True:
data = play_process.stdout.readline()
if not data:
pixels.clear() # make LEDs dark
pixels.show()
break
data = data.rstrip()
if data.endswith("%"):
vu = float(data[:-1][-3:])/100 # 0-100
leds_color_intensity(color, vu)
def leds_start_stop(color): # for pirate
while True:
data = play_process.stdout.readline()
data = data.rstrip()
print('data:',data)
print('process:', play_process.stdout.readline()) #_handle_exitstatus
leds_pirate_bounce(color_pirate)
# open json files # open json files
@ -21,7 +43,9 @@ intro = random.choice(oracle[part]['introductions'])
intro_txt = intro[0] intro_txt = intro[0]
intro_sound = sound_dir + intro[1] intro_sound = sound_dir + intro[1]
print('Intro:', intro_txt, intro_sound) print('Intro:', intro_txt, intro_sound)
os.system('play -q "{}" gain 10 chorus 0.7 0.9 100 0.5 5 2 -t'.format(intro_sound) ) play_process = subprocess.Popen(["aplay", intro_sound, "-f", "cd", "--vumeter=mono"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
vu_2_leds(color_guru)
# REBEL reply # REBEL reply
rebel_run = random.choice([True, False]) # shall the rebel enter?? rebel_run = random.choice([True, False]) # shall the rebel enter??
@ -31,6 +55,7 @@ if rebel_run is True:
rebel_sentence = rebel_reply.format(rebel_reply_snippet) rebel_sentence = rebel_reply.format(rebel_reply_snippet)
# play msg # play msg
for i in range( random.randint(1,4) ): for i in range( random.randint(1,4) ):
sleep( random.randint(1,3) ) sleep( random.randint(1,3) )
@ -38,12 +63,16 @@ for i in range( random.randint(1,4) ):
msg_txt = msg[0] msg_txt = msg[0]
msg_sound = sound_dir + msg[1] msg_sound = sound_dir + msg[1]
print('MSG:', msg_txt, msg_sound) print('MSG:', msg_txt, msg_sound)
os.system('play -q "{}" gain 10 chorus 0.7 0.9 100 0.5 5 2 -t '.format(msg_sound) ) play_process = subprocess.Popen(["aplay", msg_sound, "-f", "cd", "--vumeter=mono"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
vu_2_leds(color_guru)
# rebel text to speech # rebel text to speech
if rebel_run is True: if rebel_run is True:
print('rebel sentence:', rebel_sentence) print('rebel sentence:', rebel_sentence)
os.system('echo "{}" | espeak -ven+whisper -s 110'.format(rebel_sentence) ) #rebel_cmd = 'echo "{}" | espeak -ven+whisper -s 150'.format(rebel_sentence)
#os.system(rebel_cmd)
# TO DO
play_process = subprocess.Popen(["espeak", rebel_sentence, "-ven+whisper", "-s", "150"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
leds_pirate_bounce(color_pirate)
# leds_start_stop(color_pirate)

@ -17,20 +17,36 @@
"messages" : [ "messages" : [
["Life is life." , "repeat_msg_01.wav"], ["My mind is bursting with bright ideas, kind words, and happiness." , "repeat_msg_01.wav"],
["Bliss is to accept your flaws." , "repeat_msg_02.wav"], ["No person, place, or thing has any power over me, for I am the only thinker in my mind." , "repeat_msg_02.wav"],
["Life is full of possible solutions." , "repeat_msg_03.wav"], ["Every experience I have is perfect for my growth." , "repeat_msg_03.wav"],
["I'm only bored if I am boring." , "repeat_msg_04.wav"], ["I am a joyful breeze entering a room." , "repeat_msg_04.wav"],
["I am flawless. I woke up like this." , "repeat_msg_05.wav"], ["I feel safe in the rhythm and flow of ever-changing life." , "repeat_msg_05.wav"],
["I am what I think I am" , "repeat_msg_06.wav"], ["I am my own superhero." , "repeat_msg_06.wav"],
["Without mistakes there is no growth" , "repeat_msg_07.wav"], ["My body is healthy, and Im grateful." , "repeat_msg_07.wav"],
["I can not give up before even trying" , "repeat_msg_08.wav"], ["I choose not to criticize myself or others around me.", "repeat_msg_08.wav"],
["Ignorance is bliss" , "repeat_msg_09.wav"], ["I love myself fully, including the way I look." , "repeat_msg_09.wav"],
["I have what I have and I am happy with that" , "repeat_msg_10.wav"], ["Negative thoughts only have the power I allow them." , "repeat_msg_10.wav"],
["I will be productive today", "repeat_msg_11.wav"], ["Today I create a wonderful new day and a wonderful new future." , "repeat_msg_11.wav"],
["I am a good person" , "repeat_msg_12.wav"], ["Being miserable is a habit; being happy is a habit; the choice is mine." , "repeat_msg_12.wav"],
["Crying makes you feel good" , "repeat_msg_13.wav"], ["My financial prospect brings me joy." , "repeat_msg_13.wav"],
["Today is going to be a good day" , "repeat_msg_14.wav"] ["A problem is a chance for me to do my very best." , "repeat_msg_14.wav"],
["Dreams and goals are coming attractions in my life." , "repeat_msg_15.wav"],
["There is only one thing that makes a dream impossible to achieve: the fear of failure." , "repeat_msg_16.wav"],
["I will master distractions and keep my focus on my goals." , "repeat_msg_17.wav"],
["I turn towards my difficulties instead of trying to fix them instantly." , "repeat_msg_18.wav"],
["I am in charge of how I feel and today I am choosing happiness." , "repeat_msg_19.wav"],
["I have infinite patience when it comes to fulfilling my own destiny." , "repeat_msg_20.wav"],
["I am connected to an unlimited source of abundance." , "repeat_msg_21.wav"],
["Im an infinite being. The age of my body has no bearing on what I do and who I am." , "repeat_msg_22.wav"],
["I feel passionately about my life, and this passion fills me with excitement and energy." , "repeat_msg_23.wav"],
["Every crisis is an opportunity in disguise." , "repeat_msg_24.wav"],
["I bring something unique to the table by simply being me." , "repeat_msg_25.wav"],
["The tools I need to succeed are in my possession." , "repeat_msg_26.wav"],
["I use my failures as stepping stones." , "repeat_msg_27.wav"],
["The success of others will not make me jealous. My time will come." , "repeat_msg_28.wav"],
["A calm feeling spreads through my thoughts and actions." , "repeat_msg_29.wav"],
["Inner wisdom shines from within me as I grow." , "repeat_msg_30.wav"]
] ]
@ -45,7 +61,7 @@
["I want you to ask yourself:", "ask_intro_01.wav", "Asking myself"], ["I want you to ask yourself:", "ask_intro_01.wav", "Asking myself"],
["Consider this:", "ask_intro_02.wav", "Considering that"], ["Consider this:", "ask_intro_02.wav", "Considering that"],
["Deep inside, ask yourself:", "ask_intro_03.wav", "Asking myself"], ["Deep inside, ask yourself:", "ask_intro_03.wav", "Asking myself"],
["How often do you ask yourself:", "ask_intro_04.wav", "Oftenly asking myself"], ["How often do you ask yourself:", "ask_intro_04.wav", "Often asking myself"],
["Take your time to reflect on this:", "ask_intro_05.wav", "Reflecting on that"], ["Take your time to reflect on this:", "ask_intro_05.wav", "Reflecting on that"],
["Invite this into your daily thoughts:", "ask_intro_06.wav", "Controlling my daily thoughts"], ["Invite this into your daily thoughts:", "ask_intro_06.wav", "Controlling my daily thoughts"],
["Focus on this:", "ask_intro_07.wav", "Focusing on that"] ["Focus on this:", "ask_intro_07.wav", "Focusing on that"]
@ -54,24 +70,36 @@
"messages" : [ "messages" : [
["Are you working hard, or hardly working?" , "ask_msg_01.wav"], ["Are efficient solutions the ultimate goal?" , "ask_msg_01.wav"],
["Do you try to solve one problem at a time?" , "ask_msg_02.wav"], ["Do you try to solve one problem at a time?" , "ask_msg_02.wav"],
["How would you change things if you were the boss?" , "ask_msg_03.wav"], ["Are you conscious of your problems?" , "ask_msg_03.wav"],
["How much time did you spend on the internet today?" , "ask_msg_04.wav"], ["If happiness is a currency, how rich do you think you are?" , "ask_msg_04.wav"],
["Are efficient solutions the ultimate goal?" , "ask_msg_05.wav"], ["If there were no consequences, would you be afraid of mistakes?" , "ask_msg_05.wav"],
["How do you know if you've had a good day, or a bad one?" , "ask_msg_06.wav"], ["Are you doing what you truly want to do?" , "ask_msg_06.wav"],
["How much time do you make for yourself every day?" , "ask_msg_07.wav"], ["If the chance of failure and success was 50-50, would you still take a shot?" , "ask_msg_07.wav"],
["Why do we need to solve our problems?" , "ask_msg_08.wav"], ["What would you prefer? Stable but boring work, or interesting and demanding work?" , "ask_msg_08.wav"],
["What happens when you think with your hands?" , "ask_msg_09.wav"], ["If you had a time machine, would you abandon this era?" , "ask_msg_09.wav"],
["Are you conscious of your problems?" , "ask_msg_10.wav"], ["Are you convinced this is the best possible world?" , "ask_msg_10.wav"],
["Do you prefer that interesting things happen, or good things?" , "ask_msg_11.wav"], ["Which is worse, failing or not even trying?" , "ask_msg_11.wav"],
["Does the problem contain its own solution?" , "ask_msg_12.wav"], ["Is this insanity or just creativity?" , "ask_msg_12.wav"],
["Is utility always desired?" , "ask_msg_13.wav"], ["Why are you, you?" , "ask_msg_13.wav"],
["What makes you get up in the morning?" , "ask_msg_14.wav"], ["What are you most grateful for?" , "ask_msg_14.wav"],
["Would you rather be weird, or normal?" , "ask_msg_15.wav"], ["In what ways do you make your life better, more fulfilling, or meaningful?" , "ask_msg_15.wav"],
["How many people have you spoken with about your problems?" , "ask_msg_16.wav"], ["What empowering beliefs will help you achieve your goals?" , "ask_msg_16.wav"],
["Would you rather the job done quickly, or well?" , "ask_msg_17.wav"], ["What is your purpose in life? Why do you exist? What is your mission?" , "ask_msg_17.wav"],
["How can I improve my life?" , "ask_msg_18.wav"] ["Is there a joyful marriage between your profession and your passion?" , "ask_msg_18.wav"],
["What qualities do you embody?" , "ask_msg_19.wav"],
["We learn from our mistakes, yet were always so afraid to make them. Where is this true for you?" , "ask_msg_20.wav"],
["Think of one job that could get you out of bed happily for the rest of your life. Are you doing it now?" , "ask_msg_21.wav"],
["When its all said and done, will you have said more than youve done?" , "ask_msg_22.wav"],
["Were always making choices. Are you choosing for your story or for someone elses?" , "ask_msg_23.wav"],
["Do you need permission to move forward?" , "ask_msg_24.wav"],
["How much better would your life be if there werent any criticism in the world?" , "ask_msg_25.wav"],
["Which worries you more doing things right or doing the right things?" , "ask_msg_26.wav"],
["What risk would you take if you knew you could not fail?" , "ask_msg_27.wav"],
["Are you working so hard to create an amazing future, that you miss a million 'nows'?" , "ask_msg_28.wav"],
["Are your dreams bigger than other people's opinions or vice versa?" , "ask_msg_29.wav"],
["If the biggest obstacle in your life was removed, how would your life change?" , "ask_msg_30.wav"]
] ]

@ -0,0 +1,9 @@
[Unit]
Description=Life hack motion activation on reboot
After=multi-user.target
[Service]
ExecStart=/bin/sh /var/www/html/lifeHackAgent/motion.sh
[Install]
WantedBy=multi-user.target

@ -0,0 +1,9 @@
#!/bin/sh
DIR=/var/www/html/lifeHackAgent/
while [ 1 ]
do
python "$DIR"motion_detector_2.py -a 10
python "$DIR"guru-pirate.py
sleep 10
done

@ -0,0 +1,97 @@
#!/usr/bin/env python
# coding=utf-8
# USAGE
# python motion_detector.py
# python motion_detector.py --video videos/example_01.mp4
# import the necessary packages
import imutils
from imutils.video import VideoStream
import argparse
import datetime
import time, sys
from time import sleep
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-a", "--min-area", type=int, default=6000, help="minimum area size")
args = vars(ap.parse_args())
# if the video argument is None, then we are reading from webcam
vs = VideoStream(usePiCamera=True).start()
sleep(2.0)
# initialize the first frame in the video stream
firstFrame = None
occupied = False
# loop over the frames of the video
while True:
# grab the current frame and initialize the occupied/unoccupied
# text
frame = vs.read()
frame = frame if args.get("video", None) is None else frame[1]
text = "Unoccupied"
# if the frame could not be grabbed, then we have reached the end
# of the video
if frame is None:
break
# resize the frame, convert it to grayscale, and blur it
frame = imutils.resize(frame, width=500)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
# if the first frame is None, initialize it
if firstFrame is None:
firstFrame = gray
continue
# compute the absolute difference between the current frame and
# first frame
frameDelta = cv2.absdiff(firstFrame, gray)
thresh = cv2.threshold(frameDelta, 25, 255, cv2.THRESH_BINARY)[1]
# dilate the thresholded image to fill in holes, then find contours
# on thresholded image
thresh = cv2.dilate(thresh, None, iterations=2)
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
# loop over the contours
for c in cnts:
# if the contour is too small, ignore it
if cv2.contourArea(c) < args["min_area"]:
continue
# compute the bounding box for the contour, draw it on the frame,
# and update the text
(x, y, w, h) = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
text = "Occupied"
if not occupied:
occupied = True
print ('occupied')
sys.exit()
if occupied and text == "Unoccupied":
occupied = False
print ("Unoccupied")
# # show the frame and record if the user presses a key
# # cv2.imshow("Security Feed", frame)
# cv2.imwrite('security.jpg', frame)
# #cv2.imshow("Thresh", thresh)
# cv2.imwrite('threshold.jpg', thresh)
# #cv2.imshow("Frame Delta", frameDelta)
# cv2.imwrite('blured.jpg', frameDelta)
# #key = cv2.waitKey(1) & 0xFF
#
# # if the `q` key is pressed, break from the lop
# #if key == ord("q"):
# # break
# cleanup the camera and close any open windows
vs.stop() if args.get("video", None) is None else vs.release()
#cv2.destroyAllWindows()

@ -29,34 +29,33 @@
"How much vacation time do you get?" "How much vacation time do you get?"
], ],
"part2":[ "part2":[
"Ask yourself: are you wasting your time with this?", "Ask yourself: are you wasting your time with this?",
"Would you rather use your time to meditate or to actually solve your problems?", "Would you rather use your time to meditate or to actually solve your problems?",
"Can you really trust someone to solve your problems?", "Can you really trust someone to solve your problems?",
"Instead of that, ask for a raise!", "Instead of that, ask for a raise!",
"Leave before it's overtime!", "Leave before it's overtime!",
"Don't stay late today.", "Don't stay late today.",
"Why aren't you leaving?", "Why aren't you leaving?",
"Grab a coffee with a friend", "Grab a coffee with a friend",
"Can I leave early today?", "Can I leave early today?",
"Come on...", "Come on...",
"Cough cough cough cough", "Cough cough cough cough",
"Bla bla bla", "Bla bla bla",
"What brought you here?", "Oh come on, another one?",
"Oh come on, another one?", "Ahem",
"Ahem", "I have to leave early on Fridays.",
"I have to leave early on Fridays.", "My resume is fake.",
"My résumé is fake.", "I do not have a solution, but I do admire the problem.",
"I dont have a solution, but I do admire the problem.", "Focus on this: are you being paid enough?",
"Focus on this: are you being paid enough?", "Another meeting that could have been an email.",
"Another meeting that could have been an email.", "Ask your boss, how much do they get paid?",
"Ask your boss, how much do they get paid?", "Can I ask you to cover for me while I am in Bora Bora?",
"Can I ask you to cover for me while I am in Bora Bora?", "Ask for employee discounts, you are not getting any.",
"Ask for employee discounts, you are not getting any.", "{} seems too self-absorbed",
"{} seems too self-absorbed", "{} can look egocentric.",
"{} can look egocentric.", "{} is narcissistic",
"{} is narcissistic", "Buuurp",
"Buuurp", "Use your common sense."
"Use your common sense."
] ]
} }

Loading…
Cancel
Save