Public Types | Public Member Functions | Private Attributes | List of all members
image_transport_codecs::CompressedCodec Class Reference

Image transport codec corresponding to compressed_image_transport. More...

#include <compressed_codec.h>

Inheritance diagram for image_transport_codecs::CompressedCodec:
Inheritance graph
[legend]

Public Types

typedef cras::expected< sensor_msgs::CompressedImage, std::string > EncodeResult
 Result of image encoding. Either a sensor_msgs::CompressedImage message, or error message. More...
 
- Public Types inherited from image_transport_codecs::ImageTransportCodec
typedef boost::shared_ptr< const ImageTransportCodecConstPtr
 Shared pointer to const ImageTransportCodec. More...
 
typedef cras::expected< sensor_msgs::Image, std::string > DecodeResult
 Result of image decoding. Either a sensor_msgs::Image holding the raw message, or error message. More...
 
typedef cras::expected< cras::ShapeShifter, std::string > EncodeResult
 Result of image encoding. Either a shapeshifter holding the compressed message, or error message. More...
 
typedef cras::expected< cras::optional< CompressedImageContent >, std::string > GetCompressedContentResult
 Result of getting the actual compressed image data. More...
 
typedef boost::shared_ptr< ImageTransportCodecPtr
 Shared pointer to ImageTransportCodec. More...
 

Public Member Functions

 CompressedCodec (const cras::LogHelperPtr &logHelper=std::make_shared< cras::NodeLogHelper >())
 Create an instance of the codec. More...
 
ImageTransportCodec::DecodeResult decode (const sensor_msgs::CompressedImage &compressed, const compressed_image_transport::CompressedSubscriberConfig &config) const
 Decode the given compressed image using the given subscriber config. More...
 
ImageTransportCodec::DecodeResult decode (const sensor_msgs::CompressedImage &compressed) const
 Decode the given compressed image using the default subscriber config. More...
 
ImageTransportCodec::DecodeResult decode (const topic_tools::ShapeShifter &compressed, const dynamic_reconfigure::Config &config) const override
 Decode the given compressed image into a raw image. More...
 
ImageTransportCodec::DecodeResult decompressJPEG (const std::vector< uint8_t > &data, const std::string &source_encoding, const std_msgs::Header &header) const
 Fast method to decompress a JPEG image. It does not support PNG images (use decode() if you are not sure). More...
 
EncodeResult encode (const sensor_msgs::Image &raw, const compressed_image_transport::CompressedPublisherConfig &config) const
 Encode the given raw image using the given publisher config. More...
 
ImageTransportCodec::EncodeResult encode (const sensor_msgs::Image &raw, const dynamic_reconfigure::Config &config) const override
 Encode the given raw image into the given shapeshifter object. More...
 
ImageTransportCodec::GetCompressedContentResult getCompressedImageContent (const topic_tools::ShapeShifter &compressed, const std::string &matchFormat) const override
 Return the part of the encoded message that represents the actual image data (i.e. the part that can be passed to external decoders or saved to a file). If the codec messages have no such meaning, empty result is returned. More...
 
ImageTransportCodec::GetCompressedContentResult getCompressedImageContent (const sensor_msgs::CompressedImage &compressed, const std::string &matchFormat) const
 This function returns the bytes of the actual PNG/RVL image (skipping the codec-specific header). More...
 
std::string getTransportName () const override
 Get the name of the codec/transport (used e.g. as topic suffix). More...
 
 ~CompressedCodec () override
 
- Public Member Functions inherited from image_transport_codecs::ImageTransportCodec
DecodeResult decode (const topic_tools::ShapeShifter &compressed) const
 Decode the given compressed image into a raw image using the default decompression parameters. More...
 
DecodeResult decode (const topic_tools::ShapeShifter &compressed, const XmlRpc::XmlRpcValue &config) const
 Decode the given compressed image into a raw image. More...
 
DecodeResult decode (const topic_tools::ShapeShifter &compressed, const ros::NodeHandle &nh, const std::string &param) const
 Decode the given compressed image into a raw image. More...
 
