Image processing using ROS and OpenCV

In this section, we will see an example of using cv_bridge for acquiring images from a camera driver, and converting and processing the images using OpenCV APIs. The following is how the example works:

  1. Subscribe the images from the camera driver from the topic /usb_cam/image_raw (sensor_msgs/Image)
  2. Convert the ROS images to the  OpenCV image type using CvBridge
  3. Process the OpenCV image using its APIs and find the edges on the image
  4. Convert the OpenCV image type of the edge detection to the ROS image messages and publish into the topic /edge_detector/processed_image

The step-by-step procedure to build this example follows:

Get Mastering ROS for Robotics Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.