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
 

f41ardu

Well-known member
Joined
Jan 3, 2019
Messages
74
Reaction score
27
Location
Back in Stuttgart ;->
Can you tell us which platform, python version, opencv version, ... do you use?
According my experience not all openvc implementations may support video stream via udp.
And try my script: Taking Pictures with Tello Drone using Python 3

I've brewed opencv on my PI on my own to ensure that the feature is available.

Hope that helps.If you are on windows using Thonny it may work.
 

Zehdari

New member
Joined
Jul 31, 2020
Messages
1
Reaction score
0
If you're still having this problem, I had the exact same thing. I changed my network settings from "Public" to "Private", and that fixed it.
I believe that's what was stopping me from contacting the udp server @ 0.0.0.0 before.
 

New Threads

Members online

Forum statistics

Threads
4,587
Messages
33,733
Members
11,840
Latest member
Tello Dancer