上一篇文章中我們實現了ros節點讀取usb camera數據,然後通過topic形式發佈數據,接下來我們需要在web中實現usb camera數據的顯示,步驟如下:
1、安裝依賴庫async-web-server
sudo apt-get install ros-kinetic-async-web-server-cpp
2、下載ros工程倉庫
git clone https://github.com/RobotWebTools/web_video_server
3、編譯並運行
mkdir src
mv web_video_server src/
cd …/
catkin build
roscore
#關於usb_cam節點不清楚地方,可以自己查看此篇文章:https://blog.csdn.net/pengrui18/article/details/88958487
roslaunch usb_cam usb_cam-test.launch
#啓動web video server服務器
rosrun web_video_server web_video_server
4、在web中顯示效果
打開瀏覽器輸入如下地址:
http://localhost:8080/stream?topic=/usb_cam/image_raw
此處/usb_cam/image_raw表示usb camera的rostopic節點原始數據
效果圖如下: