damiafuentes / DJITelloPy

DJI Tello drone python interface using the official Tello SDK. Feel free to contribute!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when using with_queue for get_frame_read()

S-Khos opened this issue · comments

commented

I run into this error whenever I am using the with_queue=True flag for tello.get_frame_read()

this is the exact error

Exception in thread Thread-3 (update_frame):
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/djitellopy/tello.py", line 1067, in update_frame
    for frame in self.container.decode(video=0):
  File "av/container/input.pyx", line 202, in decode
  File "av/container/input.pyx", line 162, in demux
  File "av/container/core.pyx", line 292, in av.container.core.Container.err_check
  File "av/error.pyx", line 336, in av.error.err_check
av.error.ExitError: [Errno 1414092869] Immediate exit requested: 'udp://@0.0.0.0:11111'; last error log: [h264] error while decoding MB 38 4, bytestream -5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.11/site-packages/djitellopy/tello.py", line 1077, in update_frame
    raise TelloException('Do not have enough frames for decoding, please try again or increase video fps before get_frame_read()')
djitellopy.tello.TelloException: Do not have enough frames for decoding, please try again or increase video fps before get_frame_read()
Traceback (most recent call last):
  File "/Users/user1/Documents/Github/test/src/drone_feed.py", line 15, in <module>
    cv2.imshow("FEED", frame)
cv2.error: OpenCV(4.7.0) /Users/xperience/GHA-OCV-Python/_work/opencv-python/opencv-python/opencv/modules/highgui/src/window.cpp:971: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

this is what my code looks like,

drone = Tello()
drone.connect()
drone.streamon()
frame_read = drone.get_frame_read(with_queue=True)


cv2.namedWindow("FEED", cv2.WINDOW_NORMAL)
while True:
    frame = frame_read.frame
    cv2.imshow("FEED", frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()
drone.end()

When using the frame queue the frame_read.frame only returns a frame when a new frame is acutally available. You are reading them too fast.

When no new frame is available frame_read.frame returns None, which causes an error when given to cv2.imshow