-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecodingProject.py
More file actions
56 lines (43 loc) · 1.49 KB
/
Copy pathRecodingProject.py
File metadata and controls
56 lines (43 loc) · 1.49 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
49
50
51
52
53
54
55
from distutils.file_util import write_file
import numpy as np
import KeyPressModule as kp
import time, cv2
from threading import Thread
from djitellopy import Tello
from array import *
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
## cv2.VideoWriter(filename, codec being used, frame per sec, )
count = 0
DState = tello.get_current_state()
DStateM = [[any]]
video = cv2.VideoWriter(f'Resources/Vid/{time.time()}.avi', cv2.VideoWriter_fourcc(*'XVID'), 30, (width, height))
DStateMF = str
while keepRecording:
video.write(frame_read.frame); DStateM.insert(count,[DState]); count = count+1
time.sleep(1 / 30)
print(DStateM)
for row in DStateM:
write_file(f'Resources/StateData/DStateM.txt', DStateM)
# DStateMF.close()
cv2.imshow("Current video ",frame_read.frame) ## Gives window to display image
cv2.waitKey(1)
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()
time.sleep(10)
# tello.move_up(100)
# tello.rotate_counter_clockwise(360)
# if cv2.waitKey(1) & 0xFF == ord('q'):
# keepRecording = False
# recorder.join()
keepRecording = False
recorder.join()