Beispiel #1
0
def take_vid(cam, pir):
    '''takes a video while movement is detected'''
    duration = 10
    if not os.path.isdir('/home/pi/Documents/talos/vids-talos'):
        os.makedirs('/home/pi/Documents/talos/vids-talos')
    vid_list = []
    cam.rotation = 0
    cam.annotate_text_size = 64
    cam.annotate_background = Color.from_rgb(0, 0, 0)
    cam.annotate_text = str_now()
    cam.start_preview()
    vid = '/home/pi/Documents/talos/vids-talos/vid' + str_now() + '.h264'
    cam.start_recording(vid)
    vid_list.append(vid)
    timer = 0
    timer2 = 0
    while timer < duration:
        cam.annotate_text = str_now()
        time.sleep(1)
        if pir.motion_detected:
            timer = 0
        else:
            timer += 1
        timer2 += 1
        if timer2 >= 300:
            cam.stop_recording()
            vid = '/home/pi/Documents/talos/vids-talos/vid' + str_now(
            ) + '.h264'
            cam.start_recording(vid)
            vid_list.append(vid)
    cam.stop_recording()
    cam.stop_preview()
    return vid_list
Beispiel #2
0
def take_pic(cam):
    '''takes a picture and saves it'''
    if not os.path.isdir('/home/pi/Documents/talos/pics-talos'):
        os.makedirs('/home/pi/Documents/talos/pics-talos')
    cam.rotation = 0
    #cam.start_preview()
    cam.annotate_text_size = 64
    cam.annotate_text = str_now()
    cam.annotate_background = Color.from_rgb(0, 0, 0)
    #time.sleep(.5)
    image = '/home/pi/Documents/talos/pics-talos/img' + str_now() + '.jpg'
    cam.capture(image)
    #cam.stop_preview()
    return image