我目前在python和OpenCV上遇到了很高的视频流延迟。我已经设置了视频流,但延迟(约800ms)很难处理时,手动控制的无人机与pygame。我知道它不是无人机,因为当我使用Tello应用程序时,延迟是不可察觉的。有没有人有过使用Tello无人机的视频流的经验?
发布于 2021-07-17 20:13:45
我在Windows10中使用了以下代码,可以毫无延迟地显示来自无人机的视频流。但是,请注意,这使用了tellopy库。
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()https://stackoverflow.com/questions/67117862
复制相似问题