@ -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 ) > 3 00:
if len ( buffer ) > 1 00:
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")