forked from murtazahassan/Tello-Object-Tracking
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TelloMain.py
53 lines (43 loc) · 1.3 KB
/
TelloMain.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
from djitellopy import Tello
import cv2
import time
######################################################################
width = 320 # WIDTH OF THE IMAGE
height = 240 # HEIGHT OF THE IMAGE
startCounter =0 # 0 FOR FIGHT 1 FOR TESTING
######################################################################
# CONNECT TO TELLO
me = Tello()
me.connect()
me.for_back_velocity = 0
me.left_right_velocity = 0
me.up_down_velocity = 0
me.yaw_velocity = 0
me.speed = 0
print(me.get_battery())
me.streamoff()
me.streamon()
while True:
# GET THE IMGAE FROM TELLO
frame_read = me.get_frame_read()
myFrame = frame_read.frame
img = cv2.resize(myFrame, (width, height))
# TO GO UP IN THE BEGINNING
if startCounter == 0:
me.takeoff()
time.sleep(8)
me.rotate_clockwise(90)
time.sleep(3)
me.move_left(35)
time.sleep(3)
me.land()
startCounter = 1
# # SEND VELOCITY VALUES TO TELLO
# if me.send_rc_control:
# me.send_rc_control(me.left_right_velocity, me.for_back_velocity, me.up_down_velocity, me.yaw_velocity)
# DISPLAY IMAGE
cv2.imshow("MyResult", img)
# WAIT FOR THE 'Q' BUTTON TO STOP
if cv2.waitKey(1) & 0xFF == ord('q'):
me.land()
break