IDS peak IPL  v1.7.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) noexcept;
63  PixelLine& operator=(PixelLine&& other) noexcept;
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  if (m_backendHandle)
160  {
161  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Destruct(m_backendHandle);
162  }
163 }
164 
165 inline PixelLine::PixelLine(PixelLine&& other) noexcept
166 {
167  *this = std::move(other);
168 }
169 
170 inline PixelLine& PixelLine::operator=(PixelLine&& other) noexcept
171 {
172  if (this != &other)
173  {
174  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_Destruct(m_backendHandle);
175  m_backendHandle = other.m_backendHandle;
176  other.m_backendHandle = nullptr;
177  }
178 
179  return *this;
180 }
181 
183 {
185 
188  m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
189  });
190 
191  return pixelFormatName;
192 }
193 
195 {
197 
200  m_backendHandle, reinterpret_cast<PEAK_IPL_ORIENTATION*>(&orientation));
201  });
202 
203  return orientation;
204 }
205 
206 inline size_t PixelLine::Offset() const
207 {
208  size_t offset = 0;
209 
211  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetOffset(m_backendHandle, &offset); });
212 
213  return offset;
214 }
215 
216 inline std::vector<PixelLine::Channel> PixelLine::Channels() const
217 {
218  std::vector<Channel> channels;
219 
220  size_t numChannels = 0;
222  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_PixelLine_GetNumChannels(m_backendHandle, &numChannels); });
223 
224  for (size_t ch = 0; ch < numChannels; ++ch)
225  {
226  size_t valueListSize = 0;
229  m_backendHandle, ch, nullptr, &valueListSize);
230  });
231  std::vector<uint32_t> valueList(valueListSize);
234  m_backendHandle, ch, valueList.data(), &valueListSize);
235  });
236 
237  channels.emplace_back(Channel{ std::move(valueList) });
238  }
239 
240  return channels;
241 }
242 
243 } /* namespace ipl */
244 } /* 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:216
peak::ipl::Orientation Orientation() const
Returns the orientation of the given pixel line.
Definition: peak_ipl_pixel_line.hpp:194
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
struct PEAK_IPL_PIXEL_LINE * PEAK_IPL_PIXEL_LINE_HANDLE
Definition: peak_ipl_backend.h:334
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:39
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:206
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:182
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