28 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromFile(&handle, path.c_str());
37 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromFileWithPixelFormat(
38 &handle, path.c_str(),
static_cast<peak_common_pixel_format
>(name));
45 peak_icv_image_info imageInfo{};
47 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetInfo(handle, &imageInfo,
sizeof(imageInfo));
57 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Create(
58 &handle,
static_cast<peak_common_pixel_format
>(pixelFormat), { size.
GetWidth(), size.
GetHeight() });
68 peak_icv_image_info info{
static_cast<peak_common_pixel_format
>(pixelFormat), { size.
GetWidth(), size.
GetHeight() }, bufferSize,
69 const_cast<uint8_t*
>(buffer) };
70 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_CreateFromImageInfo(&handle, info,
sizeof(info));
83 captureInformationC.region_of_interest.width, captureInformationC.region_of_interest.height });
88 : m_imageHandle{ handle }
89 , m_size{ info.size.width, info.size.height }
90 , m_buffer{ info.buffer }
91 , m_pixelFormatInfo{ static_cast<
peak::common::PixelFormat>(info.pixelFormat) }
95inline Image::Image(
const peak::ipl::Image& image)
96 : Image(CreateFromBuffer(static_cast<
peak::common::PixelFormat>(image.PixelFormat().PixelFormatName()),
97 peak::common::Size{ static_cast<uint32_t>(image.Width()), static_cast<uint32_t>(image.Height()) }, image.Data(),
100 peak_icv_capture_information captureInformationC{ { 1, 1 }, image.Timestamp(), {}, {} };
101 detail::ExecuteAndMapReturnCodes([&] {
102 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC,
sizeof(captureInformationC));
105 m_metaData = std::make_unique<peak::common::Metadata>(
112 :
Image(CreateFromBuffer(imageView.GetPixelFormat(), imageView.GetSize(), imageView.GetData(), imageView.GetSizeInBytes()))
119 :
Image{ CreateFromFile(path) }
123 :
Image{ CreateFromFile(path, name) }
127 :
Image{ CreateFromBuffer(pixelFormat, imageSize, buffer, bufferSize),
128 {
static_cast<peak_common_pixel_format
>(pixelFormat), { imageSize.
GetWidth(), imageSize.
GetHeight() }, bufferSize, buffer } }
132 :
Image{ CreateFromSize(pixelFormat, imageSize) }
136 :
Image{ imageHandle, CreateFromHandle(imageHandle) }
140 :
Image{ other.m_imageHandle, CreateFromHandle(other.m_imageHandle) }
143 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(other.m_imageHandle);
146 m_image = other.m_image;
151 :
Image{ other.m_imageHandle, CreateFromHandle(other.m_imageHandle) }
154 m_image = std::move(other.m_image);
156 other.m_imageHandle =
nullptr;
161 if (this->m_imageHandle != other.m_imageHandle)
166 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
171 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(other.m_imageHandle);
173 m_imageHandle = other.m_imageHandle;
174 m_size = other.m_size;
175 m_pixelFormatInfo = other.m_pixelFormatInfo;
176 m_buffer = other.m_buffer;
178 m_image = other.m_image;
187 if (this->m_imageHandle != other.m_imageHandle)
192 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
196 m_imageHandle = std::exchange(other.m_imageHandle,
nullptr);
197 m_size = other.m_size;
198 m_pixelFormatInfo = other.m_pixelFormatInfo;
199 m_buffer = std::exchange(other.m_buffer,
nullptr);
201 m_image = std::move(other.m_image);
210 if (m_imageHandle !=
nullptr)
212 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Destroy(m_imageHandle);
222 if (rhs.
GetSize() != this->GetSize())
230 if (rhs.
GetRegion() != this->GetRegion())
236 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Compare(
237 m_imageHandle, peak::common::detail::BackendAccessor<Image>::BackendHandle(rhs), &isSame);
275 return m_imageHandle;
284inline peak::ipl::Image Image::GetIPLImage()
const
286 if (!m_image.Empty())
291 PEAK_IPL_IMAGE_HANDLE imageHandle{};
294 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetIPLImage(m_imageHandle, &imageHandle);
297 return ImageBackendAccessor::CreateImage(imageHandle);
305 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetRegion(
306 m_imageHandle, peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(region));
313 const peak_icv_region_handle regionHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(region);
316 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetRegion(m_imageHandle, regionHandle);
323 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ResetRegion(m_imageHandle);
330 const auto imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(outputImage);
332 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ConvertPixelFormat(
333 m_imageHandle,
static_cast<peak_common_pixel_format
>(pixelFormat), imageHandle);
341 const auto imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(outputImage);
343 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_ConvertPixelFormatWithFactor(
344 m_imageHandle,
static_cast<peak_common_pixel_format
>(pixelFormat), factor, imageHandle);
354 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC,
sizeof(captureInformationC));
357 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, metadata));
362 peak_icv_capture_information captureInformationC;
364 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetCaptureInformation(
365 m_imageHandle, &captureInformationC,
sizeof(captureInformationC));
370 m_metaData = std::make_unique<peak::common::Metadata>(
375 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, *m_metaData));
387 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Subtract(GetHandle(), subtrahend.GetHandle(), difference.GetHandle());
404 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Crop(GetHandle(), croppedImage.GetHandle(),
405 peak::common::detail::BackendAccessor<peak::common::Rectangle>::CreateCType(rect));
414 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Scale(
415 GetHandle(), scaledImage.GetHandle(),
static_cast<peak_icv_interpolation
>(interpolation));
421inline Image::operator peak::ipl::Image()
const
423 return GetIPLImage();
Interface for viewing image pixel data from arbitrary sources.
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.
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.
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 ®ion) const
Updates the region on the image.
Represents a region defined by a set of points in the image plane.
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
@ Roi
Region of interest applied to the image.
@ BinningHorizontal
Horizontal pixel binning factor.
@ DeviceTimestamp
Device-provided image acquisition timestamp in nanoseconds.
@ 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