7#ifndef CCF_COMMON_DATA_FRAME_HPP_H_
8#define CCF_COMMON_DATA_FRAME_HPP_H_
10#include <ifw/fnd/defs/dataType.hpp>
12#include <ifw/core/utils/param/parameter.hpp>
28 const int16_t frame_q_nb);
61 void Store(
const void* buffer,
64 const int64_t cam_frame_count,
65 const int64_t int_frame_count,
66 const int64_t sub_frame_count,
67 const int64_t exp_nb_sub_frames,
68 const ifw::fnd::datatype::DataType data_type,
69 const int32_t offset_x,
70 const int32_t offset_y,
73 const int32_t depth = 1);
76 void AddData(
const void* buffer,
145 template <
class TYPE>
148 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
150 if constexpr(std::is_arithmetic_v<TYPE>) {
152 m_meta_data[name] = ifw::core::utils::param::Parameter(name, std::to_string(value));
153 }
else if constexpr(std::is_same_v<TYPE, std::string>) {
155 m_meta_data[name] = ifw::core::utils::param::Parameter(name, value);
158 static_assert(std::is_arithmetic_v<TYPE> || std::is_same_v<TYPE, std::string>,
159 "Unsupported type: AddMetaData only supports numeric types and "
168 template <
class TYPE>
171 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
172 auto it = m_meta_data.find(name);
173 if (it == m_meta_data.end()) {
176 it->second.GetValue(value);
181 std::string
ToString(
const bool full =
false)
const;
209 void Initialise(
const std::string& frame_id =
"",
210 const int64_t frame_nb = -1);
213 std::string m_frame_id;
214 int64_t m_frame_q_nb;
216 int64_t m_cam_frame_count{0};
217 int64_t m_int_frame_count{0};
219 int64_t m_sub_frame_count{0};
220 int64_t m_exp_nb_sub_frames{0};
222 uint8_t m_consumer_count{0};
224 double m_handling_start_time{0.0};
226 void* m_buffer{
nullptr};
228 uint32_t m_expected_size{0};
229 uint32_t m_cur_allocated{0};
230 bool m_completed{
false};
234 ifw::fnd::datatype::DataType m_data_type{ifw::fnd::datatype::DataType::UNSPECIFIED};
235 int32_t m_offset_x{1};
236 int32_t m_offset_y{1};
241 std::map<std::string, ifw::core::utils::param::Parameter> m_meta_data;
243 template <
class DATA_TYPE>
245 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
247 DATA_TYPE* p =
static_cast<DATA_TYPE*
>(m_buffer);
249 sum +=
static_cast<DATA_TYPE
>(*p++);
Base()
Definition base.cpp:121
Frame class used to store the data and metadata for one frames received from the camera.
Definition dataFrame.hpp:20
std::string ToString(const bool full=false) const
Generate a representative (short) string representation (summary) of the object.
Definition dataFrame.cpp:65
ifw::fnd::datatype::DataType GetDataType() const
Definition dataFrame.cpp:312
bool GetCompleted() const
Return true if the image in the object is complete according to width/height/data type.
Definition dataFrame.cpp:232
double GetHandlingStartTime() const
Get the time for starting the handling of the frame.
Definition dataFrame.cpp:333
uint32_t GetBufferSize() const
Get the size of the internal buffer allocated, in bytes.
Definition dataFrame.cpp:277
int32_t GetWidth() const
Get the width of the ROI applied by the camera.
Definition dataFrame.cpp:297
void RemoveMetaData(const std::string &name)
Remove a given metadata parameter from the object.
Definition dataFrame.cpp:365
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:272
int32_t GetDepth() const
Get the number of frames if a three dimensional image is contained in the object.
Definition dataFrame.cpp:307
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:194
double GetDataSum() const
Compute the data sum of all pixels.
Definition dataFrame.cpp:373
~DataFrame()
Definition dataFrame.cpp:40
void SetCompleted()
Mark the frame as completed.
Definition dataFrame.cpp:237
void * GetBufferReadWrite() const
Definition dataFrame.cpp:267
int32_t GetHeight() const
Get the height of the ROI applied by the camera.
Definition dataFrame.cpp:302
const std::string & GetFrameId() const
Return the frame ID allocated.
Definition dataFrame.cpp:55
int32_t GetOffsetY() const
Get vertical offset of the ROI applied by the camera.
Definition dataFrame.cpp:292
int32_t GetOffsetX() const
Get horisontal offset of the ROI applied by the camera.
Definition dataFrame.cpp:287
double GetTime() const
Get the current time stamp stored in the object.
Definition dataFrame.cpp:282
DataFrame & operator=(const DataFrame &source)
Definition dataFrame.cpp:322
int64_t GetExpNbSubFrames() const
Expected number of sub-frames if the data of a frame is received in sub-frames (blocks).
Definition dataFrame.cpp:257
const void * GetBuffer() const
Get read-only pointer to internal image buffer.
Definition dataFrame.cpp:262
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:252
int64_t GetCamFrameCount() const
Definition dataFrame.cpp:242
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:60
int64_t GetIntFrameCount() const
Internall frame counter, counting the frames receives since the last Start command (first frame == 1)...
Definition dataFrame.cpp:247
double GetHandlingTime() const
Get handling time (duration for handling the frame in the given context).
Definition dataFrame.cpp:338
void SetHandlingStartTime(const double time)
Set the start time for handling handling the frame.
Definition dataFrame.cpp:328
void Reset()
Definition dataFrame.cpp:48
bool HasMetadata(const std::string &name, TYPE &value) const
Get a parameter value from the configuration.
Definition dataFrame.hpp:169
void AddMetaData(const std::string &name, TYPE &value)
Definition dataFrame.hpp:146
DataFrame(const std::string &frame_id, const int16_t frame_q_nb)
Get CFITSIO data type.
Definition dataFrame.cpp:14
int32_t GetResolution() const
Get the resolution (bytes/pixel) of the image currently stored in the object.
Definition dataFrame.cpp:317
void SetConsumerCount(const uint8_t count)
Definition dataFrame.cpp:93
void DecrementConsumerCount(const uint8_t decr=1)
Definition dataFrame.cpp:108
DataFrame()
Definition dataFrame.cpp:35
Definition appBase.cpp:10
log4cplus::Logger & Logger()
Definition base.cpp:24