template<typename Config >
DecodeResult decode (const topic_tools::ShapeShifter &compressed, const Config &config) const
 Decode the given compressed image into a raw image. More...
 
EncodeResult encode (const sensor_msgs::Image &raw) const
 Encode the given raw image into the given shapeshifter object using the default compression parameters. More...
 
EncodeResult encode (const sensor_msgs::Image &raw, const XmlRpc::XmlRpcValue &config) const
 Encode the given raw image into the given shapeshifter object. More...
 
EncodeResult encode (const sensor_msgs::Image &raw, const ros::NodeHandle &nh, const std::string &param) const
 Encode the given raw image into the given shapeshifter object. More...
 
template<typename Config >
EncodeResult encode (const sensor_msgs::Image &raw, const Config &config) const
 Encode the given raw image into the given shapeshifter object. More...
 
GetCompressedContentResult getCompressedImageContent (const topic_tools::ShapeShifter &compressed) const
 Return the part of the encoded message that represents the actual image data (i.e. the part that can be passed to external decoders or saved to a file). If the codec messages have no such meaning, empty result is returned. More...
 
 ImageTransportCodec (const cras::LogHelperPtr &logHelper)
 Create an instance of the codec. More...
 
virtual ~ImageTransportCodec ()
 
- Public Member Functions inherited from cras::HasLogger
::cras::LogHelperConstPtr getCrasLogger () const
 
 HasLogger (const ::cras::LogHelperPtr &log)
 
void setCrasLogger (const ::cras::LogHelperPtr &log)
 

Private Attributes

std::unique_ptr< CompressedCodecPrivate > data
 Private implementation data. More...
 

Additional Inherited Members

- Protected Attributes inherited from cras::HasLogger
::cras::LogHelperPtr log
 

Detailed Description

Image transport codec corresponding to compressed_image_transport.

This codec exposes the functionality of compressed_image_transport so that it can be used directly without the need to go through running a node and publishing on a topic. E.g.

sensor_msgs::Image raw = ...;
auto result = codec.encode(raw);
if (!result)
{
ROS_ERROR_STREAM("Compression failed: " << result.error());
return false;
}
sensor_msgs::CompressedImage compressed = result.value();

Definition at line 53 of file compressed_codec.h.

Member Typedef Documentation

◆ EncodeResult

typedef cras::expected<sensor_msgs::CompressedImage, std::string> image_transport_codecs::CompressedCodec::EncodeResult

Result of image encoding. Either a sensor_msgs::CompressedImage message, or error message.

Definition at line 57 of file compressed_codec.h.

Constructor & Destructor Documentation

◆ CompressedCodec()

image_transport_codecs::CompressedCodec::CompressedCodec ( const cras::LogHelperPtr logHelper = std::make_shared< cras::NodeLogHelper >())
explicit

Create an instance of the codec.

Parameters
[in]logHelperThe logger to use for error messages not directly related to the currently processed image.

◆ ~CompressedCodec()

image_transport_codecs::CompressedCodec::~CompressedCodec ( )
override

Member Function Documentation

◆ decode() [1/3]

ImageTransportCodec::DecodeResult image_transport_codecs::CompressedCodec::decode ( const sensor_msgs::CompressedImage &  compressed,
const compressed_image_transport::CompressedSubscriberConfig &  config 
) const

Decode the given compressed image using the given subscriber config.

Parameters
[in]compressedThe image to decode.
[in]configConfiguration of the decoder (corresponds to the dynamic_reconfigure parameters of subscriber).
Returns
The decoded raw image, or an error.
See also
Corresponding C API function: compressedCodecDecode().

◆ decode() [2/3]

ImageTransportCodec::DecodeResult image_transport_codecs::CompressedCodec::decode ( const sensor_msgs::CompressedImage &  compressed) const

Decode the given compressed image using the default subscriber config.

Parameters
[in]compressedThe image to decode.
Returns
The decoded raw image, or an error.
See also
Corresponding C API function: compressedCodecDecode().

