IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_pixel_line.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
12
13#include <cstddef>
14#include <cstdint>
15#include <utility>
16#include <vector>
17
22
23namespace peak
24{
25namespace ipl
26{
27
33{
34public:
38 struct Channel
39 {
40 std::vector<uint32_t> Values;
41 };
42
43public:
44 PixelLine() = delete;
45
57 explicit PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset);
58
65 virtual ~PixelLine();
66
78 PixelLine(const PixelLine& other);
79
91 PixelLine& operator=(const PixelLine& other);
92
101 PixelLine(PixelLine&& other) noexcept;
102
111 PixelLine& operator=(PixelLine&& other) noexcept;
112
122
132
142 PEAK_IPL_NO_DISCARD size_t Offset() const;
143
152 PEAK_IPL_NO_DISCARD std::vector<Channel> Channels() const;
153
154private:
155 PEAK_IPL_PIXEL_LINE_HANDLE m_backendHandle{};
156};
157
161class PixelRow : public PixelLine
162{
163public:
164 PixelRow() = delete;
165 explicit PixelRow(const Image& image, size_t row);
166 ~PixelRow() override = default;
167 PixelRow(const PixelRow& other) = default;
168 PixelRow& operator=(const PixelRow& other) = default;
169 PixelRow(PixelRow&& other) = default;
170 PixelRow& operator=(PixelRow&& other) = default;
171};
172
176class PixelColumn : public PixelLine
177{
178public:
179 PixelColumn() = delete;
180 explicit PixelColumn(const Image& image, size_t column);
181 ~PixelColumn() override = default;
182 PixelColumn(const PixelColumn& other) = default;
183 PixelColumn& operator=(const PixelColumn& other) = default;
184 PixelColumn(PixelColumn&& other) = default;
185 PixelColumn& operator=(PixelColumn&& other) = default;
186};
187
188inline PixelRow::PixelRow(const Image& image, size_t row)
189 : PixelLine(image, peak::ipl::Orientation::Horizontal, row)
190{}
191
192inline PixelColumn::PixelColumn(const Image& image, size_t column)
193 : PixelLine(image, peak::ipl::Orientation::Vertical, column)
194{}
195
196
197inline PixelLine::PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset)
198{
200 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Construct(ImageBackendAccessor::BackendHandle(image),
201 static_cast<PEAK_IPL_ORIENTATION>(orientation), offset, &m_backendHandle);
202 });
203}
204
206{
207 if (m_backendHandle)
208 {
210 }
211}
212
213inline PixelLine::PixelLine(const PixelLine& other)
214{
215 if (other.m_backendHandle)
216 {
217 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
218 }
219
220 m_backendHandle = other.m_backendHandle;
221}
222
224{
225 if (this != &other)
226 {
227 if (m_backendHandle)
228 {
230 }
231
232 if (other.m_backendHandle)
233 {
235 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
236 }
237 }
238
239 m_backendHandle = other.m_backendHandle;
240
241 return *this;
242}
243
244inline PixelLine::PixelLine(PixelLine&& other) noexcept
245{
246 *this = std::move(other);
247}
248
249inline PixelLine& PixelLine::operator=(PixelLine&& other) noexcept
250{
251 if (this != &other)
252 {
253 if (m_backendHandle != nullptr)
254 {
256 }
257
258 m_backendHandle = other.m_backendHandle;
259 other.m_backendHandle = nullptr;
260 }
261
262 return *this;
263}
264
266{
268
271 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
272 });
273
274 return pixelFormatName;
275}
276
278{
280
283 m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
284 });
285
286 return orientation;
287}
288
289inline size_t PixelLine::Offset() const
290{
291 size_t offset = 0;
292
294 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
295
296 return offset;
297}
298
299inline std::vector<PixelLine::Channel> PixelLine::Channels() const
300{
301 std::vector<Channel> channels;
302
303 size_t numChannels = 0;
305 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
306
307 for (size_t ch = 0; ch < numChannels; ++ch)
308 {
309 size_t valueListSize = 0;
312 m_backendHandle, ch, nullptr, &valueListSize);
313 });
314 std::vector<uint32_t> valueList(valueListSize);
317 m_backendHandle, ch, valueList.data(), &valueListSize);
318 });
319
320 channels.emplace_back(Channel{ std::move(valueList) });
321 }
322
323 return channels;
324}
325
326} /* namespace ipl */
327} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:42
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:289
peak::ipl::PixelFormatName PixelFormatName() const
Returns the pixel format of the given pixel line.
Definition peak_ipl_pixel_line.hpp:265
virtual ~PixelLine()
Destructor for the PixelLine instance.
Definition peak_ipl_pixel_line.hpp:205
std::vector< Channel > Channels() const
Returns the number of the given pixel line's channels.
Definition peak_ipl_pixel_line.hpp:299
PixelLine & operator=(const PixelLine &other)
Copy assigment for PixelLine instance.
Definition peak_ipl_pixel_line.hpp:223
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition peak_ipl_pixel_line.hpp:277
~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:38
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:39
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
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:284
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
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:410
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:199
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:170
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:11
Represents the values of the pixel line.
Definition peak_ipl_pixel_line.hpp:39
std::vector< uint32_t > Values
Definition peak_ipl_pixel_line.hpp:40