class documentation

class CvBridge(object):

View In Hierarchy

The CvBridge is an object that converts between OpenCV Images and ROS Image messages.

Method __init__ Undocumented
Method compressed_imgmsg_to_cv2 Convert a sensor_msgs::CompressedImage message to an OpenCV :cpp:type:`cv::Mat`.
Method cv2_to_compressed_imgmsg Convert an OpenCV :cpp:type:`cv::Mat` type to a ROS sensor_msgs::CompressedImage message.
Method cv2_to_imgmsg Convert an OpenCV :cpp:type:`cv::Mat` type to a ROS sensor_msgs::Image message.
Method cvtype2_to_dtype_with_channels Undocumented
Method dtype_with_channels_to_cvtype2 Undocumented
Method encoding_to_cvtype2 Undocumented
Method encoding_to_dtype_with_channels Undocumented
Method imgmsg_to_cv2 Convert a sensor_msgs::Image message to an OpenCV :cpp:type:`cv::Mat`.
Instance Variable cvdepth_to_numpy_depth Undocumented
Instance Variable cvtype_to_name Undocumented
Instance Variable numpy_type_to_cvtype Undocumented
def __init__(self):

Undocumented

def compressed_imgmsg_to_cv2(self, cmprs_img_msg, desired_encoding='passthrough'):

Convert a sensor_msgs::CompressedImage message to an OpenCV :cpp:type:`cv::Mat`.

If desired_encoding is "passthrough", then the returned image has the same format as img_msg. Otherwise desired_encoding must be one of the standard image encodings

This function returns an OpenCV :cpp:type:`cv::Mat` message on success, or raises cv_bridge.CvBridgeError on failure.

If the image only has one channel, the shape has size 2 (width and height)

Parameters
cmprs_img_msgA :cpp:type:`sensor_msgs::CompressedImage` message
desired_encoding

The encoding of the image data, one of the following strings:

  • "passthrough"
  • one of the standard strings in sensor_msgs/image_encodings.h
Returns
:cpp:type:`cv::Mat`Undocumented
Raises
CvBridgeErrorwhen conversion is not possible.
def cv2_to_compressed_imgmsg(self, cvim, dst_format='jpg'):

Convert an OpenCV :cpp:type:`cv::Mat` type to a ROS sensor_msgs::CompressedImage message.

This function returns a sensor_msgs::Image message on success, or raises cv_bridge.CvBridgeError on failure.

Parameters
cvimAn OpenCV :cpp:type:`cv::Mat`
dst_format

The format of the image data, one of the following strings:

Returns
A sensor_msgs.msg.CompressedImage messageUndocumented
Raises
CvBridgeErrorwhen the cvim has a type that is incompatible with format
def cv2_to_imgmsg(self, cvim, encoding='passthrough', header=None):

Convert an OpenCV :cpp:type:`cv::Mat` type to a ROS sensor_msgs::Image message.

If encoding is "passthrough", then the message has the same encoding as the image's OpenCV type. Otherwise desired_encoding must be one of the standard image encodings

This function returns a sensor_msgs::Image message on success, or raises cv_bridge.CvBridgeError on failure.

Parameters
cvimAn OpenCV :cpp:type:`cv::Mat`
encoding

The encoding of the image data, one of the following strings:

  • "passthrough"
  • one of the standard strings in sensor_msgs/image_encodings.h
headerA std_msgs.msg.Header message
Returns
A sensor_msgs.msg.Image messageUndocumented
Raises
CvBridgeErrorwhen the cvim has a type that is incompatible with encoding
def cvtype2_to_dtype_with_channels(self, cvtype):

Undocumented

def dtype_with_channels_to_cvtype2(self, dtype, n_channels):

Undocumented

def encoding_to_cvtype2(self, encoding):

Undocumented

def encoding_to_dtype_with_channels(self, encoding):

Undocumented

def imgmsg_to_cv2(self, img_msg, desired_encoding='passthrough'):

Convert a sensor_msgs::Image message to an OpenCV :cpp:type:`cv::Mat`.

If desired_encoding is "passthrough", then the returned image has the same format as img_msg. Otherwise desired_encoding must be one of the standard image encodings

This function returns an OpenCV :cpp:type:`cv::Mat` message on success, or raises cv_bridge.CvBridgeError on failure.

If the image only has one channel, the shape has size 2 (width and height)

Parameters
img_msgA :cpp:type:`sensor_msgs::Image` message
desired_encoding

The encoding of the image data, one of the following strings:

  • "passthrough"
  • one of the standard strings in sensor_msgs/image_encodings.h
Returns
:cpp:type:`cv::Mat`Undocumented
Raises
CvBridgeErrorwhen conversion is not possible.
cvdepth_to_numpy_depth =

Undocumented

cvtype_to_name: dict =

Undocumented

numpy_type_to_cvtype: dict[str, str] =

Undocumented