我遇到了一个问题,当无人机使用ardrone_autonomy ardrone.launch通过ROS连接时,我无法连接到AR无人机2摄像头。
我认为这个问题是因为我试图在通过ardrone_autonomy连接的同时,通过OpenCV和Python通过IP地址访问无人机摄像头。下面是我如何实现这一点的代码片段。
video_capture = cv2.VideoCapture()
video_capture.open('tcp://192.168.1.1:5555')
vidWidth = video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)
vidHeight = video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)如您所见,我使用的是摄像机的IP地址。当无人机没有通过ROS连接时,这是完美的,这本质上就像一个网络摄像头。
我的最终目标是通过使用OpenCV从相机接收的图像进行跟踪和导航,这意味着我将不得不发出移动命令(Cmd_vel),这需要基于OpenCV接收和处理的图像通过ardrone_autonomy进行连接。
有没有什么办法,我可以在连接到ROS的同时使用无人机上的IP摄像头来完成这项任务?
谢谢你的帮助!
发布于 2016-12-06 01:20:32
http://wiki.ros.org/video_stream_opencv可以从HTTP/TCP打开视频流:
<launch> <!-- video stream from URL to ROS topic - see http://wiki.ros.org/video_stream_opencv -->
<include file="$(find video_stream_opencv)/launch/camera.launch" >
<arg name="camera_name" value="drone_webcam" /> <!-- node name and ros graph name -->
<arg name="video_stream_provider" value="http://192.168.1.227:8080/video?x.mjpeg" /> <!-- ?x.mjpeg see http://answers.opencv.org/question/13139/cvvideocapture-works-for-webcams-but-not-ip-cameras/ -->
<arg name="fps" value="10" /><!-- throttling the querying of frames to 10Hz -->
<arg name="frame_id" value="webcam" /> <!-- setting TF frame_id -->
<arg name="camera_info_url" value="file:///abc/xyz.yaml" /> <!-- camera info loading, take care as it needs the "file:///" at the start , e.g.:
"file:///$(find your_camera_package)/config/your_camera.yaml" -->
<arg name="flip_horizontal" value="false" /> <!-- flip the image horizontally (mirror it) -->
<arg name="flip_vertical" value="false" /> <!-- flip the image vertically -->
<arg name="visualize" value="true" /> <!-- visualize on an image_view window the stream generated -->
</include>
</launch>请注意网址末尾的/video?x.mjpeg。
https://stackoverflow.com/questions/40004386
复制相似问题