In ROS, we have a node that allows us to show images coming from a camera on the fly. You only need a camera to do this. It is also possible to reproduce a video with a simple node in ROS but here we are going to use your laptop's webcam. The example6
node implements a basic camera capture program using OpenCV and ROS bindings to convert cv::Mat
images into ROS image messages that can be published in a topic. This node publishes the camera frames in the /camera
topic.
We are only going to run the node with a launch file created to do so. The code inside the node is still new for the reader, but in the upcoming chapters, we will cover how to work with cameras and images in ROS so that we can come back to this node and understand every bit of the code:
roslaunch chapter3_tutorials example6.launch
Once the node is running, we can list the topics (rostopic list
) and see that the /camera
topic is there. A straightforward way to see that we are actually capturing images...