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

Issues with Tello video stream to Windows Computer

mbrh

New member
Joined
May 16, 2021
Messages
3
Reaction score
0
Hi everyone!

I am trying to follow along Murtaza's Workshop YouTube "Drone Programming With Python Course | 3 Hours | Including x4 Projects | Computer Vision" course:


However I have hit a wall at the imageCapture section.

The Tello drone connects to the computer and I can use the basic movements commands without any difficulty, having the drone take off / move around with commands issued from the laptop. However when I try to run the code below to get a video stream:

from djitellopy import tello
import cv2

me = tello.Tello()
me.connect()
print(me.get_battery())

me.streamon()

while True:
img = me.get_frame_read().frame
img = cv2.resize(img, (360, 240))
cv2.imshow("Image", img)
cv2.waitKey(1)

the code returns the error:

[h264 @ 000001d171fc08c0] non-existing PTraceback (most recent call last):
File "C:/Users/Andrew Rudy/PycharmProjects/TelloDroneYouTubeProject/Video test 2.py", line 11, in <module>
frame_read = tello.get_frame_read()
File "C:\Users\Andrew Rudy\PycharmProjects\TelloDroneYouTubeProject\venv\lib\site-packages\djitellopy\enforce_types.py", line 54, in wrapper
return func(*args, **kwargs)
File "C:\Users\Andrew Rudy\PycharmProjects\TelloDroneYouTubeProject\venv\lib\site-packages\djitellopy\tello.py", line 404, in get_frame_read
self.background_frame_read = BackgroundFrameRead(self, address) # also sets self.cap
File "C:\Users\Andrew Rudy\PycharmProjects\TelloDroneYouTubeProject\venv\lib\site-packages\djitellopy\tello.py", line 932, in __init__
raise Exception('Failed to grab first frame from video stream')

If you debug look at the return value for the Frame = "None" so there is no stream is coming back to the computer. Also seen in the returned "raise Exception('Failed to grab first frame from video stream')".

I have tried to turn the firewall completely off and also to create special inbound rules to allow the UDP port 11111 to come through, however that has not solved the issue.

I am using Windows 10, pycharm, and have tried this with Python 3.7 and 3.9. Additionally I have tried it with djitello and djitello2, am using opencv-python 4.5.2.52.

The issue isn't with the Tello drone - it can send a video to my phone, and my friend ran the same code on his laptop (running on Linux) and it opened up a live stream.

Does anyone have any idea how to troubleshoot this or what may be wrong? Thanks in advance!
 
Last edited:

mbrh

New member
Joined
May 16, 2021
Messages
3
Reaction score
0
So I got it to work by changing the tello.py file


in line 930 I changed the if statement to a while statement for grabbing the first frame. It appears that my computer took longer to initialize that first frame and the exception would cancel out the code.

```
self.grabbed, self.frame = self.cap.read()
while not self.grabbed or self.frame is None:
print('still trying to grab first frame')
self.grabbed, self.frame = self.cap.read()
```

This gave it time to be able to grab the first frame and initialize. Going to see if I can find a workaround that doesn't involve editing the tello.py file.

If you look around online it seems that a lot of people are having this issue so it might be nice if the base file could be updated.
 

duw

New member
Joined
Jun 22, 2021
Messages
1
Reaction score
0
I was having this same issue and this solved the problem. Thank you so much!
 

New Threads

Members online

Forum statistics

Threads
5,120
Messages
37,030
Members
13,852
Latest member
DRONE MAN