-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspypy_test.py
36 lines (32 loc) · 967 Bytes
/
spypy_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import datetime
import subprocess
import os
from configparser import ConfigParser
import RPi.GPIO as GPIO
from picamera import PiCamera
from time import sleep
GPIO.setmode(GPIO.BCM)
PIR = 4
GPIO.setup(PIR, GPIO.IN)
counter = 0
filename = "capture{}.jpg"
while os.path.isfile(filename.format(counter)):
counter += 1
filename = filename.format(counter)
camera = PiCamera()
camera.resolution = (1024, 768)
try:
print("Monitoring")
time.sleep(1)
print("Ready")
while True:
if GPIO.input(PIR):
for filename in camera.capture_continuous('img{timestamp:%Y-%m-%d-%H-%M-%S}.jpg'):
print('Captured %s' % filename)
time.sleep(1)
except KeyboardInterrupt:
print(" Quit")
GPIO.cleanup()
#sleep(2)
#camera.capture(filename)