Reputation: 11
I am currently stuck with high video streaming latency on python with OpenCV. I have the video streaming set up but the latency (about 800ms) is hard to deal with when manually controlling the drone with pygame. I know that it isn't the drone because when I use the Tello app, the latency is unnoticeable. Does anyone have any experience with video streaming with the Tello drone?
Upvotes: 1
Views: 1409
Reputation: 95
I used the following code in Windows 10 and could display the video stream from the drone without a delay. However, note that this uses the tellopy library.
def video_thread():
global drone
global run_video_thread
global av
print('START Video thread')
drone.start_video()
try:
container = av.open(drone.get_video_stream())
frame_count = 0
while True:
for frame in container.decode(video=0):
frame_count = frame_count + 1
image = cv2.cvtColor(numpy.array(frame.to_image()), cv2.COLOR_RGB2BGR)
cv2.imshow('Original', image)
cv2.waitKey(1)
cv2.destroyWindow('Original')
except KeyboardInterrupt as e:
print('KEYBOARD INTERRUPT Video thread ' + e)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
print('EXCEPTION Video thread ' + e)
def main():
global drone
drone = tellopy.Tello()
drone.connect()
try:
threading.Thread(target=video_thread).start()
except e:
print(str(e))
finally:
print('Shutting down connection to drone...')
drone.quit()
exit(1)
if __name__ == '__main__':
main()
Upvotes: -2