-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBevkaka
70 lines (58 loc) · 2.06 KB
/
Bevkaka
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime
from picamera import PiCamera
import os
import subprocess
os.system('sudo service motion stop')
pir = MotionSensor(4)
kamera = PiCamera()
val = ""
print('Welcome to Grizzly survailance')
while val != "n":
print("Take a picture: 1")
print("Record a video: 2")
print("Acivate motion sensor: 3")
print("LiveStream: 4")
print("Quit: n")
val = input("Select one...")
name = datetime.now().strftime('%c')
if val == '1':
os.system('clear')
kamera.capture('/home/pi/bevaka/bilder/'+name+'.jpeg')
print('Image taken')
os.system('/home/pi/backup/attach_test.py') # Denna!
subprocess.call("/home/pi/bevaka/intro.sh", shell=True)
elif val == '2':
print('Vido recording for 5 seconds started:')
kamera.start_recording('/home/pi/bevaka/videos/'+name+'.h264')
sleep(5)
kamera.stop_recording()
elif val == '3':
print('Motion activated')
name2 = datetime.now().strftime('%c')
i = 0
try:
while True:
pir.wait_for_motion()
print('motion detected')
kamera.capture('/home/pi/bevaka/bilder/motion/'+name2+'.jpeg')
pir.wait_for_no_motion()
print('Motion captured')
#subprocess.call("/home/pi/bevaka/bilder/motion/intro.sh", shell=True)
os.system('/home/pi/backup/attach_test.py')
print('Image emailed')
i = i +1
if i == '5':
break
except KeyboardInterrupt:
pass
print('Motion detection disabled')
elif val == '4':
print('Live stream activated for 60 seconds, at 31.209.6.158:8081')
os.system('sudo service motion start')
sleep(60)
os.system('sudo service motion stop')
print('Live stream ended')
#Kanske se til att se den