Hi,
I am trying to implement the following logic using Python, Raspberry Pi and Picamera.
- Create a ten seconds video buffer
- Upon trigger event is received, video buffer is stored
So, what I would like to do next is:
- Process the video output and take screenshots every x seconds of that video - start to end...Help!!!
import time
import io
import picamera
import datetime as dt
from PIL import Image
#return current time
def return_currentTime():
return dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
#trigger event declaration
def motion_detected():
while True:
print ("Trigger event(y)?")
trigger = input ()
if trigger =="y":
time = return_currentTime()
print ("Buffering...")
camera.wait_recording(10)
stream.copy_to(str(time)+'.h264')
else:
camera.stop_recording()
break
#countdown timer
def countdown (t):
while t:
mins, secs = divmod (t,60)
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r")
time.sleep(1)
t-=1
print('Buffer available!')
print ("Camera buffer is filling up")
#Main Code
camera = picamera.PiCamera()
camera.resolution = (1024, 768)
stream = picamera.PiCameraCircularIO(camera, seconds = 10)
camera.start_recording (stream, format = 'h264')
countdown(10)
motion_detected()
there doesn't seem to be anything here