-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcameraScript.py
More file actions
38 lines (32 loc) · 1021 Bytes
/
cameraScript.py
File metadata and controls
38 lines (32 loc) · 1021 Bytes
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
import os.path
import picamera
import RPi.GPIO as GPIO
launchDetect = False
videoRecorded = False
#Pin definitions
triggerPin = 17
#Pin setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(triggerPin, GPIO.IN)
camera = picamera.PiCamera()
camera.resolution = (1920, 1080)
camera.framerate = 30
stream = picamera.PiCameraCircularIO(camera, seconds=100)
camera.start_recording(stream, format='h264')
def launch_detected():
if GPIO.input(triggerPin):
launchDetect = True
return launchDetect
for i in range(99):
if not os.path.exists('video' + str(i) + '.h264'):
try:
while not videoRecorded:
camera.wait_recording(3)
if launch_detected():
camera.wait_recording(90)
stream.copy_to('video'+ str(i) + '.h264')
camera.stop_recording()
videoRecorded = True
finally:
if os.path.exists('video' + str(i) + '.h264'):
os.system("sudo shutdown now")