1.安装async-web-server
sudo apt-get install ros-kinetic-async-web-server-cpp
2.安装web_video_server(假设已经有catkin_ws工作空间)
cd ~/catkin_ws/src
git clone https://github.com/RobotWebTools/web_video_server
3.安装usb cam package
cd ~/catkin_ws/src
git clone https://github.com/ros-drivers/usb_cam.git
4.查看电脑摄像头设备
ls -ltrh /dev/video*
修改usb cam的launch文件,输入想要使用的摄像头设备。
5.启动摄像头和网络监听
roslaunch usb_cam usb_cam-test.launch
rosrun web_video_server web_video_server
打开一个浏览器,输入地址
http://localhost:8080/stream?topic=/usb_cam/image_raw
其中的localhost和/usb_cam/image_raw可根据自己的需要更改。
比如,在另一台电脑上输入
http://192.168.31.204:8080/stream?topic=/usb_cam/image_raw,
192.168.31.204是连接摄像头的PC的IP地址。
参考
https://www.programmersought.com/article/5011943312/