ifw-ccf 4.0.0
Loading...
Searching...
No Matches
dataFrame.hpp
Go to the documentation of this file.
1
5#ifndef CCF_COMMON_DATA_FRAME_HPP_H_
6#define CCF_COMMON_DATA_FRAME_HPP_H_
7
8#include <core/utils/param/parameter.hpp>
9
10#include <ccf/common/base.hpp>
12
13
14namespace ccf::common {
15
17 class DataFrame: public Base {
18 public:
19
21 inline static int32_t GetCFitsioType(const DataType data_type);
22
24 DataFrame(const std::string& frame_id,
25 const int16_t frame_q_nb);
26
28 DataFrame(const DataFrame& source);
29
30 DataFrame();
31
32 ~DataFrame();
33
34 void Reset();
35
37 const std::string& GetFrameId() const;
38
40 int16_t GetFrameQNb() const;
41
58 void Store(const void* buffer,
59 const uint32_t size,
60 const double time,
61 const int64_t cam_frame_count,
62 const int64_t int_frame_count,
63 const int64_t sub_frame_count,
64 const int64_t exp_nb_sub_frames,
65 const DataType data_type,
66 const int32_t offset_x,
67 const int32_t offset_y,
68 const int32_t width,
69 const int32_t height,
70 const int32_t depth = 1);
71
73 void AddData(const void* buffer,
74 const uint32_t size);
75
77 const void* GetBuffer() const;
78
81 void* GetBufferReadWrite() const;
82
84 uint32_t GetBufferSize() const;
85
87 uint32_t GetDataSize() const;
88
90 void ResetDataSize();
91
93 double GetDataSum() const;
94
96 double GetTime() const;
97
100 int64_t GetCamFrameCount() const;
101
103 int64_t GetIntFrameCount() const;
104
106 int64_t GetSubFrameCount() const;
107
109 int64_t GetExpNbSubFrames() const;
110
112 int32_t GetOffsetX() const;
113
115 int32_t GetOffsetY() const;
116
118 int32_t GetWidth() const;
119
121 int32_t GetHeight() const;
122
124 int32_t GetDepth() const;
125
128 DataType GetDataType() const;
129
131 int32_t GetResolution() const;
132
134 bool GetCompleted() const;
135
137 void SetCompleted();
138
142 template <class TYPE>
143 void AddMetaData(const std::string& name,
144 TYPE& value) {
145 LOG4CPLUS_TRACE_METHOD(Logger(), __PRETTY_FUNCTION__);
146 m_meta_data[name] = core::utils::param::Parameter(name, std::to_string(value));
147 }
148
150 void RemoveMetaData(const std::string& name);
151
153 template <class TYPE>
154 bool HasMetadata(const std::string& name,
155 TYPE& value) const {
156 LOG4CPLUS_TRACE_METHOD(Logger(), __PRETTY_FUNCTION__);
157 auto it = m_meta_data.find(name);
158 if (it == m_meta_data.end()) {
159 return false;
160 }
161 it->second.GetValue(value);
162 return true;
163 }
164
166 std::string ToString(const bool full = false) const;
167
170 void SetConsumerCount(const uint8_t count);
171
174 uint8_t GetConsumerCount() const;
175
178 void DecrementConsumerCount(const uint8_t decr = 1);
179
181 void SetHandlingStartTime(const double time);
182
184 double GetHandlingStartTime() const;
185
187 double GetHandlingTime() const;
188
189 DataFrame& operator = (const DataFrame& source);
190
191 protected:
192
193 private:
194 void Initialise(const std::string& frame_id = "",
195 const int64_t frame_nb = -1);
196 void Copy(const DataFrame& source);
197
198 std::string m_frame_id;
199 int64_t m_frame_q_nb;
200
201 int64_t m_cam_frame_count;
202 int64_t m_int_frame_count;
203
204 int64_t m_sub_frame_count;
205 int64_t m_exp_nb_sub_frames;
206
207 uint8_t m_consumer_count;
208
209 double m_handling_start_time;
210
211 void* m_buffer;
212 uint32_t m_size;
213 uint32_t m_expected_size;
214 uint32_t m_cur_allocated;
215 bool m_completed;
216
217 double m_time;
218
219 DataType m_data_type;
220 int32_t m_offset_x;
221 int32_t m_offset_y;
222 int32_t m_width;
223 int32_t m_height;
224 int32_t m_depth;
225
226 std::map<std::string, core::utils::param::Parameter> m_meta_data;
227
228 template <class DATA_TYPE>
229 double Sum() const {
230 LOG4CPLUS_TRACE_METHOD(Logger(), __PRETTY_FUNCTION__);
231 double sum = 0;
232 DATA_TYPE* p = static_cast<DATA_TYPE*>(m_buffer);
233 for (int64_t i = 0; i < GetDataSize(); i++) {
234 sum += static_cast<DATA_TYPE>(*p++);
235 }
236 return sum;
237 }
238
239 };
240
241}
242
243#endif // CCF_COMMON_DATA_FRAME_HPP_H_
Class to be used as parent all CCF classes.
Definition: base.hpp:107
Frame class used to store the data and metadata for one frames received from the camera.
Definition: dataFrame.hpp:17
void SetConsumerCount(const uint8_t count)
Definition: dataFrame.cpp:110
void DecrementConsumerCount(const uint8_t decr=1)
Definition: dataFrame.cpp:126
const void * GetBuffer() const
Get read-only pointer to internal image buffer.
Definition: dataFrame.cpp:274
int32_t GetWidth() const
Get the width of the ROI applied by the camera.
Definition: dataFrame.cpp:309
int32_t GetResolution() const
Get the resolution (bytes/pixel) of the image currently stored in the object.
Definition: dataFrame.cpp:329
void Reset()
Definition: dataFrame.cpp:65
int16_t GetFrameQNb() const
Return the frame queue number, when used in a queue.
Definition: dataFrame.cpp:77
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 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:150
double GetDataSum() const
Compute the data sum of all pixels.
Definition: dataFrame.cpp:385
int64_t GetCamFrameCount() const
Definition: dataFrame.cpp:254
double GetHandlingTime() const
Get handling time (duration for handling the frame in the given context).
Definition: dataFrame.cpp:350
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:264
~DataFrame()
Definition: dataFrame.cpp:57
double GetHandlingStartTime() const
Get the time for starting the handling of the frame.
Definition: dataFrame.cpp:345
DataFrame & operator=(const DataFrame &source)
Definition: dataFrame.cpp:334
bool HasMetadata(const std::string &name, TYPE &value) const
Get a parameter value from the configuration.
Definition: dataFrame.hpp:154
void * GetBufferReadWrite() const
Definition: dataFrame.cpp:279
void RemoveMetaData(const std::string &name)
Remove a given metadata parameter from the object.
Definition: dataFrame.cpp:377
DataFrame()
Definition: dataFrame.cpp:52
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:212
int32_t GetDepth() const
Get the number of frames if a three dimensional image is contained in the object.
Definition: dataFrame.cpp:319
int64_t GetExpNbSubFrames() const
Expected number of sub-frames if the data of a frame is received in sub-frames (blocks).
Definition: dataFrame.cpp:269
double GetTime() const
Get the current time stamp stored in the object.
Definition: dataFrame.cpp:294
int32_t GetOffsetX() const
Get horisontal offset of the ROI applied by the camera.
Definition: dataFrame.cpp:299
uint8_t GetConsumerCount() const
Definition: dataFrame.cpp:121
void ResetDataSize()
Reset the size of the image. This indicates that no image is stored in the object.
Definition: dataFrame.cpp:145
bool GetCompleted() const
Return true if the image in the object is complete according to width/height/data type.
Definition: dataFrame.cpp:244
uint32_t GetBufferSize() const
Get the size of the internal buffer allocated, in bytes.
Definition: dataFrame.cpp:289
int64_t GetIntFrameCount() const
Internall frame counter, counting the frames receives since the last Start command (first frame == 1)...
Definition: dataFrame.cpp:259
uint32_t GetDataSize() const
Return the size in bytes of the image.
Definition: dataFrame.cpp:284
void SetCompleted()
Mark the frame as completed.
Definition: dataFrame.cpp:249
int32_t GetHeight() const
Get the height of the ROI applied by the camera.
Definition: dataFrame.cpp:314
void AddMetaData(const std::string &name, TYPE &value)
Definition: dataFrame.hpp:143
DataType GetDataType() const
Definition: dataFrame.cpp:324
const std::string & GetFrameId() const
Return the frame ID allocated.
Definition: dataFrame.cpp:72
static int32_t GetCFitsioType(const DataType data_type)
Get CFITSIO data type.
void SetHandlingStartTime(const double time)
Set the start time for handling handling the frame.
Definition: dataFrame.cpp:340
std::string ToString(const bool full=false) const
Generate a representative (short) string representation (summary) of the object.
Definition: dataFrame.cpp:82
int32_t GetOffsetY() const
Get vertical offset of the ROI applied by the camera.
Definition: dataFrame.cpp:304
Definition: appBase.cpp:8
log4cplus::Logger & Logger()
Definition: base.cpp:11
DataType
Definition: dataType.hpp:46