◆ decode() [3/3]

ImageTransportCodec::DecodeResult image_transport_codecs::CompressedCodec::decode ( const topic_tools::ShapeShifter compressed,
const dynamic_reconfigure::Config &  config 
) const
overridevirtual

Decode the given compressed image into a raw image.

Parameters
[in]compressedThe shapeshifter of the compressed image to be decoded.
[in]configConfig of the decompression (if it has any parameters).
Returns
The decoded raw image (if decoding succeeds), or an error message.

Implements image_transport_codecs::ImageTransportCodec.

◆ decompressJPEG()

ImageTransportCodec::DecodeResult image_transport_codecs::CompressedCodec::decompressJPEG ( const std::vector< uint8_t > &  data,
const std::string &  source_encoding,
const std_msgs::Header header 
) const

Fast method to decompress a JPEG image. It does not support PNG images (use decode() if you are not sure).

Parameters
[in]dataThe bytes of the JPEG image.
[in]source_encodingColor encoding of the raw image.
[in]headerHeader to be added to the output image.
Returns
The decoded raw image, or an error.

◆ encode() [1/2]

EncodeResult image_transport_codecs::CompressedCodec::encode ( const sensor_msgs::Image &  raw,
const compressed_image_transport::CompressedPublisherConfig &  config 
) const

Encode the given raw image using the given publisher config.

Parameters
[in]rawThe raw image to encode.
[in]configConfiguration of the encoder (corresponds to the dynamic_reconfigure parameters of publisher).
Returns
The encoded image, or an error.
See also
Corresponding C API function: compressedCodecEncode().

◆ encode() [2/2]

ImageTransportCodec::EncodeResult image_transport_codecs::CompressedCodec::encode ( const sensor_msgs::Image &  raw,
const dynamic_reconfigure::Config &  config 
) const
overridevirtual

Encode the given raw image into the given shapeshifter object.

Parameters
[in]rawThe input raw image.
[in]configConfig of the compression (if it has any parameters).
Returns
The output shapeshifter holding the compressed image message (if encoding succeeds), or an error message.

Implements image_transport_codecs::ImageTransportCodec.

◆ getCompressedImageContent() [1/2]

ImageTransportCodec::GetCompressedContentResult image_transport_codecs::CompressedCodec::getCompressedImageContent ( const topic_tools::ShapeShifter compressed,
const std::string &  matchFormat 
) const
overridevirtual

Return the part of the encoded message that represents the actual image data (i.e. the part that can be passed to external decoders or saved to a file). If the codec messages have no such meaning, empty result is returned.

Parameters
[in]compressedThe compressed image.
[in]matchFormatIf nonempty, the image data is only returned if their format field would match the given one. The matching should be case-insensitive.
Returns
If it makes sense, the contained image bytes. If not, empty result. If an error occurred, it is reported as the unexpected result.

Implements image_transport_codecs::ImageTransportCodec.

◆ getCompressedImageContent() [2/2]

ImageTransportCodec::GetCompressedContentResult image_transport_codecs::CompressedCodec::getCompressedImageContent ( const sensor_msgs::CompressedImage &  compressed,
const std::string &  matchFormat 
) const

This function returns the bytes of the actual PNG/RVL image (skipping the codec-specific header).

Parameters
[in]compressedThe compressed image.
[in]matchFormatIf nonempty, the image data is only returned if their format field would match the given one. The matching should be case-insensitive.
Returns
The contained image bytes.

◆ getTransportName()

std::string image_transport_codecs::CompressedCodec::getTransportName ( ) const
overridevirtual

Get the name of the codec/transport (used e.g. as topic suffix).

Note
This name has to be unique among all defined codecs.
Returns
The transport name.

Implements image_transport_codecs::ImageTransportCodec.

Member Data Documentation

◆ data

std::unique_ptr<CompressedCodecPrivate> image_transport_codecs::CompressedCodec::data
private

Private implementation data.

Definition at line 127 of file compressed_codec.h.


The documentation for this class was generated from the following file:


image_transport_codecs
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:33:19