From 7716dadb58451bc40b858b6e4cb8c3a76e48c5ed Mon Sep 17 00:00:00 2001 From: acastro Date: Wed, 12 Dec 2018 17:44:40 +0000 Subject: [PATCH] integration colophon.py in montion.sh --- colophon.py | 29 ++++++++++++++++++----------- motion.sh | 3 ++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/colophon.py b/colophon.py index 2969bd7..545e9ad 100644 --- a/colophon.py +++ b/colophon.py @@ -11,19 +11,21 @@ import imutils from imutils.video import VideoStream from io import BytesIO from PIL import Image -import time, sys +import time, sys, os from time import sleep import cv2 import datetime from datetime import datetime from subprocess import call +pwd = os.path.dirname( os.path.realpath(__file__) ) + "/" #current dir + # check open cv version -print(cv2.__version__) +#print(cv2.__version__) # choose video source from camera pi vs = VideoStream(usePiCamera=True).start() # let camera warm up -sleep(2.0) +sleep(0.5) image = vs.read() count = 0 @@ -32,8 +34,13 @@ buffer = [] playing = False -while success: +iteration=0 +while success: + iteration = iteration +1 + #print("iteration:", iteration) + if iteration > 500: + sys.exit() # save live frame as JPEG file cv2.imwrite("check_frame.jpg", image) image = vs.read() @@ -56,21 +63,21 @@ while success: buffer.append(datetime.now()) # create an array with all the values that we got, when the array is bigger than 300 values, start erasing being the first one first to go - if len(buffer) > 300: + if len(buffer) > 100: buffer.pop(0) - print(buffer) +# print(buffer) # For calling the colophon.wav some conditions must be met. # By the order of: # all the values must be the same # we need to have at least 200 values, this prevents it from starting when there is just 1 value - if ( (len(set(buffer))==1) & ( len(buffer) > 200 ) & ( playing == False ) ): - print ("All elements in list are same") - call(["aplay", "/home/pi/colophon/colophon.wav"]) + if ( (len(set(buffer))==1) & ( len(buffer) > 99 ) & ( playing == False ) ): + #print ("All elements in list are same") + call(["aplay", pwd+"colophon.wav"]) # to record the espeak sentence into a .wav file -> # -> espeak "sentence goes here" -ven+whisper -s 150 --stdout > colophon.wav # espeak 'Iris Version 0.5 Contributors: Gill Baldwin, Simon Browne, Tancredi Di Giovanni, Paloma García, Rita Graça, Artemis Gryllaki, Pedro Sá Couto, Biyi Wen, Bohye Woo, Silvio Lorusso, Aymeric Mansoux, André Castro, Steve Rushton, Michael Murtaugh, Leslie Robbins. Produced and published by the Experimental Publishing (XPUB) program of the Piet Zwart Institute, Rotterdam, December 2018. A collaboration between the Research Department of Het Nieuwe Instituut and XPUB. playing = True - else: - print ("All elements in list are not same") +# else: +# print ("All elements in list are not same") diff --git a/motion.sh b/motion.sh index 0e7ccc0..70cb5e5 100755 --- a/motion.sh +++ b/motion.sh @@ -2,9 +2,10 @@ # location of the directory DIR=/var/www/html/lifeHackAgent/ + while [ 1 ] do python "$DIR"motion_detector_2.py -a 6000 python "$DIR"guru-pirate.py - sleep 5 + python "$DIR"colophon.py # THIS WILL RUN FOR 10SEC done