5.2.7 工具
图像发布工具
功能介绍
图片发布工具支持批量读取本地图片或视频文件,并按照ROS消息格式发布,从而提高算法调试和部署效率。
对于图片发布,支持读取JPEG/JPG/PNG/NV12格式的图片,发布压缩图片或者将压缩图片转换为NV12格式进行发布。
对于视频发布,支持H264/H265/MP4格式,读 取视频文件后提取相关的视频流进行发布。
代码仓库: (https://github.com/D-Robotics/hobot_image_publisher.git)
支持平台
平台 | 运行方式 |
---|---|
RDK X3, RDK X3 Module | Ubuntu 20.04 (Foxy), Ubuntu 22.04 (Humble) |
RDK X5, RDK X5 Module | Ubuntu 22.04 (Humble) |
RDK Ultra | Ubuntu 20.04 (Foxy) |
X86 | Ubuntu 20.04 (Foxy) |
X86平台不支持将H.264、H.265视频解码为NV12格式,因此H.264、H.265视频发布功能无法在X86平台展示。 RDK Ultra不支持将H.264视频解码为NV12格式,因此H.264视频发布功能无法在RDK Ultra平台展示。
准备工作
RDK平台
-
RDK已烧录好Ubuntu 20.04/Ubuntu 22.04系统镜像
-
RDK已成功安装tros.b
-
可以通过网络访问RDK的PC
X86平台
-
X86环境已配置Ubuntu 20.04系统镜像
-
X86环境已安装X86版本 tros.b
图片发布使用介绍
循环读取本地的一张NV12格式图片并发布,使用图像编解码模块将图片压缩编码成JPEG格式,在PC的Web端展示图片。
RDK/X86平台
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 从tros.b的安装路径中拷贝出运行示例需要的图片文件
cp -r /opt/tros/${TROS_DISTRO}/lib/hobot_image_publisher/config/ .
# 启动launch文件
ros2 launch hobot_image_publisher hobot_image_publisher_demo.launch.py
图片发布结果分析
在运行 终端输出如下信息:
[INFO] [launch]: All log files can be found below /root/.ros/log/2022-08-19-12-58-02-288516-ubuntu-24492
[INFO] [launch]: Default logging verbosity is set to INFO
webserver has launch
[INFO] [hobot_image_pub-1]: process started with pid [24511]
[INFO] [hobot_codec_republish-2]: process started with pid [24513]
[INFO] [websocket-3]: process started with pid [24519]
输出log显示出webserver已启动,hobot_image_pub、hobot_codec_republish、websocket都正常运行
在PC端的浏览器输入 http://IP:8000
即可查看图像展示效果(IP为RDK/X86设备的IP地址):
视频发布使用介绍
读取本地video.list文件,获取list文件中的视频文件路径,循环读取视频文件并发布,先使用图像编解码模块将视频流解码成NV12格式图片,再使用图像编解码模块将图片压缩编码成JPEG格式,在PC的Web端展示图片。
RDK平台
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 从tros.b的安装路径中拷贝出运行示例需要的图片文件
cp -r /opt/tros/${TROS_DISTRO}/lib/hobot_image_publisher/config/ .
# 启动launch文件
ros2 launch hobot_image_publisher hobot_image_publisher_videolist_demo.launch.py
X86平台
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 从tros.b的安装路径中拷贝出运行示例需要的图片文件
cp -r /opt/tros/${TROS_DISTRO}/lib/hobot_image_publisher/config/ .
# 启动图片发布节点,使用本地MP4格式视频文件进行发布(可以根据自己的需求进行参数配置),暂不支持Web端显示
/opt/tros/${TROS_DISTRO}/lib/hobot_image_publisher/hobot_image_pub --ros-args -p image_source:=./config/video.list -p fps:=30 -p image_format:=mp4
视频发布结果分析
在运行终端输出如下信息:
[INFO] [launch]: All log files can be found below /root/.ros/log/2022-10-22-21-44-03-663907-ubuntu-702475
[INFO] [launch]: Default logging verbosity is set to INFO
webserver has launch
[INFO] [hobot_image_pub-1]: process started with pid [702597]
[INFO] [hobot_codec_republish-2]: process started with pid [702599]
[INFO] [hobot_codec_republish-3]: process started with pid [702601]
[INFO] [websocket-4]: process started with pid [702603]