如何从openCV捕获的cv2.VIDEOCAPTURE()捕获的Tello SDK 2.0流。
我想编写一个代码,并实时显示带有Yolov5 Torch模型的Tello流,而潜伏期低。
但是我坚持如何使用cv2.videocapture()
与tello。
from threading import Thread
from djitellopy import Tello
import cv2, math, time
import os
tello = Tello()
tello.connect(False)
tello.streamon()
print(tello.get_udp_video_address())
print(type(tello.get_udp_video_address()))
cap = cv2.VideoCapture(tello.get_udp_video_address())
try:
while True:
img = cap.read()
cv2.imshow('frame', img)
except KeyboardInterrupt:
exit(1)
finally:
print("fin")
输出:
[INFO] tello.py - 107 - Tello instance was initialized. Host: '192.168.10.1'. Port: '8889'.
[INFO] tello.py - 422 - Send command: 'command'
[WARNING] tello.py - 432 - Aborting command 'command'. Did not receive a response after 7 seconds
[INFO] tello.py - 422 - Send command: 'command'
[INFO] tello.py - 446 - Response command: 'ok'
[INFO] tello.py - 422 - Send command: 'streamon'
[INFO] tello.py - 446 - Response streamon: 'ok'
udp://@0.0.0.0:11111
<class 'str'>
fin
Traceback (most recent call last):
File "bruh.py", line 16, in <module>
cv2.imshow('frame', img)
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imshow'
> Overload resolution failed:
> - mat is not a numerical tuple
> - Expected Ptr<cv::cuda::GpuMat> for argument 'mat'
> - Expected Ptr<cv::UMat> for argument 'mat'
[INFO] tello.py - 422 - Send command: 'streamoff'
我想使用cv2.videocapture()
,因为有更多的源使用网络摄像头&amp;实时对象检测。我已经尝试了多种方法来处理它,但是它们似乎对我不起作用。方法包括给捕获一个随机的UDP端口,并让其找出正确的一个端口。
感谢任何人的回应。
I want to write a code, showing stream from tello with yolov5 torch model in real-time with low latency.
But I am stuck with how to use cv2.VideoCapture()
with tello.
from threading import Thread
from djitellopy import Tello
import cv2, math, time
import os
tello = Tello()
tello.connect(False)
tello.streamon()
print(tello.get_udp_video_address())
print(type(tello.get_udp_video_address()))
cap = cv2.VideoCapture(tello.get_udp_video_address())
try:
while True:
img = cap.read()
cv2.imshow('frame', img)
except KeyboardInterrupt:
exit(1)
finally:
print("fin")
output:
[INFO] tello.py - 107 - Tello instance was initialized. Host: '192.168.10.1'. Port: '8889'.
[INFO] tello.py - 422 - Send command: 'command'
[WARNING] tello.py - 432 - Aborting command 'command'. Did not receive a response after 7 seconds
[INFO] tello.py - 422 - Send command: 'command'
[INFO] tello.py - 446 - Response command: 'ok'
[INFO] tello.py - 422 - Send command: 'streamon'
[INFO] tello.py - 446 - Response streamon: 'ok'
udp://@0.0.0.0:11111
<class 'str'>
fin
Traceback (most recent call last):
File "bruh.py", line 16, in <module>
cv2.imshow('frame', img)
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imshow'
> Overload resolution failed:
> - mat is not a numerical tuple
> - Expected Ptr<cv::cuda::GpuMat> for argument 'mat'
> - Expected Ptr<cv::UMat> for argument 'mat'
[INFO] tello.py - 422 - Send command: 'streamoff'
I want to use cv2.VideoCapture()
, since there're more sources with webcam & real-time objects detection. I have tried many ways to deal with it but they seems didn't work for me. Ways include give capture a random udp port and let it find out the correct one itself.
Appreciate anyone's response.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是从Tello获取视频流的基本代码:
这样做时,您必须调用'tello.streamon()',然后在循环中您制作该图像变量:
我将其与您的代码合并,这是结果:
我在每次添加/更改并评论了所有不安全的所有内容后,都提出了一个注释/#,您基本上只需要调用
img = tello.get_frame_frame_read.frame.frame
and us good。然后显示它并添加1 milisec的延迟。我建议您观看此视频: https://www.youtube.com/watch = v = v = lmecyqnfpda ,它有很多您可能想尝试的很酷的东西。享受!this is the basic code for getting video stream from the tello:
when doing that, you have to call 'tello.streamon()' and then in the loop you make that image variable:
i merged it with your code and this is the result:
I put a comment/# after everyting i added/changed and commented out everything that was uneccesary, you basically had to just call
img = tello.get_frame_read.frame
and ur good. then just show it and add a delay of 1 milisec. and i suggest you watch this video: https://www.youtube.com/watch?v=LmEcyQnfpDA , it has a bunch of cool stuff you might wanna try out. enjoy!