-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecord-video.py
More file actions
executable file
·38 lines (29 loc) · 900 Bytes
/
Copy pathrecord-video.py
File metadata and controls
executable file
·38 lines (29 loc) · 900 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
#!/usr/bin/env python3
import time, cv2
from threading import Thread
from djitellopy import Tello
tello = Tello()
tello.connect()
keepRecording = True
tello.streamon()
frame_read = tello.get_frame_read()
def videoRecorder():
# create a VideoWrite object, recoring to ./video.avi
height, width, _ = frame_read.frame.shape
video = cv2.VideoWriter('video.avi', cv2.VideoWriter_fourcc(*'XVID'), 30, (width, height))
while keepRecording:
video.write(frame_read.frame)
time.sleep(1 / 30)
print (".")
video.release()
# we need to run the recorder in a seperate thread, otherwise blocking options
# would prevent frames from getting added to the video
recorder = Thread(target=videoRecorder)
recorder.start()
# tello.takeoff()
# tello.move_up(100)
# tello.rotate_counter_clockwise(360)
# tello.land()
time.sleep(10)
keepRecording = False
recorder.join()