image_transport_codec_plugin.h
Go to the documentation of this file.
1 #pragma once
2 
3 // SPDX-License-Identifier: BSD-3-Clause
4 // SPDX-FileCopyrightText: Czech Technical University in Prague
5 
13 #include <string>
14 
15 #include <dynamic_reconfigure/Config.h>
16 #include <sensor_msgs/Image.h>
17 #include <topic_tools/shape_shifter.h>
18 
21 
22 namespace image_transport_codecs
23 {
24 
59 {
60 public:
63 
66 
67  virtual ~ImageTransportCodecPlugin() = default;
68 
73  virtual void setLogHelper(const cras::LogHelperPtr& logHelper) = 0;
74 
80  virtual std::string getTransportName() const = 0;
81 
88  virtual ImageTransportCodec::EncodeResult encode(const sensor_msgs::Image& raw,
89  const dynamic_reconfigure::Config& config) const = 0;
90 
98  const dynamic_reconfigure::Config& config) const = 0;
99 
111  const topic_tools::ShapeShifter& compressed, const std::string& matchFormat) const = 0;
112 };
113 
137 template<typename Codec>
139 {
140 public:
141  void setLogHelper(const cras::LogHelperPtr& logHelper) override
142  {
143  this->codec.setCrasLogger(logHelper);
144  }
145 
146  std::string getTransportName() const override
147  {
148  return this->codec.getTransportName();
149  }
150 
151  ImageTransportCodec::EncodeResult encode(const sensor_msgs::Image& raw,
152  const dynamic_reconfigure::Config& config) const override
153  {
154  return this->codec.encode(raw, config);
155  }
156 
158  const dynamic_reconfigure::Config& config) const override
159  {
160  return this->codec.decode(compressed, config);
161  }
162 
164  const topic_tools::ShapeShifter& compressed, const std::string& matchFormat) const override
165  {
166  return this->codec.getCompressedImageContent(compressed, matchFormat);
167  }
168 
169 private:
170  Codec codec;
171 };
172 
173 }
cras::expected< cras::ShapeShifter, std::string > EncodeResult
Result of image encoding. Either a shapeshifter holding the compressed message, or error message...
virtual ImageTransportCodec::DecodeResult decode(const topic_tools::ShapeShifter &compressed, const dynamic_reconfigure::Config &config) const =0
Decode the given compressed image into a raw image.
virtual std::string getTransportName() const =0
Get the name of the codec/transport (used e.g. as topic suffix).
cras::expected< sensor_msgs::Image, std::string > DecodeResult
Result of image decoding. Either a sensor_msgs::Image holding the raw message, or error message...
boost::shared_ptr< ImageTransportCodecPlugin > Ptr
Shared pointer to ImageTransportCodecPlugin.
Convenience class for implementing image transport codec plugins, which just relays the whole API to ...
virtual ImageTransportCodec::EncodeResult encode(const sensor_msgs::Image &raw, const dynamic_reconfigure::Config &config) const =0
Encode the given raw image into the given shapeshifter object.
cras::expected< cras::optional< CompressedImageContent >, std::string > GetCompressedContentResult
Result of getting the actual compressed image data.
Base for all image transport codecs.
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.
void setLogHelper(const cras::LogHelperPtr &logHelper) override
Use the given log helper for logging messages.
virtual void setLogHelper(const cras::LogHelperPtr &logHelper)=0
Use the given log helper for logging messages.
ImageTransportCodec::DecodeResult decode(const topic_tools::ShapeShifter &compressed, const dynamic_reconfigure::Config &config) const override
Decode the given compressed image into a raw image.
Basic interface of an image transport codec plugin.
std::string getTransportName() const override
Get the name of the codec/transport (used e.g. as topic suffix).
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.
boost::shared_ptr< const ImageTransportCodecPlugin > ConstPtr
Shared pointer to const ImageTransportCodecPlugin.
virtual ImageTransportCodec::GetCompressedContentResult getCompressedImageContent(const topic_tools::ShapeShifter &compressed, const std::string &matchFormat) const =0
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.
::cras::LogHelper::Ptr LogHelperPtr


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