硬件在Logitech C920摄像机上对视频流进行编码,并通过wifi将其发送到ROS,延迟少于0.2秒


在此指令中,我们将通过无线网络从BeagleBone Blue发送的Logitech C920摄像机编码的h264视频流发送到笔记本电脑,然后将其带到ROS gscam节点,并沿着EduMIP机器人的路径搜索和识别塔罗牌和番茄酱瓶的图像。

这是我系列文章的续篇, 在上一期中,我们重点讨论了通过gstreamer将视频发送到便携式计算机这一事实

ROS有一个可以从gstreamer接收视频的软件包,称为gscam,这是文档源代码

我们需要具有gstreamer-1.0支持的最新版gscam,因此我们将从最新版本的源代码进行安装。

cd catkin_ws/src git clone https://github.com/ros-drivers/gscam cd .. catkin_make -DGSTREAMER_VERSION_1_x=On 

现在我们需要创建一个启动文件,并在其中输入gstreamer命令,该命令会将视频发送到ffmpegcolorspace。

 -v udpsrc port=6666 ! application/x-rtp, encoding-name=H264 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! ffmpegcolorspace 

生成的文件〜/ catkin_ws / src / gscam / examples / streamc920.launch如下所示:

 <launch> <!-- Set this to your camera's name --> <arg name="cam_name" value="creative_cam" /> <!-- Start the GSCAM node --> <env name="GSCAM_CONFIG" value="-v udpsrc port=6666 ! application/x-rtp, encoding-name=H264 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! ffmpegcolorspace" /> <node pkg="gscam" type="gscam" name="$(arg cam_name)"> <param name="camera_name" value="$(arg cam_name)" /> <param name="camera_info_url" value="package://localcam/calibrations/${NAME}.yaml" /> <remap from="camera/image_raw" to="$(arg cam_name)/image_raw" /> </node> <!-- Provide rectification --> <node pkg="image_proc" type="image_proc" name="creative_image_proc" ns="$(arg cam_name)" /> <!-- View the raw and rectified output --> <node pkg="image_view" type="image_view" name="creative_view" > <remap from="image" to="/$(arg cam_name)/image_raw" /> </node> </launch> 

现在,如果我们运行它:

 roslaunch gscam streamc920.launch 

它将接收来自摄像机的视频流,现在在ROS中,我们将此视频作为主题creative_cam / image_raw。

从上一课中,我们将通过更改主题开始搜索和识别地图图像:

 rosrun find_object_2d find_object_2d image:=/creative_cam/image_raw 

在本文开头的视频中,您可以在即兴的轨道上看到测试EduMIP机器人的结果。 尽管由于机器人的平衡而产生了晃动,但仍可以识别图像,但是在三轮或四轮机器人上,我认为一切都会好得多。

我还将笔记本电脑连接到wifi双绞线路由器,并通过每秒一次的关键帧将比特率降低到1 Mbps,这将视频传输延迟降低到0.2秒。

 gst-launch-1.0 uvch264src initial-bitrate=1000000 average-bitrate=1000000 iframe-period=1000 name=src auto-start=true src.vidsrc ! video/x-h264,width=160,height=120,framerate=30/1 ! h264parse ! rtph264pay ! udpsink host=192.168.1.196 port=6666 



对于那些想要实时观看机器人的人,我将在7月7日与莫斯科DIYorDIE Meetup的EduMIP项目进行交流

Source: https://habr.com/ru/post/zh-CN415735/


All Articles