留个记录,PC连接上tello并在电脑上显示无人机拍摄的视频。
以下是我所借鉴的大佬的文章:
https://www.coder.work/article/7348021
https://blog.csdn.net/weixin_44917390/article/details/118188977
以下是使用cv2.VideoCapture接收视频的代码(实测可行):
import threading
import sys
import socket
import time
import cv2
host = ''
port = 9000
tello_ip = '192.168.10.1'
tello_port = 8889
tello_address = (tello_ip, tello_port)
mypc_address = (host, port)
socket = socket.socket (socket.AF_INET, socket.SOCK_DGRAM)
socket.bind (mypc_address)
socket.sendto ('command'.encode (' utf-8 '), tello_address)
socket.sendto ('streamon'.encode (' utf-8 '), tello_address)
print ("Start streaming")
capture = cv2.VideoCapture ('udp://0.0.0.0:11111',cv2.CAP_FFMPEG)
if not capture.isOpened():
capture.open('udp://0.0.0.0:11111')
while True:
ret, frame =capture.read()
print(ret)
if(ret):
cv2.imshow('frame', frame)
if cv2.waitKey (1)&0xFF == ord ('q'):
break
capture.release ()
cv2.destroyAllWindows ()
socket.sendto ('streamoff'.encode (' utf-8 '), tello_address)
还有这个大佬所使用的是ffmpeg视频显示(没有尝试)
https://blog.csdn.net/sxj731533730/article/details/112911578