-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProject-KeybContImageCapture.py
More file actions
60 lines (46 loc) · 1.22 KB
/
Project-KeybContImageCapture.py
File metadata and controls
60 lines (46 loc) · 1.22 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
56
57
58
59
60
# Surveillance Project to Move Drone Manually and
# take pictures with button 'z'
# Direction Movements Arrows
# Drone Movements w(up),a(left),d(right),q(land),e(take off)
from djitellopy import tello
import KeyPressModule as kp
import time
import cv2
kp.init()
me = tello.Tello()
me.connect()
print(me.get_battery())
global img
me.streamon()
def getKeyboardInput():
lr, fb, ud, yv = 0, 0, 0, 0
speed = 50
if kp.getKey("LEFT"):
lr = -speed
elif kp.getKey("RIGHT"):
lr = speed
if kp.getKey("UP"):
fb = speed
elif kp.getKey("DOWN"):
fb = -speed
if kp.getKey("w"):
ud = speed
elif kp.getKey("s"):
ud = -speed
if kp.getKey("a"):
yv = -speed
elif kp.getKey("d"):
yv = speed
if kp.getKey("q"): yv = me.land(); time.sleep(3)
if kp.getKey("e"): yv = me.takeoff()
if kp.getKey('z'):
cv2.imwrite(f'Resources/Images/{time.time()}.jpg', img)
time.sleep(0.3)
return [lr, fb, ud, yv]
while True:
vals = getKeyboardInput()
me.send_rc_control(vals[0], vals[1], vals[2], vals[3])
img = me.get_frame_read().frame
img = cv2.resize(img, (360, 240))
cv2.imshow("Image", img)
cv2.waitKey(1)