5#ifndef CCF_COMMON_DATA_FRAME_HPP_H_
6#define CCF_COMMON_DATA_FRAME_HPP_H_
8#include <ifw/fnd/defs/dataType.hpp>
10#include <ifw/core/utils/param/parameter.hpp>
26 const int16_t frame_q_nb);
59 void Store(
const void* buffer,
62 const int64_t cam_frame_count,
63 const int64_t int_frame_count,
64 const int64_t sub_frame_count,
65 const int64_t exp_nb_sub_frames,
66 const ifw::fnd::datatype::DataType data_type,
67 const int32_t offset_x,
68 const int32_t offset_y,
71 const int32_t depth = 1);
74 void AddData(
const void* buffer,
143 template <
class TYPE>
146 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
148 if constexpr(std::is_arithmetic_v<TYPE>) {
150 m_meta_data[name] = ifw::core::utils::param::Parameter(name, std::to_string(value));
151 }
else if constexpr(std::is_same_v<TYPE, std::string>) {
153 m_meta_data[name] = ifw::core::utils::param::Parameter(name, value);
156 static_assert(std::is_arithmetic_v<TYPE> || std::is_same_v<TYPE, std::string>,
157 "Unsupported type: AddMetaData only supports numeric types and "
166 template <
class TYPE>
169 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
170 auto it = m_meta_data.find(name);
171 if (it == m_meta_data.end()) {
174 it->second.GetValue(value);
179 std::string
ToString(
const bool full =
false)
const;
207 void Initialise(
const std::string& frame_id =
"",
208 const int64_t frame_nb = -1);
211 std::string m_frame_id;
212 int64_t m_frame_q_nb;
214 int64_t m_cam_frame_count{0};
215 int64_t m_int_frame_count{0};
217 int64_t m_sub_frame_count{0};
218 int64_t m_exp_nb_sub_frames{0};
220 uint8_t m_consumer_count{0};
222 double m_handling_start_time{0.0};
224 void* m_buffer{
nullptr};
226 uint32_t m_expected_size{0};
227 uint32_t m_cur_allocated{0};
228 bool m_completed{
false};
232 ifw::fnd::datatype::DataType m_data_type{ifw::fnd::datatype::DataType::UNSPECIFIED};
233 int32_t m_offset_x{1};
234 int32_t m_offset_y{1};
239 std::map<std::string, ifw::core::utils::param::Parameter> m_meta_data;
241 template <
class DATA_TYPE>
243 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
245 DATA_TYPE* p =
static_cast<DATA_TYPE*
>(m_buffer);
247 sum +=
static_cast<DATA_TYPE
>(*p++);
Class to be used as parent all CCF classes.
Definition base.hpp:120
Frame class used to store the data and metadata for one frames received from the camera.
Definition dataFrame.hpp:18
std::string ToString(const bool full=false) const
Generate a representative (short) string representation (summary) of the object.
Definition dataFrame.cpp:64
ifw::fnd::datatype::DataType GetDataType() const
Definition dataFrame.cpp:313
bool GetCompleted() const
Return true if the image in the object is complete according to width/height/data type.
Definition dataFrame.cpp:233
double GetHandlingStartTime() const
Get the time for starting the handling of the frame.
Definition dataFrame.cpp:334
uint32_t GetBufferSize() const
Get the size of the internal buffer allocated, in bytes.
Definition dataFrame.cpp:278
int32_t GetWidth() const
Get the width of the ROI applied by the camera.
Definition dataFrame.cpp:298
void RemoveMetaData(const std::string &name)
Remove a given metadata parameter from the object.
Definition dataFrame.cpp:366
void ResetDataSize()
Reset the size of the image. This indicates that no image is stored in the object.
Definition dataFrame.cpp:127
uint32_t GetDataSize() const
Return the size in bytes of the image.
Definition dataFrame.cpp:273
int32_t GetDepth() const
Get the number of frames if a three dimensional image is contained in the object.
Definition dataFrame.cpp:308
uint8_t GetConsumerCount() const
Definition dataFrame.cpp:103
void AddData(const void *buffer, const uint32_t size)
Add a new chunk of data in the image buffer. Used to build up the image incrementally.
Definition dataFrame.cpp:195
double GetDataSum() const
Compute the data sum of all pixels.
Definition dataFrame.cpp:374
~DataFrame()
Definition dataFrame.cpp:39
void SetCompleted()
Mark the frame as completed.
Definition dataFrame.cpp:238
void * GetBufferReadWrite() const
Definition dataFrame.cpp:268
int32_t GetHeight() const
Get the height of the ROI applied by the camera.
Definition dataFrame.cpp:303
const std::string & GetFrameId() const
Return the frame ID allocated.
Definition dataFrame.cpp:54
int32_t GetOffsetY() const
Get vertical offset of the ROI applied by the camera.
Definition dataFrame.cpp:293
int32_t GetOffsetX() const
Get horisontal offset of the ROI applied by the camera.
Definition dataFrame.cpp:288
double GetTime() const
Get the current time stamp stored in the object.
Definition dataFrame.cpp:283
DataFrame & operator=(const DataFrame &source)
Definition dataFrame.cpp:323
int64_t GetExpNbSubFrames() const
Expected number of sub-frames if the data of a frame is received in sub-frames (blocks).
Definition dataFrame.cpp:258
const void * GetBuffer() const
Get read-only pointer to internal image buffer.
Definition dataFrame.cpp:263
int64_t GetSubFrameCount() const
Number of a sub-frame if the data of a frame is received in sub-frames (blocks) (first sub-frame == 1...
Definition dataFrame.cpp:253
int64_t GetCamFrameCount() const
Definition dataFrame.cpp:243
void Store(const void *buffer, const uint32_t size, const double time, const int64_t cam_frame_count, const int64_t int_frame_count, const int64_t sub_frame_count, const int64_t exp_nb_sub_frames, const ifw::fnd::datatype::DataType data_type, const int32_t offset_x, const int32_t offset_y, const int32_t width, const int32_t height, const int32_t depth=1)
Store an image frame (or sub-frame) in the object.
Definition dataFrame.cpp:132
int16_t GetFrameQNb() const
Return the frame queue number, when used in a queue.
Definition dataFrame.cpp:59
int64_t GetIntFrameCount() const
Internall frame counter, counting the frames receives since the last Start command (first frame == 1)...
Definition dataFrame.cpp:248
double GetHandlingTime() const
Get handling time (duration for handling the frame in the given context).
Definition dataFrame.cpp:339
void SetHandlingStartTime(const double time)
Set the start time for handling handling the frame.
Definition dataFrame.cpp:329
void Reset()
Definition dataFrame.cpp:47
bool HasMetadata(const std::string &name, TYPE &value) const
Get a parameter value from the configuration.
Definition dataFrame.hpp:167
void AddMetaData(const std::string &name, TYPE &value)
Definition dataFrame.hpp:144
int32_t GetResolution() const
Get the resolution (bytes/pixel) of the image currently stored in the object.
Definition dataFrame.cpp:318
void SetConsumerCount(const uint8_t count)
Definition dataFrame.cpp:92
void DecrementConsumerCount(const uint8_t decr=1)
Definition dataFrame.cpp:108
DataFrame()
Definition dataFrame.cpp:34
log4cplus::Logger & Logger()
Definition base.cpp:23