IDS peak IPL v1.16.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
26namespace peak
27{
28namespace ipl
29{
30
35{
36public:
40 struct Channel
41 {
42 std::vector<uint32_t> Values;
43 };
44
45public:
46 PixelLine() = delete;
47
59 explicit PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset);
60
67 virtual ~PixelLine();
68
80 PixelLine(const PixelLine& other);
81
93 PixelLine& operator=(const PixelLine& other);
94
103 PixelLine(PixelLine&& other) noexcept;
104
113 PixelLine& operator=(PixelLine&& other) noexcept;
114
124
134
144 PEAK_IPL_NO_DISCARD size_t Offset() const;
145
154 PEAK_IPL_NO_DISCARD std::vector<Channel> Channels() const;
155
156private:
157 PEAK_IPL_PIXEL_LINE_HANDLE m_backendHandle{};
158};
159
163class PixelRow : public PixelLine
164{
165public:
166 PixelRow() = delete;
167 explicit PixelRow(const Image& image, size_t row);
168 ~PixelRow() override = default;
169 PixelRow(const PixelRow& other) = default;
170 PixelRow& operator=(const PixelRow& other) = default;
171 PixelRow(PixelRow&& other) = default;
172 PixelRow& operator=(PixelRow&& other) = default;
173};
174
178class PixelColumn : public PixelLine
179{
180public:
181 PixelColumn() = delete;
182 explicit PixelColumn(const Image& image, size_t column);
183 ~PixelColumn() override = default;
184 PixelColumn(const PixelColumn& other) = default;
185 PixelColumn& operator=(const PixelColumn& other) = default;
186 PixelColumn(PixelColumn&& other) = default;
187 PixelColumn& operator=(PixelColumn&& other) = default;
188};
189
190inline PixelRow::PixelRow(const Image& image, size_t row)
191 : PixelLine(image, peak::ipl::Orientation::Horizontal, row)
192{}
193
194inline PixelColumn::PixelColumn(const Image& image, size_t column)
195 : PixelLine(image, peak::ipl::Orientation::Vertical, column)
196{}
197
198
199inline PixelLine::PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset)
200{
202 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Construct(ImageBackendAccessor::BackendHandle(image),
203 static_cast<PEAK_IPL_ORIENTATION>(orientation), offset, &m_backendHandle);
204 });
205}
206
208{
209 if (m_backendHandle)
210 {
212 }
213}
214
215inline PixelLine::PixelLine(const PixelLine& other)
216{
217 if (other.m_backendHandle)
218 {
219 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
220 }
221
222 m_backendHandle = other.m_backendHandle;
223}
224
226{
227 if (this != &other)
228 {
229 if (m_backendHandle)
230 {
232 }
233
234 if (other.m_backendHandle)
235 {
237 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Acquire(other.m_backendHandle); });
238 }
239 }
240
241 m_backendHandle = other.m_backendHandle;
242
243 return *this;
244}
245
246inline PixelLine::PixelLine(PixelLine&& other) noexcept
247{
248 *this = std::move(other);
249}
250
251inline PixelLine& PixelLine::operator=(PixelLine&& other) noexcept
252{
253 if (this != &other)
254 {
255 if (m_backendHandle != nullptr)
256 {
258 }
259
260 m_backendHandle = other.m_backendHandle;
261 other.m_backendHandle = nullptr;
262 }
263
264 return *this;
265}
266
268{
270
273 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
274 });
275
276 return pixelFormatName;
277}
278
280{
282
285 m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
286 });
287
288 return orientation;
289}
290
291inline size_t PixelLine::Offset() const
292{
293 size_t offset = 0;
294
296 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
297
298 return offset;
299}
300
301inline std::vector<PixelLine::Channel> PixelLine::Channels() const
302{
303 std::vector<Channel> channels;
304
305 size_t numChannels = 0;
307 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
308
309 for (size_t ch = 0; ch < numChannels; ++ch)
310 {
311 size_t valueListSize = 0;
314 m_backendHandle, ch, nullptr, &valueListSize);
315 });
316 std::vector<uint32_t> valueList(valueListSize);
319 m_backendHandle, ch, valueList.data(), &valueListSize);
320 });
321
322 channels.emplace_back(Channel{ std::move(valueList) });
323 }
324
325 return channels;
326}
327
328} /* namespace ipl */
329} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:41
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:291
peak::ipl::PixelFormatName PixelFormatName() const
Returns the pixel format of the given pixel line.
Definition peak_ipl_pixel_line.hpp:267
virtual ~PixelLine()
Destructor for the PixelLine instance.
Definition peak_ipl_pixel_line.hpp:207
std::vector< Channel > Channels() const
Returns the number of the given pixel line's channels.
Definition peak_ipl_pixel_line.hpp:301
PixelLine & operator=(const PixelLine &other)
Copy assigment for PixelLine instance.
Definition peak_ipl_pixel_line.hpp:225
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition peak_ipl_pixel_line.hpp:279
~PixelRow() override=default
PixelRow & operator=(PixelRow &&other)=default
PixelRow(const PixelRow &other)=default
PixelRow(PixelRow &&other)=default
PixelRow & operator=(const PixelRow &other)=default
Definition peak_ipl_binning.hpp:25
Orientation
Enum holding the possible orientation.
Definition peak_ipl_simple_types.hpp:193
@ Vertical
Vertical orientation.
Definition peak_ipl_simple_types.hpp:195
@ Horizontal
Horizontal orientation.
Definition peak_ipl_simple_types.hpp:194
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:39
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:40
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
#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:41
std::vector< uint32_t > Values
Definition peak_ipl_pixel_line.hpp:42