参考:
wiki教程
https://github.com/ros-drivers/video_stream_opencv.git
0 . 查看摄像头是否挂载及挂载的USB端口号
- 两个USB摄像头同时使用 hub连接电脑,会报:
- [ERROR] [1652284172.828043630]: VIDIOC_S_FMT error 22, Invalid argument.
1.介绍 接受的视频输入,例如:
1 . USB摄像头
2 . rtsp
3 . 视频文件
video_stream_provider: A number for the /dev/videoX device;
e.g.: 0 for /dev/video0. A string for a path for a video file;
e.g.: /home/user/Videos/myvideo.avi or a url of a video stream;
e.g.: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov and http://10.68.0.6/mjpg/video.mjpg.
2.读取rtsp视频
修改rtsp_stream.launch文件
<?xml version="1.0"?>
<launch>
<!-- launch video stream -->
<include file="$(find video_stream_opencv)/launch/camera.launch" >
<!-- node name and ros graph name -->
<arg name="camera_name" value="rtsp2" />
<!-- url of the video stream -->
<!--<arg name="video_stream_provider" value="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov" />-->
<arg name="video_stream_provider" value="rtsp://admin:@192.168.1.112:554/ch0" />
<!-- set camera fps to (does nothing on a stream)-->
<!-- <arg name="set_camera_fps" value="30"/> -->
<!-- set buffer queue size of frame capturing to -->
<arg name="buffer_queue_size" value="1000" />
<!-- throttling the querying of frames to -->
<arg name="fps" value="30" />
<!-- setting frame_id -->
<arg name="frame_id" value="rtsp_frame" />
<!-- 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="camera_info_url" value="" />
<!-- flip the image horizontally (mirror it) -->
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- visualize on an image_view window the stream generated -->
<arg name="visualize" value="true" />
</include>
</launch>
3.读取usb摄像头
使用这个包读取usb摄像头在agx上有问题,换个包读取。
参考:ros驱动:http://wiki.ros.org/usb_cam
打开launch文件
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
查看摄像头是否挂载及挂载的USB端口号 可以查看usb摄像头的信息,修改对应的参数
启动摄像头launch
roslaunch usb_cam usb_cam-test.launch
打开rviz查看视频流
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)