7. Web page real-time monitoring 7.1. Environment Construction 7.2. modify the launch file 7.3. effect demonstration
sudo apt-get install ros-melodic-async-web-server-cpp ros-melodic-web-video-server ros-melodic-usb-cam
First make sure that the USB camera link is correct, enter the following command to check that the USB device number exists and is video0
xxxxxxxxxx
ll /dev
If the execute permission is not enough, you need to add the execute permission
xxxxxxxxxx
sudo chmod 777 /dev/video*
xxxxxxxxxx
sudo vim /opt/ros/melodic/share/usb_cam/launch/usb_cam-test.launch
Keep hitting the keyboard [d] to delete everything. Click [i] on the keyboard to enter the edit mode, and write the following content into it.
< launch >
< arg name = "open_view" default = "false" />
< 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 >
<!-- web_video_server -->
< node pkg = "web_video_server" type = "web_video_server" name = "web_video_server" output = "screen" />
<!-- image_view -->
< group if = "$(arg open_view)" >
< 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 >
</ group >
</ launch >
Click the [ESC] key twice (or multiple times), click the keyboard [shift plus;], enter [wq], and click the [Enter] key.
open terminal, start
xxxxxxxxxx
roslaunch usb_cam usb_cam-test.launch
xxxxxxxxxx
http://localhost:8080/
xxxxxxxxxx
http://192.168.2.93:8080/
Note: It is recommended to use Google Chrome or mobile QQ browser, other browsers may not be able to open the image
Click [image_raw] to view the camera image in real time, and click [Snapshot] to display only one frame of image.