IDS peak IPL v1.17.0
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
37{
38public:
42 struct Channel
43 {
44 std::vector<uint32_t> Values;
45 };
46
47public:
48 PixelLine() = delete;
49
61 explicit PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset);
62
69 virtual ~PixelLine();
70
82 PixelLine(const PixelLine& other);
83
95 PixelLine& operator=(const PixelLine& other);
96
105 PixelLine(PixelLine&& other) noexcept;
106
115 PixelLine& operator=(PixelLine&& other) noexcept;
116
126
136
146 PEAK_IPL_NO_DISCARD size_t Offset() const;
147
156 PEAK_IPL_NO_DISCARD std::vector<Channel> Channels() const;
157
158private:
159 PEAK_IPL_PIXEL_LINE_HANDLE m_backendHandle{};
160};
161
165class PixelRow : public PixelLine
166{
167public:
168 PixelRow() = delete;
169 explicit PixelRow(const Image& image, size_t row);
170 ~PixelRow() override = default;
171 PixelRow(const PixelRow& other) = default;
172 PixelRow& operator=(const PixelRow& other) = default;
173 PixelRow(PixelRow&& other) = default;
174 PixelRow& operator=(PixelRow&& other) = default;
175};
176
180class PixelColumn : public PixelLine
181{
182public:
183 PixelColumn() = delete;
184 explicit PixelColumn(const Image& image, size_t column);
185 ~PixelColumn() override = default;
186 PixelColumn(const PixelColumn& other) = default;
187 PixelColumn& operator=(const PixelColumn& other) = default;
188 PixelColumn(PixelColumn&& other) = default;
189 PixelColumn& operator=(PixelColumn&& other) = default;
190};
191
192inline PixelRow::PixelRow(const Image& image, size_t row)
193 : PixelLine(image, peak::ipl::Orientation::Horizontal, row)
194{}
195
196inline PixelColumn::PixelColumn(const Image& image, size_t column)
197 : PixelLine(image, peak::ipl::Orientation::Vertical, column)
198{}
199
200
201inline PixelLine::PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset)
202{
204 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Construct(ImageBackendAccessor::BackendHandle(image),
205 static_cast<PEAK_IPL_ORIENTATION>(orientation), offset, &m_backendHandle);
206 });
207}
208
210{
211 if (m_backendHandle)
212 {
214 }
215}
216
217inline PixelLine::PixelLine(const PixelLine& other)
218{
219 if (other.m_backendHandle)
220 {
221 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
222 }
223
224 m_backendHandle = other.m_backendHandle;
225}
226
228{
229 if (this != &other)
230 {
231 if (m_backendHandle)
232 {
234 }
235
236 if (other.m_backendHandle)
237 {
239 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
240 }
241 }
242
243 m_backendHandle = other.m_backendHandle;
244
245 return *this;
246}
247
248inline PixelLine::PixelLine(PixelLine&& other) noexcept
249{
250 *this = std::move(other);
251}
252
253inline PixelLine& PixelLine::operator=(PixelLine&& other) noexcept
254{
255 if (this != &other)
256 {
257 if (m_backendHandle != nullptr)
258 {
260 }
261
262 m_backendHandle = other.m_backendHandle;
263 other.m_backendHandle = nullptr;
264 }
265
266 return *this;
267}
268
270{
272
275 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
276 });
277
278 return pixelFormatName;
279}
280
282{
284
287 m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
288 });
289
290 return orientation;
291}
292
293inline size_t PixelLine::Offset() const
294{
295 size_t offset = 0;
296
298 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
299
300 return offset;
301}
302
303inline std::vector<PixelLine::Channel> PixelLine::Channels() const
304{
305 std::vector<Channel> channels;
306
307 size_t numChannels = 0;
309 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
310
311 for (size_t ch = 0; ch < numChannels; ++ch)
312 {
313 size_t valueListSize = 0;
316 m_backendHandle, ch, nullptr, &valueListSize);
317 });
318 std::vector<uint32_t> valueList(valueListSize);
321 m_backendHandle, ch, valueList.data(), &valueListSize);
322 });
323
324 channels.emplace_back(Channel{ std::move(valueList) });
325 }
326
327 return channels;
328}
329
330} /* namespace ipl */
331} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:46
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:293
peak::ipl::PixelFormatName PixelFormatName() const
Returns the pixel format of the given pixel line.
Definition peak_ipl_pixel_line.hpp:269
virtual ~PixelLine()
Destructor for the PixelLine instance.
Definition peak_ipl_pixel_line.hpp:209
std::vector< Channel > Channels() const
Returns the number of the given pixel line's channels.
Definition peak_ipl_pixel_line.hpp:303
PixelLine & operator=(const PixelLine &other)
Copy assigment for PixelLine instance.
Definition peak_ipl_pixel_line.hpp:227
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition peak_ipl_pixel_line.hpp:281
~PixelRow() override=default
PixelRow & operator=(PixelRow &&other)=default
PixelRow(const PixelRow &other)=default
PixelRow(PixelRow &&other)=default
PixelRow & operator=(const PixelRow &other)=default
The "peak::ipl" namespace contains the whole image processing library.
Orientation
Enum holding the possible orientation.
Definition peak_ipl_simple_types.hpp:195
@ Vertical
Vertical orientation.
Definition peak_ipl_simple_types.hpp:197
@ Horizontal
Horizontal orientation.
Definition peak_ipl_simple_types.hpp:196
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:41
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:42
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:271
#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:43
std::vector< uint32_t > Values
Definition peak_ipl_pixel_line.hpp:44