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));
79 metadata.
SetValueByName<
decltype(captureInformationC.binning_factor.x)>(
80 "BinningHorizontal", std::move(captureInformationC.binning_factor.x));
81 metadata.
SetValueByName<
decltype(captureInformationC.binning_factor.y)>(
82 "BinningVertical", std::move(captureInformationC.binning_factor.y));
87 : m_imageHandle{ handle }
88 , m_size{ info.size.width, info.size.height }
89 , m_buffer{ info.buffer }
90 , m_pixelFormatInfo{ static_cast<
peak::common::
PixelFormat>(info.pixelFormat) }
94inline Image::Image(
const peak::ipl::Image& image)
96 peak::common::
Size{ static_cast<uint32_t>(image.Width()), static_cast<uint32_t>(image.Height()) }, image.Data(),
99 peak_icv_capture_information captureInformationC{ { 1, 1 }, image.Timestamp(), {} };
100 detail::ExecuteAndMapReturnCodes([&] {
101 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC,
sizeof(captureInformationC));
104 m_metaData = std::make_unique<peak::common::Metadata>(
111 :
Image(CreateFromBuffer(imageView.GetPixelFormat(), imageView.GetSize(), imageView.GetData(), imageView.GetSizeInBytes()))
118 :
Image{ CreateFromFile(path) }
122 :
Image{ CreateFromFile(path, name) }
126 :
Image{ CreateFromBuffer(pixelFormat, imageSize, buffer, bufferSize),
127 {
static_cast<peak_common_pixel_format
>(pixelFormat), { imageSize.
GetWidth(), imageSize.
GetHeight() }, bufferSize, buffer } }
131 :
Image{ CreateFromSize(pixelFormat, imageSize) }
135 :
Image{ imageHandle, CreateFromHandle(imageHandle) }
139 :
Image{ other.m_imageHandle, CreateFromHandle(other.m_imageHandle) }
142 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_IncreaseUseCount(other.m_imageHandle);
145 m_image = other.m_image;
150 :
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 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<experimental::Region>::BackendHandleAddress(region));
313 const peak_icv_region_handle regionHandle = peak::common::detail::BackendAccessor<experimental::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);
343 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_SetCaptureInformation(m_imageHandle, captureInformationC,
sizeof(captureInformationC));
346 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, metadata));
352 peak_icv_capture_information captureInformationC;
354 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_GetCaptureInformation(
355 m_imageHandle, &captureInformationC,
sizeof(captureInformationC));
360 m_metaData = std::make_unique<peak::common::Metadata>(
365 m_metaData = std::make_unique<peak::common::Metadata>(AddCaptureInformationDataToMetadata(captureInformationC, *m_metaData));
377 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Subtract(GetHandle(), subtrahend.GetHandle(), difference.GetHandle());
394 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Crop(GetHandle(), croppedImage.GetHandle(),
395 peak::common::detail::BackendAccessor<peak::common::Rectangle>::CreateCType(rect));
404 return PEAK_ICV_C_ABI_PREFIX peak_icv_Image_Scale(
405 GetHandle(), scaledImage.GetHandle(),
static_cast<peak_icv_interpolation
>(interpolation));
411inline Image::operator peak::ipl::Image()
const
413 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.
void SetRegion(const experimental::Region ®ion) const
Updates the region on the image.
peak::common::Size GetSize() const
Provides the size of the image.
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)
experimental::Region GetRegion() const
Provides the region of the image.
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...
Image(const peak::common::IImageView &imageView)
Constructs an Image from an IImageView Instance. This can be a buffer or a possibility to convert oth...
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 CaptureInformation of an image which contains information about the image capture setting...
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 CaptureInformation of an image which is used to store and manage capture settings.
Image Copy() const
Creates a deep copy of the current Image.
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).
A region consists of a set of points in the image plane.
detail::SizeT< uint32_t > Size
Size with unsigned 32-bit integer dimensions.
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
@ DeviceTimestamp
Device-provided image acquisition timestamp in nanoseconds.
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