김유현

edit videorecord

...@@ -21,8 +21,8 @@ def record() : ...@@ -21,8 +21,8 @@ def record() :
21 #''' 21 #'''
22 # rpi setting 22 # rpi setting
23 GPIO.setmode(GPIO.BCM) 23 GPIO.setmode(GPIO.BCM)
24 - PIR_PIN = 7 24 + pir_pin = 7
25 - GPIO.setup(PIR_PIN, GPIO.IN) 25 + GPIO.setup(pir_pin, GPIO.IN)
26 camera = PiCamera() 26 camera = PiCamera()
27 #''' 27 #'''
28 28
...@@ -33,7 +33,7 @@ def record() : ...@@ -33,7 +33,7 @@ def record() :
33 serializer = RecordSerializer(target, many = False) 33 serializer = RecordSerializer(target, many = False)
34 state = serializer.data['recording'] 34 state = serializer.data['recording']
35 ''' 35 '''
36 - if GPIO.input(PIR_PIN): # motion detected 36 + if GPIO.input(pir_pin): # motion detected
37 # take a video 37 # take a video
38 camera.resolution = [320, 240] 38 camera.resolution = [320, 240]
39 camera.start_preview() 39 camera.start_preview()
...@@ -44,7 +44,9 @@ def record() : ...@@ -44,7 +44,9 @@ def record() :
44 camera.start_recording(output=vid_path) 44 camera.start_recording(output=vid_path)
45 time.sleep(1) 45 time.sleep(1)
46 camera.capture(thumbnail_path) 46 camera.capture(thumbnail_path)
47 - time.sleep(5) 47 + while GPIO.input(pir_pin):
48 + print("recoring..")
49 + time.sleep(2)
48 camera.stop_recording() 50 camera.stop_recording()
49 camera.stop_preview() 51 camera.stop_preview()
50 52
...@@ -69,4 +71,4 @@ def record() : ...@@ -69,4 +71,4 @@ def record() :
69 71
70 72
71 if __name__ == '__main__': 73 if __name__ == '__main__':
72 - record()
...\ No newline at end of file ...\ No newline at end of file
74 + record()
......