libopencv

Library for converts between ROS Image messages and OpenCV images using CvBridge.

class libopencv.LibOpenCV

Bases: object

OpenCV library.

cv2smi(cv, encode)

Convert from OpenCV image to sensor_msgs/Image.

Parameters
  • cv (ndarray) – OpenCV image before conversion.

  • encode (str) – Conversion encode. mono8: grayscale image. mono16 16-bit grayscale image. bgr8: color image with blue-green-red color order. rgb8: color image with red-green-blue color order. bgra8: BGR color image with an alpha channel. rgba8: RGB color image with an alpha channel.

Returns

converted Image. If False is returned, the conversion has failed.

Return type

sensor_msgs/Image

delete()
smci2cv(smci)

Convert from sensor_msgs/CompressedImage to OpenCV image.

Parameters

smci (sensor_msgs/CompressedImage) – CompressedImage before conversion.

Returns

Converted OpenCV image. If False is returned, the conversion has failed.

Return type

ndarray

smci2smi(smci, encode)

Convert from sensor_msgs/CompressedImage to sensor_msgs/Image.

Parameters
  • smci (sensor_msgs/CompressedImage) – CompressedImage before conversion.

  • encode (str) – Conversion encode. mono8: grayscale image. mono16 16-bit grayscale image. bgr8: color image with blue-green-red color order. rgb8: color image with red-green-blue color order. bgra8: BGR color image with an alpha channel. rgba8: RGB color image with an alpha channel.

Returns

converted Image. If False is returned, the conversion has failed.

Return type

sensor_msgs/Image

smi2cv(smi, encode, is_depth=False)

Convert from sensor_msgs/Image to OpenCV image.

Parameters
  • smi (sensor_msgs/Image) – Image before conversion.

  • encode (str) – Conversion encode. mono8: grayscale image. mono16 16-bit grayscale image. bgr8: color image with blue-green-red color order. rgb8: color image with red-green-blue color order. bgra8: BGR color image with an alpha channel. rgba8: RGB color image with an alpha channel.

  • is_depth (bool, optional) – Whether to convert depth image. Defaults to False.

Returns

Converted OpenCV image. If False is returned, the conversion has failed.

Return type

ndarray