IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_image.ipp
Go to the documentation of this file.
1
11#pragma once
12
16#include <peak_icv_c/types/peak_icv_buffer.h>
17#include <algorithm>
18#include <cstring>
19#include <utility>
20
21#ifdef WITH_peak_ipl
22# include <peak_ipl/types/peak_ipl_pixel_format.hpp>
23#endif
24
25namespace peak
26{
27namespace icv
28{
29inline peak_icv_image_handle Image::CreateFromFile(const std::string& path)
30{
31 peak_icv_image_handle handle{};
33 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromFile(&handle, path.c_str());
34 });
35 return handle;
36}
37
38inline peak_icv_image_handle Image::CreateFromFile(const std::string& path, peak::common::PixelFormat name)
39{
40 peak_icv_image_handle handle{};
42 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromFileWithPixelFormat(
43 &handle, path.c_str(), peak::common::detail::CppPixelFormatToCPixelFormat(name));
44 });
45 return handle;
46}
47
48inline peak_icv_image_info Image::CreateFromHandle(peak_icv_image_handle handle)
49{
50 peak_icv_image_info imageInfo{};
52 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetInfo(handle, &imageInfo, sizeof(imageInfo));
53 });
54
55 return imageInfo;
56}
57
58inline peak_icv_image_handle Image::CreateFromSize(peak::common::PixelFormat pixelFormat, const peak::common::Size& size)
59{
60 peak_icv_image_handle handle{};
62 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Create(
63 &handle, peak::common::detail::CppPixelFormatToCPixelFormat(pixelFormat), { size.GetWidth(), size.GetHeight() });
64 });
65 return handle;
66}
67
68inline peak_icv_image_handle Image::CreateFromBuffer(
69 peak::common::PixelFormat pixelFormat, const peak::common::Size& size, const uint8_t* buffer, size_t bufferSize)
70{
71 peak_icv_image_handle handle{};
73 peak_icv_image_info info{ peak::common::detail::CppPixelFormatToCPixelFormat(pixelFormat),
74 { size.GetWidth(), size.GetHeight() }, bufferSize, const_cast<uint8_t*>(buffer) };
75 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromImageInfo(&handle, info, sizeof(info));
76 });
77 return handle;
78}
79
80inline peak_icv_image_handle Image::CreateFromImageView(const peak::common::IImageView& imageView)
81{
82 const auto imageViewSize = imageView.GetSize();
83 const auto lineStartOffset = imageView.GetLineStartOffset();
84
85 const size_t validBytesPerLine = peak::common::PixelFormatInfo(imageView.GetPixelFormat())
86 .GetSizeInBytes({ imageViewSize.GetWidth(), 1 });
87
88 if (lineStartOffset == 0 && validBytesPerLine == imageView.GetBytesPerLine())
89 {
90 return CreateFromBuffer(imageView.GetPixelFormat(), imageViewSize, imageView.GetData(), imageView.GetSizeInBytes());
91 }
92
93 Image imageWithoutBlackColumns(imageView.GetPixelFormat(), imageViewSize);
94 auto imageHandleWithoutBlackColumns = peak::common::detail::BackendAccessor<Image>::BackendHandle(imageWithoutBlackColumns);
95
97 return PEAK_ICV_C_ABI_PREFIX peak_icv_Buffer_CutBytes(imageView.GetData(), lineStartOffset, imageView.GetBytesPerLine(),
98 validBytesPerLine, imageViewSize.GetHeight(), imageHandleWithoutBlackColumns);
99 });
101 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(imageHandleWithoutBlackColumns);
102 });
103 return imageHandleWithoutBlackColumns;
104}
105
106inline peak::common::Metadata Image::AddCaptureInformationDataToMetadata(
107 peak_icv_capture_information captureInformationC, peak::common::Metadata metadata)
108{
109 metadata.SetValueByKey<peak::common::MetadataKey::DeviceTimestamp>(captureInformationC.relative_timestamp);
110 metadata.SetValueByKey<peak::common::MetadataKey::BinningHorizontal>(captureInformationC.binning_factor.x);
111 metadata.SetValueByKey<peak::common::MetadataKey::BinningVertical>(captureInformationC.binning_factor.y);
113 peak::common::RectangleU{ captureInformationC.region_of_interest.x, captureInformationC.region_of_interest.y,
114 captureInformationC.region_of_interest.width, captureInformationC.region_of_interest.height });
115
116 if (captureInformationC.exposure_time != 0)
117 {
118 metadata.SetValueByKey<peak::common::MetadataKey::DeviceExposureTime>(captureInformationC.exposure_time);
119 }
120
121 const double* exposureSequenceBegin = &captureInformationC.exposure_time_a;
122 const double* firstZeroExposure = std::find(exposureSequenceBegin, exposureSequenceBegin + 4, 0.0);
123 if (firstZeroExposure != exposureSequenceBegin)
124 {
126 std::vector<double>(exposureSequenceBegin, firstZeroExposure));
127 }
128
129 if (captureInformationC.gain != 0)
130 {
131 metadata.SetValueByKey<peak::common::MetadataKey::DeviceGain>(captureInformationC.gain);
132 }
133
134 const double* gainSequenceBegin = &captureInformationC.gain_a;
135 const double* firstZeroGain = std::find(gainSequenceBegin, gainSequenceBegin + 4, 0.0);
136 if (firstZeroGain != gainSequenceBegin)
137 {
138 metadata.SetValueByKey<peak::common::MetadataKey::DeviceGainSequence>(std::vector<double>(gainSequenceBegin, firstZeroGain));
139 }
140
141 return metadata;
142}
143
144inline Image::Image(peak_icv_image_handle handle, peak_icv_image_info info)
145 : m_imageHandle{ handle }
146 , m_size{ info.size.width, info.size.height }
147 , m_buffer{ info.buffer }
148 , m_pixelFormatInfo{ peak::common::detail::CPixelFormatToCppPixelFormat(info.pixelFormat) }
149{}
150
151#ifdef WITH_peak_ipl
152inline Image::Image(const peak::ipl::Image& image)
153 : Image(CreateFromBuffer(peak::common::detail::CPixelFormatToCppPixelFormat(
154 static_cast<peak_common_pixel_format>(image.PixelFormat().PixelFormatName())), // NOLINT
155 peak::common::Size{ static_cast<uint32_t>(image.Width()), static_cast<uint32_t>(image.Height()) }, image.Data(),
156 image.ByteCount()))
157{
158 peak_icv_capture_information captureInformationC{};
159 captureInformationC.binning_factor = { 1, 1 };
160 captureInformationC.relative_timestamp = image.Timestamp();
161 detail::ExecuteAndMapReturnCodes([&] {
162 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC, sizeof(captureInformationC));
163 });
164
165 m_metaData = std::make_unique<peak::common::Metadata>(
166 AddCaptureInformationDataToMetadata(captureInformationC, peak::common::Metadata{}));
167 m_image = image;
168}
169#endif
170
171inline Image::Image(const peak::common::IImageView& imageView)
172 : Image(CreateFromImageView(imageView))
173{
174 const auto metadata = imageView.GetMetadata();
175 SetMetadata(*metadata);
176}
177
178inline Image::Image(const std::string& path)
179 : Image{ CreateFromFile(path) }
180{}
181
182inline Image::Image(const std::string& path, peak::common::PixelFormat name)
183 : Image{ CreateFromFile(path, name) }
184{}
185
186inline Image::Image(peak::common::PixelFormat pixelFormat, uint8_t* buffer, size_t bufferSize, const peak::common::Size& imageSize)
187 : Image{ CreateFromBuffer(pixelFormat, imageSize, buffer, bufferSize),
188 { peak::common::detail::CppPixelFormatToCPixelFormat(pixelFormat), { imageSize.GetWidth(), imageSize.GetHeight() }, bufferSize,
189 buffer } }
190{}
191
192inline Image::Image(peak::common::PixelFormat pixelFormat, const peak::common::Size& imageSize)
193 : Image{ CreateFromSize(pixelFormat, imageSize) }
194{}
195
196inline Image::Image(peak_icv_image_handle imageHandle)
197 : Image{ imageHandle, CreateFromHandle(imageHandle) }
198{}
199
200inline Image::Image(const Image& other)
201 : Image{ other.m_imageHandle, CreateFromHandle(other.m_imageHandle) }
202{
203 if (other.m_metaData)
204 {
205 m_metaData = std::make_unique<peak::common::Metadata>(*other.m_metaData);
206 }
208 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(other.m_imageHandle);
209 });
210#ifdef WITH_peak_ipl
211 m_image = other.m_image;
212#endif
213}
214
215inline Image::Image(Image&& other) noexcept
216 : Image{ other.m_imageHandle, CreateFromHandle(other.m_imageHandle) }
217{
218 m_metaData = std::move(other.m_metaData);
219#ifdef WITH_peak_ipl
220 m_image = std::move(other.m_image);
221#endif
222 other.m_imageHandle = nullptr;
223}
224
225inline Image& Image::operator=(const Image& other)
226{
227 if (this->m_imageHandle != other.m_imageHandle)
228 {
229 if (m_imageHandle)
230 {
232 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
233 });
234 }
235
237 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(other.m_imageHandle);
238 });
239 m_imageHandle = other.m_imageHandle;
240 m_size = other.m_size;
241 m_pixelFormatInfo = other.m_pixelFormatInfo;
242 m_buffer = other.m_buffer;
243 m_metaData = std::make_unique<peak::common::Metadata>(other.GetMetadata());
244#ifdef WITH_peak_ipl
245 m_image = other.m_image;
246#endif
247 }
248
249 return *this;
250}
251
252inline Image& Image::operator=(Image&& other) noexcept
253{
254 if (this->m_imageHandle != other.m_imageHandle)
255 {
256 if (m_imageHandle)
257 {
259 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
260 });
261 }
262
263 m_imageHandle = std::exchange(other.m_imageHandle, nullptr);
264 m_size = other.m_size;
265 m_pixelFormatInfo = other.m_pixelFormatInfo;
266 m_buffer = std::exchange(other.m_buffer, nullptr);
267 m_metaData = std::exchange(other.m_metaData, nullptr);
268#ifdef WITH_peak_ipl
269 m_image = std::move(other.m_image);
270#endif
271 }
272
273 return *this;
274}
275
277{
278 if (m_imageHandle != nullptr)
279 {
280 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
281 }
282}
283
284inline bool Image::operator==(const Image& rhs) const
285{
286 if (rhs.GetSizeInBytes() != this->GetSizeInBytes())
287 {
288 return false;
289 }
290 if (rhs.GetSize() != this->GetSize())
291 {
292 return false;
293 }
294 if (rhs.GetPixelFormat() != this->GetPixelFormat())
295 {
296 return false;
297 }
298 if (rhs.GetRegion() != this->GetRegion())
299 {
300 return false;
301 }
302 bool isSame{};
304 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Compare(
305 m_imageHandle, peak::common::detail::BackendAccessor<Image>::BackendHandle(rhs), &isSame);
306 });
307 return isSame;
308}
309
310inline Image Image::Copy() const
311{
312 Image tmpImg(m_pixelFormatInfo.GetPixelFormat(), m_size);
313#if _MSC_VER
314 memcpy_s(tmpImg.GetData(), tmpImg.GetSizeInBytes(), GetData(), GetSizeInBytes());
315#else
316 std::memcpy(tmpImg.GetData(), GetData(), GetSizeInBytes());
317#endif
318 tmpImg.SetMetadata(GetMetadata());
319 return tmpImg;
320}
321
323{
324 return m_size;
325}
326
327inline uint8_t* Image::GetData() const
328{
329 return m_buffer;
330}
331
332inline size_t Image::GetSizeInBytes() const
333{
334 return m_pixelFormatInfo.GetSizeInBytes(m_size);
335}
336
337inline size_t Image::GetBytesPerLine() const
338{
339 return GetSizeInBytes() / m_size.GetHeight();
340}
341
342inline detail::handle_of_t<Image> Image::GetHandle() const
343{
344 return m_imageHandle;
345}
346
348{
349 return m_pixelFormatInfo.GetPixelFormat();
350}
351
352#ifdef WITH_peak_ipl
353inline peak::ipl::Image Image::GetIPLImage() const
354{
355 if (!m_image.Empty())
356 {
357 return m_image;
358 }
359
360 constexpr std::array<peak::ipl::PixelFormatName, 59> possibleValues{ peak::ipl::PixelFormatName::BayerGR8,
361 peak::ipl::PixelFormatName::BayerGR10, peak::ipl::PixelFormatName::BayerGR12, peak::ipl::PixelFormatName::BayerRG8,
362 peak::ipl::PixelFormatName::BayerRG10, peak::ipl::PixelFormatName::BayerRG12, peak::ipl::PixelFormatName::BayerGB8,
363 peak::ipl::PixelFormatName::BayerGB10, peak::ipl::PixelFormatName::BayerGB12, peak::ipl::PixelFormatName::BayerBG8,
364 peak::ipl::PixelFormatName::BayerBG10, peak::ipl::PixelFormatName::BayerBG12, peak::ipl::PixelFormatName::Mono8,
365 peak::ipl::PixelFormatName::Mono10, peak::ipl::PixelFormatName::Mono12, peak::ipl::PixelFormatName::Mono16,
366 peak::ipl::PixelFormatName::Confidence8, peak::ipl::PixelFormatName::Confidence16,
367 peak::ipl::PixelFormatName::Coord3D_C8, peak::ipl::PixelFormatName::Coord3D_C16,
368 peak::ipl::PixelFormatName::Coord3D_C32f, peak::ipl::PixelFormatName::Coord3D_ABC32f,
369 peak::ipl::PixelFormatName::YUV420_8_YY_UV_SemiplanarIDS, peak::ipl::PixelFormatName::YUV420_8_YY_VU_SemiplanarIDS,
370 peak::ipl::PixelFormatName::YUV422_8_UYVY, peak::ipl::PixelFormatName::RGB8, peak::ipl::PixelFormatName::RGB10,
371 peak::ipl::PixelFormatName::RGB12, peak::ipl::PixelFormatName::BGR8, peak::ipl::PixelFormatName::BGR10,
372 peak::ipl::PixelFormatName::BGR12, peak::ipl::PixelFormatName::RGBa8, peak::ipl::PixelFormatName::RGBa10,
373 peak::ipl::PixelFormatName::RGBa12, peak::ipl::PixelFormatName::BGRa8, peak::ipl::PixelFormatName::BGRa10,
374 peak::ipl::PixelFormatName::BGRa12, peak::ipl::PixelFormatName::BayerBG10p, peak::ipl::PixelFormatName::BayerBG12p,
375 peak::ipl::PixelFormatName::BayerGB10p, peak::ipl::PixelFormatName::BayerGB12p, peak::ipl::PixelFormatName::BayerGR10p,
376 peak::ipl::PixelFormatName::BayerGR12p, peak::ipl::PixelFormatName::BayerRG10p, peak::ipl::PixelFormatName::BayerRG12p,
377 peak::ipl::PixelFormatName::Mono10p, peak::ipl::PixelFormatName::Mono12p, peak::ipl::PixelFormatName::RGB10p32,
378 peak::ipl::PixelFormatName::BGR10p32, peak::ipl::PixelFormatName::BayerRG10g40IDS,
379 peak::ipl::PixelFormatName::BayerGB10g40IDS, peak::ipl::PixelFormatName::BayerGR10g40IDS,
380 peak::ipl::PixelFormatName::BayerBG10g40IDS, peak::ipl::PixelFormatName::BayerRG12g24IDS,
381 peak::ipl::PixelFormatName::BayerGB12g24IDS, peak::ipl::PixelFormatName::BayerGR12g24IDS,
382 peak::ipl::PixelFormatName::BayerBG12g24IDS, peak::ipl::PixelFormatName::Mono10g40IDS,
383 peak::ipl::PixelFormatName::Mono12g24IDS };
384
385 const auto currentPixelFormat = m_pixelFormatInfo.GetPixelFormat();
386 const auto foundIt = std::find_if(possibleValues.begin(), possibleValues.end(), [&](const peak::ipl::PixelFormatName& name) {
387 return static_cast<std::underlying_type<peak::ipl::PixelFormatName>::type>(name)
388 == static_cast<std::underlying_type<peak::ipl::PixelFormatName>::type>(currentPixelFormat);
389 });
390 if (foundIt == possibleValues.end())
391 {
392 throw peak::icv::NotSupportedException("The pixelformat " + m_pixelFormatInfo.GetName()
393 + " has no equivalent in the ids_peak_ipl. As a result, it cannot be converted to an ids_peak_ipl Image!");
394 }
395
396 m_image = peak::ipl::Image{ static_cast<peak::ipl::PixelFormatName>(currentPixelFormat), m_buffer,
397 m_pixelFormatInfo.GetSizeInBytes(m_size), m_size.GetWidth(), m_size.GetHeight(),
399
400 return m_image;
401}
402#endif
403
405{
406 Region region;
408 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetRegion(
409 m_imageHandle, peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(region));
410 });
411 return region;
412}
413
414inline void Image::SetRegion(const Region& region) const
415{
416 const peak_icv_region_handle regionHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(region);
417
419 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetRegion(m_imageHandle, regionHandle);
420 });
421}
422
423inline void Image::ResetRegion() const
424{
426 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ResetRegion(m_imageHandle);
427 });
428}
429
431{
432 Image outputImage(pixelFormat, GetSize());
433 const auto imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(outputImage);
435 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ConvertPixelFormat(
436 m_imageHandle, peak::common::detail::CppPixelFormatToCPixelFormat(pixelFormat), imageHandle);
437 });
438 return outputImage;
439}
440
441inline Image Image::ConvertPixelFormatWithFactor(peak::common::PixelFormat pixelFormat, const double factor) const
442{
443 Image outputImage(pixelFormat, GetSize());
444 const auto imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(outputImage);
446 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ConvertPixelFormatWithFactor(
447 m_imageHandle, peak::common::detail::CppPixelFormatToCPixelFormat(pixelFormat), factor, imageHandle);
448 });
449 return outputImage;
450}
451
452inline void Image::SetMetadata(const peak::common::Metadata& metadata)
453{
454 auto captureInformationC = peak::icv::detail::CreateCCaptureInformationFromMetadata(metadata, m_size);
455
457 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC, sizeof(captureInformationC));
458 });
459
460 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, metadata));
461}
462
464{
465 peak_icv_capture_information captureInformationC;
467 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetCaptureInformation(
468 m_imageHandle, &captureInformationC, sizeof(captureInformationC));
469 });
470
471 if (!m_metaData)
472 {
473 m_metaData = std::make_unique<peak::common::Metadata>(
474 AddCaptureInformationDataToMetadata(captureInformationC, peak::common::Metadata{}));
475 }
476 else
477 {
478 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, *m_metaData));
479 }
480
481
482 return *m_metaData;
483}
484
485inline Image Image::Subtract(const peak::icv::Image& subtrahend) const
486{
487 Image difference{ GetPixelFormat(), GetSize() };
488
490 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Subtract(GetHandle(), subtrahend.GetHandle(), difference.GetHandle());
491 });
492
493
494 return difference;
495}
496
497inline Image Image::operator-(const peak::icv::Image& subtrahend) const
498{
499 return Subtract(subtrahend);
500}
501
503{
504 Image croppedImage{ GetPixelFormat(), { rect.GetWidth(), rect.GetHeight() } };
505
507 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Crop(GetHandle(), croppedImage.GetHandle(),
508 peak::common::detail::BackendAccessor<peak::common::Rectangle>::CreateCType(rect));
509 });
510 return croppedImage;
511}
512
513inline Image Image::Scale(const peak::common::Size& targetImageSize, const Interpolation& interpolation) const
514{
515 Image scaledImage{ GetPixelFormat(), targetImageSize };
517 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Scale(
518 GetHandle(), scaledImage.GetHandle(), static_cast<peak_icv_interpolation>(interpolation));
519 });
520 return scaledImage;
521}
522
523inline std::vector<Image> Image::Deinterleave() const
524{
525 size_t numOutputImages{};
527 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Deinterleave_GetOutputImageCount(
529 });
530 peak_common_pixel_format outputPixelFormat;
532 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Deinterleave_GetOutputPixelFormat(
534 });
535 peak_common_size outputSize{};
537 const auto size = GetSize();
538 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Deinterleave_GetOutputImageSize(
540 });
541
542 std::vector<Image> deinterleavedImages;
543 deinterleavedImages.reserve(numOutputImages);
544 std::vector<peak_icv_image_handle> deinterleavedImageHandles;
545 deinterleavedImages.reserve(numOutputImages);
546 for (size_t i = 0; i < numOutputImages; ++i)
547 {
549 { outputSize.width, outputSize.height } };
550 deinterleavedImageHandles.emplace_back(peak::common::detail::BackendAccessor<Image>::BackendHandle(tmpImage));
551 deinterleavedImages.emplace_back(std::move(tmpImage));
552 }
553
555 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Deinterleave(
556 GetHandle(), deinterleavedImageHandles.data(), deinterleavedImages.size());
557 });
558
559 return deinterleavedImages;
560}
561
562#ifdef WITH_peak_ipl
563inline Image::operator peak::ipl::Image() const
564{
565 return GetIPLImage();
566}
567#endif
568} /* namespace icv */
569} /* namespace peak */
Interface for viewing image pixel data from arbitrary sources.
virtual peak::common::PixelFormat GetPixelFormat() const =0
Returns the pixel format used by the image.
virtual std::size_t GetLineStartOffset() const =0
Returns the byte offset to the first pixel of a line.
virtual size_t GetBytesPerLine() const =0
Returns the number of bytes in a single image row.
virtual std::size_t GetSizeInBytes() const =0
Returns the total size of the image data in bytes.
virtual std::shared_ptr< peak::common::Metadata > GetMetadata()=0
Returns the metadata object which can be used to retrieve or set metadata belonging to the image.
virtual const uint8_t * GetData() const =0
Returns a pointer to the start of the first line that contains valid image data (read-only).
virtual Size GetSize() const =0
Returns the overall size of the image (width × height).
Type-safe container for image acquisition metadata.
void SetValueByKey(T &&value)
Stores a value using a strongly typed metadata key.
detail::MetadataKeyTraits< metadataKey >::type GetValueByKey() const
Retrieves the value of a strongly typed metadata key.
Provides information and utility functions for pixel formats.
size_t GetSizeInBytes(const Size &size) const
Calculates the memory size in bytes for a given image size.
peak::common::PixelFormat GetPixelFormat() const
Returns the underlying pixel format enumeration value.
std::string GetName() const
Returns the human-readable name of the pixel format.
A generic rectangle defined by a point and a size.
constexpr SizeType GetWidth() const
Returns the width of the rectangle.
constexpr SizeType GetHeight() const
Returns the height of the rectangle.
Represents a two-dimensional size with non-negative width and height.
constexpr T GetWidth() const
Returns the width.
constexpr T GetHeight() const
Returns the height.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
peak::common::Size GetSize() const
Provides the size of the image in pixels.
void ResetRegion() const
Resets the region on the image to the complete image.
Image operator-(const Image &subtrahend) const
Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting i...
Image & operator=(const Image &other)
uint8_t * GetData() const
Provides a pointer to the image data buffer.
Image Subtract(const Image &subtrahend) const
Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting i...
Region GetRegion() const
Provides the region of the image.
Image(const peak::common::IImageView &imageView)
Constructs an Image from an IImageView Instance.
peak::common::PixelFormat GetPixelFormat() const
Provides the pixel format of the image.
Image Crop(const peak::common::Rectangle &rect) const
Crops the image to the given rectangle.
peak::common::Metadata GetMetadata() const
Returns the Metadata of an image which contains information about the image capture information.
peak::icv::Image ConvertPixelFormat(peak::common::PixelFormat pixelFormat) const
Converts the image to a different pixel format.
void SetMetadata(const peak::common::Metadata &metadata)
Updates the Metadata of an image which is used to store and manage capture information.
Image Copy() const
Creates a deep copy of the current Image.
peak::icv::Image ConvertPixelFormatWithFactor(peak::common::PixelFormat pixelFormat, const double factor) const
Converts an image into another pixel format with a factor multiplied to every pixel.
Image Scale(const peak::common::Size &targetImageSize, const Interpolation &interpolation=Interpolation::NearestNeighbor) const
Returns an image scaled to the given image size.
size_t GetSizeInBytes() const
Provides the size of the image data in bytes.
std::vector< Image > Deinterleave() const
Splits an image with an interleaved pixel format into individual images.
bool operator==(const Image &rhs) const
size_t GetBytesPerLine() const
Computes the number of bytes required to store one line of pixel data (no padding).
void SetRegion(const Region &region) const
Updates the region on the image.
Occurs when a requested operation is not implemented or supported (e.g., exporting to an unsupported ...
Represents a region defined by a set of points in the image plane.
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
Interpolation
Enumeration of interpolation methods used in image transformations.
constexpr peak_common_pixel_format CppPixelFormatToCPixelFormat(PixelFormat pixelFormat) noexcept
constexpr PixelFormat CPixelFormatToCppPixelFormat(peak_common_pixel_format pixelFormat) noexcept
@ Roi
Region of interest applied to the image.
@ DeviceGain
Device gain the image was captured with.
@ DeviceExposureTime
Device exposure time the image was captured with.
@ BinningHorizontal
Horizontal pixel binning factor.
@ DeviceExposureTimeSequence
Device exposure time sequence the image was captured with.
@ DeviceTimestamp
Device-provided image acquisition timestamp in nanoseconds.
@ DeviceGainSequence
Device gain sequence the image was captured with.
@ BinningVertical
Vertical pixel binning factor.
peak_icv_capture_information CreateCCaptureInformationFromMetadata(const peak::common::Metadata &metadata)
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
peak::common::detail::c_type_of_t< Type > * handle_of_t
peak_icv_image * peak_icv_image_handle