-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestObjectTracking.py
More file actions
67 lines (47 loc) · 1.6 KB
/
Copy pathTestObjectTracking.py
File metadata and controls
67 lines (47 loc) · 1.6 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
61
62
63
64
65
66
import cv2
from djitellopy import Tello
import cv2, time
import ColorDetection as CLD
import ContourDetection as CTD
################################################################################
################################################################################
width = 320 ## WIDTH OF THE IMAGE
height = 240 ## HEIGHT OF THE IMAGE
startCounter = 1 ## 0 FOR FLIGHT 1 FOR TESTING
################################################################################
################################################################################
## Connecting to Tello Drone
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 image form Tello
frame_read = me.get_frame_read()
myFrame = frame_read.frame
img = cv2.resize(myFrame, (width, height))
## To go up in the beginning
## The first frame should be 0 if it is than this will run
## method for movement is in distance to be travled
if startCounter == 0:
me.takeoff()
me.move_left(20)
me.rotate_clockwise(90)
me.move_up(100)
time.sleep(4)
startCounter = 1
## Send velocity values to telllo
# if me.send_rc_control:
# me.send_rc_control(me.for_back_velocity, me.left_right_velocity, me.up_down_velocity, me.yaw_velocity,)
## Display Image
cv2.imshow("MyResult", img)
# Set up to stop program when q is pressed
if cv2.waitKey(1) & 0xFF ==ord('q'):
me.land()
break