O'Reilly logo

Learning Robotics using Python - Second Edition by Lentin Joseph

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying Kinect images using Python, ROS, and cv_bridge

The first section of the Python code is given in the following code fragment. It mainly involves importing rospy, sys, cv2, sensor_msgs, cv_bridge, and the numpy module. The sensor_msgs dependency imports the ROS data type of both image and camera information type. The cv_bridge module imports the CvBridge class for converting the ROS image data type to the OpenCV data type and vice versa:

import rospyimport sysimport cv2from sensor_msgs.msg import Image, CameraInfofrom cv_bridge import CvBridge, CvBridgeErrorfrom std_msgs.msg import Stringimport numpy as np

The following section of code is a class definition in Python that we will use to demonstrate CvBridge functions. The class is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required