IDS peak IPL v1.17.1
Loading...
Searching...
No Matches
peak_ipl_pixel_line.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
17
18#include <cstddef>
19#include <cstdint>
20#include <utility>
21#include <vector>
22
27
28namespace peak
29{
30namespace ipl
31{
32
38{
39public:
43 struct Channel
44 {
45 std::vector<uint32_t> Values;
46 };
47
48public:
49 PixelLine() = delete;
50
62 explicit PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset);
63
70 virtual ~PixelLine();
71
83 PixelLine(const PixelLine& other);
84
96 PixelLine& operator=(const PixelLine& other);
97
106 PixelLine(PixelLine&& other) noexcept;
107
116 PixelLine& operator=(PixelLine&& other) noexcept;
117
127
137
147 PEAK_IPL_NO_DISCARD size_t Offset() const;
148
157 PEAK_IPL_NO_DISCARD std::vector<Channel> Channels() const;
158
159private:
160 PEAK_IPL_PIXEL_LINE_HANDLE m_backendHandle{};
161};
162
166class PixelRow : public PixelLine
167{
168public:
169 PixelRow() = delete;
170 explicit PixelRow(const Image& image, size_t row);
171 ~PixelRow() override = default;
172 PixelRow(const PixelRow& other) = default;
173 PixelRow& operator=(const PixelRow& other) = default;
174 PixelRow(PixelRow&& other) = default;
175 PixelRow& operator=(PixelRow&& other) = default;
176};
177
181class PixelColumn : public PixelLine
182{
183public:
184 PixelColumn() = delete;
185 explicit PixelColumn(const Image& image, size_t column);
186 ~PixelColumn() override = default;
187 PixelColumn(const PixelColumn& other) = default;
188 PixelColumn& operator=(const PixelColumn& other) = default;
189 PixelColumn(PixelColumn&& other) = default;
190 PixelColumn& operator=(PixelColumn&& other) = default;
191};
192
193inline PixelRow::PixelRow(const Image& image, size_t row)
194 : PixelLine(image, peak::ipl::Orientation::Horizontal, row)
195{}
196
197inline PixelColumn::PixelColumn(const Image& image, size_t column)
198 : PixelLine(image, peak::ipl::Orientation::Vertical, column)
199{}
200
201
202inline PixelLine::PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset)
203{
205 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Construct(ImageBackendAccessor::BackendHandle(image),
206 static_cast<PEAK_IPL_ORIENTATION>(orientation), offset, &m_backendHandle);
207 });
208}
209
211{
212 if (m_backendHandle)
213 {
215 }
216}
217
218inline PixelLine::PixelLine(const PixelLine& other)
219{
220 if (other.m_backendHandle)
221 {
222 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
223 }
224
225 m_backendHandle = other.m_backendHandle;
226}
227
229{
230 if (this != &other)
231 {
232 if (m_backendHandle)
233 {
235 }
236
237 if (other.m_backendHandle)
238 {
240 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
241 }
242 }
243
244 m_backendHandle = other.m_backendHandle;
245
246 return *this;
247}
248
249inline PixelLine::PixelLine(PixelLine&& other) noexcept
250{
251 *this = std::move(other);
252}
253
254inline PixelLine& PixelLine::operator=(PixelLine&& other) noexcept
255{
256 if (this != &other)
257 {
258 if (m_backendHandle != nullptr)
259 {
261 }
262
263 m_backendHandle = other.m_backendHandle;
264 other.m_backendHandle = nullptr;
265 }
266
267 return *this;
268}
269
271{
273
276 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
277 });
278
279 return pixelFormatName;
280}
281
283{
285
288 m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
289 });
290
291 return orientation;
292}
293
294inline size_t PixelLine::Offset() const
295{
296 size_t offset = 0;
297
299 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
300
301 return offset;
302}
303
304inline std::vector<PixelLine::Channel> PixelLine::Channels() const
305{
306 std::vector<Channel> channels;
307
308 size_t numChannels = 0;
310 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
311
312 for (size_t ch = 0; ch < numChannels; ++ch)
313 {
314 size_t valueListSize = 0;
317 m_backendHandle, ch, nullptr, &valueListSize);
318 });
319 std::vector<uint32_t> valueList(valueListSize);
322 m_backendHandle, ch, valueList.data(), &valueListSize);
323 });
324
325 channels.emplace_back(Channel{ std::move(valueList) });
326 }
327
328 return channels;
329}
330
331} /* namespace ipl */
332} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:47
PixelColumn & operator=(const PixelColumn &other)=default
PixelColumn & operator=(PixelColumn &&other)=default
PixelColumn(const PixelColumn &other)=default
~PixelColumn() override=default
PixelColumn(PixelColumn &&other)=default
size_t Offset() const
Returns the offset of the given pixel line. (Vertical: Left - Horizontal: Top).
Definition peak_ipl_pixel_line.hpp:294
peak::ipl::PixelFormatName PixelFormatName() const
Returns the pixel format of the given pixel line.
Definition peak_ipl_pixel_line.hpp:270
virtual ~PixelLine()
Destructor for the PixelLine instance.
Definition peak_ipl_pixel_line.hpp:210
std::vector< Channel > Channels() const
Returns the number of the given pixel line's channels.
Definition peak_ipl_pixel_line.hpp:304
PixelLine & operator=(const PixelLine &other)
Copy assigment for PixelLine instance.
Definition peak_ipl_pixel_line.hpp:228
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition peak_ipl_pixel_line.hpp:282
~PixelRow() override=default
PixelRow & operator=(PixelRow &&other)=default
PixelRow(const PixelRow &other)=default
PixelRow(PixelRow &&other)=default
PixelRow & operator=(const PixelRow &other)=default
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:43
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:44
Orientation
Enum holding the possible orientation.
Definition peak_ipl_simple_types.hpp:200
@ Vertical
Vertical orientation.
Definition peak_ipl_simple_types.hpp:202
@ Horizontal
Horizontal orientation.
Definition peak_ipl_simple_types.hpp:201
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:289
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
PEAK_IPL_C_API PEAK_IPL_PixelLine_GetOrientation(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, PEAK_IPL_ORIENTATION *orientation)
Queries the orientation of the given pixel line.
PEAK_IPL_C_API PEAK_IPL_PixelLine_GetValuesForChannel(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, size_t channelIndex, uint32_t *values, size_t *valuesSize)
Queries the value list for the channel with the given index.
PEAK_IPL_C_API PEAK_IPL_PixelLine_GetOffset(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, size_t *offset)
Queries the offset of the given pixel line.
struct PEAK_IPL_PIXEL_LINE * PEAK_IPL_PIXEL_LINE_HANDLE
Definition peak_ipl_backend.h:413
PEAK_IPL_C_API PEAK_IPL_PixelLine_GetPixelFormat(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, PEAK_IPL_PIXEL_FORMAT *pixelFormat)
Queries the pixel format of the given pixel line.
PEAK_IPL_C_API PEAK_IPL_PixelLine_Construct(PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_ORIENTATION orientation, size_t offset, PEAK_IPL_PIXEL_LINE_HANDLE *pixelLineHandle)
Creates a pixel line depending on the given orientation.
int32_t PEAK_IPL_ORIENTATION
Definition peak_ipl_backend.h:202
PEAK_IPL_C_API PEAK_IPL_PixelLine_GetNumChannels(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, size_t *numChannels)
Queries the number of the given pixel line's channels.
PEAK_IPL_C_API PEAK_IPL_PixelLine_Acquire(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle)
Increase the reference count of a pixel line object.
PEAK_IPL_C_API PEAK_IPL_PixelLine_Destruct(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle)
Destroys the pixel line associated with the given handle.
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16
Represents the values of the pixel line.
Definition peak_ipl_pixel_line.hpp:44
std::vector< uint32_t > Values
Definition peak_ipl_pixel_line.hpp:45