-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpir_motion_camera.py
More file actions
48 lines (29 loc) · 1.08 KB
/
pir_motion_camera.py
File metadata and controls
48 lines (29 loc) · 1.08 KB
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
from datetime import datetime
from time import sleep
class pir_motion_camera:
sleeptimer = 30
video_lenght = 15
camera = None
camera_focus_timer = 4
path_images = None
def __init__(self, camera, path_images):
self.camera = camera
self.path_images = path_images
def capture_image(self):
#open camera
self.camera.start_preview()
print("Capturing image")
filename = datetime.now().strftime("%d-%m-%Y-%H.%M.%S")
sleep(self.camera_focus_timer)
self.camera.capture(self.path_images + filename + '.jpg')
self.camera.stop_preview()
sleep(self.sleeptimer)
def capture_video(self):
self.camera.start_preview()
print("Recording video")
filename = 'video-' + datetime.now().strftime("%d-%m-%Y-%H.%M.%S")
self.camera.start_recording(self.path_images + filename + '.h264')
self.camera.wait_recording(self.video_lenght)
self.camera.stop_recording()
self.camera.stop_preview()
sleep(self.sleeptimer)