Pomik Ярыш
Pomik Ярыш

Reputation: 1

I can't output an image from a Tello quadcopter in Python

When running different programs to output images from the camera of the quadcopter, Tello gives the same incomprehensible errors. I want to get a video like from a laptop camera via OpenCV.

I run the code through IDLE. I've tried different programs with Python versions 3.11 and 3.10. Sample code:

from djitellopy import tello
import cv2

me = tello.Tello()
#cap = cv2.VideoCapture(0)
me.connect()
print(me.get_battery())
me.streamon()


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

Output:

[INFO] tello.py - 129 - Tello instance was initialized. Host: '192.168.10.1'. Port: '8889'.
[INFO] tello.py - 438 - Send command: 'command'
[INFO] tello.py - 462 - Response command: 'ok'
82
[INFO] tello.py - 438 - Send command: 'streamon'
[INFO] tello.py - 462 - Response streamon: 'ok'
Traceback (most recent call last):
  File "C:\Users\Roman\AppData\Local\Programs\Python\Python311\Lib\site-packages\djitellopy\tello.py", line 1049, in __init__
    self.container = av.open(self.address, timeout=(Tello.FRAME_GRAB_TIMEOUT, None))
  File "av\\container\\core.pyx", line 420, in av.container.core.open
  File "av\\container\\core.pyx", line 266, in av.container.core.Container.__cinit__
  File "av\\container\\core.pyx", line 286, in av.container.core.Container.err_check
  File "av\\error.pyx", line 326, in av.error.err_check
av.error.ExitError: [Errno 1414092869] Immediate exit requested: 'udp://@0.0.0.0:11111'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Roman\Desktop\11.py", line 12, in <module>
    img = me.get_frame_read().frame
  File "C:\Users\Roman\AppData\Local\Programs\Python\Python311\Lib\site-packages\djitellopy\enforce_types.py", line 54, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Roman\AppData\Local\Programs\Python\Python311\Lib\site-packages\djitellopy\tello.py", line 421, in get_frame_read
    self.background_frame_read = BackgroundFrameRead(self, address, with_queue, max_queue_len)
  File "C:\Users\Roman\AppData\Local\Programs\Python\Python311\Lib\site-packages\djitellopy\tello.py", line 1051, in __init__
    raise TelloException('Failed to grab video frames from video stream')
djitellopy.tello.TelloException: Failed to grab video frames from video stream

Upvotes: 0

Views: 42

Answers (0)

Related Questions