IDS peak IPL  v1.5.0
peak_ipl_pixel_line.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
17 
18 #include <cstddef>
19 #include <cstdint>
20 #include <utility>
21 #include <vector>
22 
26 namespace peak
27 {
28 namespace ipl
29 {
30 
34 class PixelLine
35 {
36 public:
40  struct Channel
41  {
42  std::vector<uint32_t> Values;
43  };
44 
45 public:
46  PixelLine() = delete;
58  explicit PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset);
59  virtual ~PixelLine();
60  PixelLine(const PixelLine& other) = delete;
61  PixelLine& operator=(const PixelLine& other) = delete;
62  PixelLine(PixelLine&& other);
63  PixelLine& operator=(PixelLine&& other);
64 
74 
84 
94  size_t Offset() const;
95 
104  std::vector<Channel> Channels() const;
105 
106 private:
107  PEAK_IPL_PIXEL_LINE_HANDLE m_backendHandle{};
108 };
109 
113 class PixelRow : public PixelLine
114 {
115 public:
116  PixelRow() = delete;
117  explicit PixelRow(const Image& image, size_t row);
118  virtual ~PixelRow() override = default;
119  PixelRow(const PixelRow& other) = delete;
120  PixelRow& operator=(const PixelRow& other) = delete;
121  PixelRow(PixelRow&& other) = default;
122  PixelRow& operator=(PixelRow&& other) = default;
123 };
124 
128 class PixelColumn : public PixelLine
129 {
130 public:
131  PixelColumn() = delete;
132  explicit PixelColumn(const Image& image, size_t column);
133  virtual ~PixelColumn() override = default;
134  PixelColumn(const PixelColumn& other) = delete;
135  PixelColumn& operator=(const PixelColumn& other) = delete;
136  PixelColumn(PixelColumn&& other) = default;
137  PixelColumn& operator=(PixelColumn&& other) = default;
138 };
139 
140 inline PixelRow::PixelRow(const Image& image, size_t row)
141  : PixelLine(image, peak::ipl::Orientation::Horizontal, row)
142 {}
143 
144 inline PixelColumn::PixelColumn(const Image& image, size_t column)
145  : PixelLine(image, peak::ipl::Orientation::Vertical, column)
146 {}
147 
148 
149 inline PixelLine::PixelLine(const Image& image, peak::ipl::Orientation orientation, size_t offset)
150 {
152  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Construct(ImageBackendAccessor::BackendHandle(image),
153  static_cast<PEAK_IPL_ORIENTATION>(orientation), offset, &m_backendHandle);
154  });
155 }
156 
158 {
159  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Destruct(m_backendHandle);
160 }
161 
163 {
164  *this = std::move(other);
165 }
166 
168 {
169  if (this != &other)
170  {
171  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Destruct(m_backendHandle);
172  m_backendHandle = other.m_backendHandle;
173  other.m_backendHandle = nullptr;
174  }
175 
176  return *this;
177 }
178 
180 {
182 
185  m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
186  });
187 
188  return pixelFormatName;
189 }
190 
192 {
194 
197  m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
198  });
199 
200  return orientation;
201 }
202 
203 inline size_t PixelLine::Offset() const
204 {
205  size_t offset = 0;
206 
208  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
209 
210  return offset;
211 }
212 
213 inline std::vector<PixelLine::Channel> PixelLine::Channels() const
214 {
215  std::vector<Channel> channels;
216 
217  size_t numChannels = 0;
219  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
220 
221  for (size_t ch = 0; ch < numChannels; ++ch)
222  {
223  size_t valueListSize = 0;
226  m_backendHandle, ch, nullptr, &valueListSize);
227  });
228  std::vector<uint32_t> valueList(valueListSize);
231  m_backendHandle, ch, valueList.data(), &valueListSize);
232  });
233 
234  channels.emplace_back(Channel{ std::move(valueList) });
235  }
236 
237  return channels;
238 }
239 
240 } /* namespace ipl */
241 } /* namespace peak */
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
Represents the values of a horizontal or vertical line of pixels in an image.
Definition: peak_ipl_pixel_line.hpp:34
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
std::vector< Channel > Channels() const
Returns the number of the given pixel line&#39;s channels.
Definition: peak_ipl_pixel_line.hpp:213
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition: peak_ipl_pixel_line.hpp:191
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:16
struct PEAK_IPL_PIXEL_LINE * PEAK_IPL_PIXEL_LINE_HANDLE
Definition: peak_ipl_backend.h:275
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:37
Represents the values of the pixel line.
Definition: peak_ipl_pixel_line.hpp:40
size_t Offset() const
Returns the offset of the given pixel line. (Vertical: Left - Horizontal: Top).
Definition: peak_ipl_pixel_line.hpp:203
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.
Orientation
Enum holding the possible orientation.
Definition: peak_ipl_simple_types.hpp:154
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_GetOffset(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle, size_t *offset)
Queries the offset of the given pixel line.
Represents the values of a horizontal line of pixels in an image.
Definition: peak_ipl_pixel_line.hpp:113
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_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::PixelFormatName PixelFormatName() const
Returns the pixel format of the given pixel line.
Definition: peak_ipl_pixel_line.hpp:179
std::vector< uint32_t > Values
Definition: peak_ipl_pixel_line.hpp:42
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&#39;s channels.
virtual ~PixelLine()
Definition: peak_ipl_pixel_line.hpp:157
Represents the values of a vertical line of pixels in an image.
Definition: peak_ipl_pixel_line.hpp:128
PEAK_IPL_C_API PEAK_IPL_PixelLine_Destruct(PEAK_IPL_PIXEL_LINE_HANDLE pixelLineHandle)
Destroys the pixel line associated with the given handle.
PixelLine & operator=(const PixelLine &other)=delete