5 #ifndef BASE_SAMPLES_FRAME_H__ 6 #define BASE_SAMPLES_FRAME_H__ 12 #include <base/Time.hpp> 15 namespace base {
namespace samples {
namespace frame {
20 void set(
const std::string &name,
const std::string &data);
83 void copyImageIndependantAttributes(
const Frame &other);
86 void init(
const Frame &other,
bool bcopy =
true);
88 void init(uint16_t width, uint16_t height, uint8_t depth=8,
frame_mode_t mode=
MODE_GRAYSCALE,
const uint8_t val = 0,
size_t sizeInBytes=0);
91 void reset(
int const val = 0);
93 void swap(
Frame &frame);
97 void setHDR(
bool value);
99 bool isCompressed()
const;
101 bool isGrayscale()
const;
111 uint32_t getChannelCount()
const;
117 static frame_mode_t toFrameMode(
const std::string &str);
126 uint32_t getPixelSize()
const;
134 uint32_t getRowSize()
const;
139 uint32_t getNumberOfBytes()
const;
145 uint32_t getPixelCount()
const;
147 uint32_t getDataDepth()
const;
149 void setDataDepth(uint32_t value);
155 uint16_t getWidth()
const;
157 uint16_t getHeight()
const;
159 const std::vector<uint8_t> &getImage()
const;
161 void validateImageSize(
size_t sizeToValidate)
const;
163 void setImage(
const std::vector<uint8_t> &newImage);
167 void setImage(
const char *data,
size_t newImageSize);
169 void setImage(
const uint8_t *data,
size_t newImageSize);
171 uint8_t *getImagePtr();
173 const uint8_t *getImageConstPtr()
const;
175 uint8_t* getLastByte();
177 const uint8_t* getLastConstByte()
const;
179 bool hasAttribute(
const std::string &name)
const;
184 static T default_value;
185 std::stringstream strstr;
187 std::vector<frame_attrib_t>::const_iterator _iter = attributes.begin();
188 for (;_iter != attributes.end();_iter++)
190 if (_iter->name_ == name)
193 strstr << _iter->data_;
198 return default_value;
201 bool deleteAttribute(
const std::string &name);
207 std::stringstream strstr;
209 std::vector<frame_attrib_t>::iterator _iter = attributes.begin();
210 for (;_iter != attributes.end();_iter++)
212 if (_iter->name_ == name)
214 _iter->set(name,strstr.str());
220 attributes.back().set(name,strstr.str());
224 template <
typename Tp> Tp&
at(
unsigned int column,
unsigned int row)
226 if(column >= size.width || row >= size.height )
227 throw std::runtime_error(
"out of index");
228 return *((Tp*)(getImagePtr()+row*getRowSize()+column*getPixelSize()));
bool operator!=(const Motion2D &lhs, const Motion2D &rhs)
Definition: Motion2D.cpp:10
uint16_t width
Definition: Frame.hpp:32
std::string name_
Definition: Frame.hpp:19
frame_size_t(uint16_t w, uint16_t h)
Definition: Frame.hpp:25
Tp & at(unsigned int column, unsigned int row)
Definition: Frame.hpp:224
frame_status_t
Definition: Frame.hpp:56
std::string data_
Definition: Frame.hpp:18
void setAttribute(const std::string &name, const T &data)
Definition: Frame.hpp:204
std::vector< frame_attrib_t > attributes
Definition: Frame.hpp:242
uint32_t data_depth
Definition: Frame.hpp:253
T getAttribute(const std::string &name) const
Definition: Frame.hpp:182
uint32_t pixel_size
Definition: Frame.hpp:260
frame_status_t frame_status
Definition: Frame.hpp:271
uint32_t row_size
Definition: Frame.hpp:264
frame_mode_t frame_mode
Definition: Frame.hpp:268
frame_size_t size
Definition: Frame.hpp:245
base::Time time
Definition: Frame.hpp:235
base::Time time
Definition: Frame.hpp:276
std::vector< uint8_t > image
Definition: Frame.hpp:240
bool operator==(const Motion2D &lhs, const Motion2D &rhs)
Definition: Motion2D.cpp:5
frame_mode_t
Definition: Frame.hpp:36
uint16_t height
Definition: Frame.hpp:33
Definition: LinearAngular6DCommand.hpp:8
frame_size_t()
Definition: Frame.hpp:24
Definition: Frame.hpp:274
Frame second
Definition: Frame.hpp:278
uint32_t id
Definition: Frame.hpp:279
Frame first
Definition: Frame.hpp:277
base::Time received_time
Definition: Frame.hpp:237