-
Notifications
You must be signed in to change notification settings - Fork 14
/
VideoWriter.py
53 lines (37 loc) · 1.04 KB
/
VideoWriter.py
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
##Startup##
import time, sys
import ps_drone
import cv2
drone = ps_drone.Drone()
drone.startup()
drone.reset()
while (drone.getBattery()[0]==-1):
time.sleep(0.1)
print "Battery: "+str(drone.getBattery()[0])+"% "+str(drone.getBattery()[1])
drone.useDemoMode(True)
##Setup##
drone.setConfigAllID()
drone.sdVideo()
drone.frontCam()
CDC = drone.ConfigDataCount
while CDC == drone.ConfigDataCount: time.sleep(0.0001)
drone.startVideo()
##Detection##
IMC = drone.VideoImageCount
stop = False
out = cv2.VideoWriter('output.avi',cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 10,(800,800))
while not stop:
while drone.VideoImageCount==IMC:
time.sleep(0.01)
IMC = drone.VideoImageCount
key = drone.getKey()
if key:
stop = True
img = drone.VideoImage
resize = cv2.resize(img,(800,800))
#out.write(resize)
cv2.imshow('Drones video',resize)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.waitKey(1)
cv2.destroyAllWindows()