Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

HELP with opencv, anyone?

tello-ajd

Member
Joined
Jun 19, 2020
Messages
8
Reaction score
0
Hi there, I'm trying to work with opencv and djitellopy in hopes of eventually being able to have my Tello EDU drone detect color.

I am stuck this error: OpenCV: Couldn't read video stream from file "udp://@0.0.0.0:11111". The commands "command", "streamoff" , and "stream" are successfully sent to the Tello so I think the problem is with the get_frame_read() function from djitellopy. I am so lost so any help would be much appreciated!

Here is the code I'm using:

from djitellopy import Tello
import cv2
import time

######################################################################
width = 320 # WIDTH OF THE IMAGE
height = 240 # HEIGHT OF THE IMAGE
startCounter = 1 # 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()
time.sleep(10)

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

# DISPLAY IMAGE
cv2.imshow("MyResult", img)

# WAIT FOR THE 'Q' BUTTON TO STOP
if cv2.waitKey(1) & 0xFF == ord('q'):
me.land()
break
 

New Threads

Members online

Forum statistics

Threads
4,582
Messages
33,709
Members
11,822
Latest member
TelloDronny