21 #include <type_traits> 25 class ImageBackendAccessor;
84 const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height);
121 Image(
const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height, uint64_t timestamp_ns);
300 size_t outputImageBufferSize,
316 template <
typename Integer1,
typename Integer2,
317 typename std::enable_if_t<std::is_integral<Integer1>::value,
int> = 0,
318 typename std::enable_if_t<std::is_integral<Integer2>::value,
int> = 0>
321 return Scale(
peak::ipl::Size2D{
static_cast<std::size_t
>(width), static_cast<std::size_t>(height)}, algorithm);
369 template<
typename FloatingPoint1,
typename FloatingPoint2,
370 typename std::enable_if_t<std::is_floating_point<FloatingPoint1>::value,
int> = 0,
371 typename std::enable_if_t<std::is_floating_point<FloatingPoint2>::value,
int> = 0>
374 return Scale(peak::ipl::ScaleFactor{
static_cast<double>(scaleFactorX), static_cast<double>(scaleFactorY)}, algorithm);
463 friend ImageBackendAccessor;
477 class ImageBackendAccessor
489 return image.m_backendHandle;
538 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), width, height, &m_backendHandle);
543 const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height)
547 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), buffer, bufferSize, width, height,
561 const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height, uint64_t timestamp_ns) :
562 Image::
Image(pixelFormat, buffer, bufferSize, width, height)
570 : m_backendHandle(imageHandle)
572 if (acquireReference && m_backendHandle)
588 if (other.m_backendHandle)
593 m_backendHandle = other.m_backendHandle;
605 if (other.m_backendHandle)
611 m_backendHandle = other.m_backendHandle;
618 *
this = std::move(other);
625 if (m_backendHandle !=
nullptr)
629 m_backendHandle = other.m_backendHandle;
630 other.m_backendHandle =
nullptr;
636 inline size_t Image::Width()
const 645 inline size_t Image::Height()
const 656 return {Width(), Height()};
659 inline uint8_t* Image::PixelPointer(
size_t xPos,
size_t yPos)
const 661 uint8_t* pixelPosition =
nullptr;
667 return pixelPosition;
670 inline size_t Image::ByteCount()
const 672 size_t byteCount = 0;
686 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
692 inline uint8_t* Image::Data()
const 694 uint8_t* data =
nullptr;
707 static_cast<PEAK_IPL_PIXEL_FORMAT>(outputPixelFormat.PixelFormatName()),
708 static_cast<PEAK_IPL_CONVERSION_MODE>(conversionMode), &outputImageHandle);
711 return ImageBackendAccessor::CreateImage(outputImageHandle);
720 static_cast<PEAK_IPL_PIXEL_FORMAT>(outputPixelFormat.PixelFormatName()), outputImageBuffer,
721 outputImageBufferSize, static_cast<PEAK_IPL_CONVERSION_MODE>(conversionMode), &outputImageHandle);
724 return ImageBackendAccessor::CreateImage(outputImageHandle);
736 return ImageBackendAccessor::CreateImage(outputImageHandle);
741 return Scale(
Size2D{
static_cast<size_t>(
static_cast<double>(Width()) * factor.x),
static_cast<size_t>(
static_cast<double>(Height()) * factor.y)}, algorithm);
754 inline Image Image::Crop(
const Point2D& pos,
const Size2D& size)
const 764 return ImageBackendAccessor::CreateImage(outputImageHandle);
769 return Crop({0,0}, size);
772 inline Image Image::Clone()
const 778 return ImageBackendAccessor::CreateImage(outputImageHandle);
781 inline bool Image::Empty()
const 786 inline uint64_t Image::Timestamp()
const 788 uint64_t timestamp_ns;
798 if (img.ByteCount() != this->ByteCount())
802 if (img.Width() != this->Width())
806 if (img.Height() != this->Height())
810 if (img.PixelFormat().PixelFormatName() != this->
PixelFormat().PixelFormatName())
814 if (img.Timestamp() != this->Timestamp())
819 return memcmp(img.Data(), this->Data(), img.ByteCount()) == 0;
824 return !(*
this == img);
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_Image_GetData(PEAK_IPL_IMAGE_HANDLE imageHandle, uint8_t **data)
Queries the data pointer of the given image.
PEAK_IPL_C_API PEAK_IPL_Image_GetPixelFormat(PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_PIXEL_FORMAT *pixelFormat)
Queries the pixel format of the given image.
PEAK_IPL_C_API PEAK_IPL_Image_ConvertToBuffer(PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_PIXEL_FORMAT outputPixelFormat, uint8_t *outputImageBuffer, size_t outputImageBufferSize, PEAK_IPL_CONVERSION_MODE conversionMode, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Stores the data of the current image converted to the given pixel format into a destination buffer an...
PEAK_IPL_C_API PEAK_IPL_Image_Scale(PEAK_IPL_IMAGE_HANDLE imageHandle, const struct PEAK_IPL_SIZE_2D *size, PEAK_IPL_INTERPOLATION_ALGORITHM algorithm, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image scaled to size using algorithm.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
Image()
Creates an empty image. In other words, size is 0x0 and an invalid pixel format.
Definition: peak_ipl_image.hpp:527
size_t height
Height of size.
Definition: peak_ipl_simple_types.hpp:206
PEAK_IPL_C_API PEAK_IPL_Image_Clone(PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Returns a new created image containing the data of the current image as deep copy.
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
size_t x
Definition: peak_ipl_backend.h:263
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
Definition: peak_ipl_backend.h:75
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
2D size of an image.
Definition: peak_ipl_simple_types.hpp:203
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
PEAK_IPL_C_API PEAK_IPL_Image_GetTimestamp(PEAK_IPL_IMAGE_HANDLE imageHandle, uint64_t *timestamp_ns)
Get the timestamp for an image in nanoseconds.
bool operator!=(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:425
PEAK_IPL_C_API PEAK_IPL_Image_GetHeight(PEAK_IPL_IMAGE_HANDLE imageHandle, size_t *height)
Queries the height of the given image.
PEAK_IPL_C_API PEAK_IPL_Image_GetPixelPointer(PEAK_IPL_IMAGE_HANDLE imageHandle, size_t xPos, size_t yPos, uint8_t **pixelPointer)
Queries the pointer to the given pixel position.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:357
PEAK_IPL_C_API PEAK_IPL_Image_ConvertTo(PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_PIXEL_FORMAT outputPixelFormat, PEAK_IPL_CONVERSION_MODE conversionMode, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image containing the data of the current image converted to the given pixel format...
~Image()
Destructor for the Image instance.
Definition: peak_ipl_image.hpp:578
Image & operator=(const Image &other)
Copy assigment for Image instance.
Definition: peak_ipl_image.hpp:596
ConversionMode
Enum holding the possible conversion modes.
Definition: peak_ipl_simple_types.hpp:28
PEAK_IPL_C_API PEAK_IPL_Image_ConstructFromBuffer(PEAK_IPL_PIXEL_FORMAT pixelFormat, uint8_t *buffer, uint64_t bufferSize, size_t width, size_t height, PEAK_IPL_IMAGE_HANDLE *imageHandle)
Creates an image from a given buffer.
PEAK_IPL_C_API PEAK_IPL_Image_Acquire(PEAK_IPL_IMAGE_HANDLE imageHandle)
Increase the reference count of an image object.
PEAK_IPL_C_API PEAK_IPL_Image_GetWidth(PEAK_IPL_IMAGE_HANDLE imageHandle, size_t *width)
Queries the width of the given image.
InterpolationAlgorithm
Enum holding the possible interpolation algorithm.
Definition: peak_ipl_simple_types.hpp:189
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:419
PEAK_IPL_C_API PEAK_IPL_Image_ScaleInto(PEAK_IPL_IMAGE_HANDLE imageHandle, const struct PEAK_IPL_SIZE_2D *size, uint8_t *buffer, size_t bufferSize, PEAK_IPL_INTERPOLATION_ALGORITHM algorithm)
Creates a new image scaled to size using algorithm into the supplied buffer.
PEAK_IPL_C_API PEAK_IPL_Image_GetByteCount(PEAK_IPL_IMAGE_HANDLE imageHandle, size_t *byteCount)
Queries the size of the given image in number of bytes.
Image ConvertTo(const peak::ipl::PixelFormat &outputPixelFormat, uint8_t *outputImageBuffer, size_t outputImageBufferSize, peak::ipl::ConversionMode conversionMode=peak::ipl::ConversionMode::Fast) const
Saves the data of the current image converted to the given pixel format into a destination buffer and...
Definition: peak_ipl_image.hpp:701
size_t width
Width of size.
Definition: peak_ipl_simple_types.hpp:205
Definition: peak_ipl_backend.h:261
PEAK_IPL_C_API PEAK_IPL_Image_SetTimestamp(PEAK_IPL_IMAGE_HANDLE imageHandle, uint64_t timestamp_ns)
Set the timestamp for an image in nanoseconds.
Definition: peak_ipl_backend.h:267
PEAK_IPL_C_API PEAK_IPL_Image_Crop(PEAK_IPL_IMAGE_HANDLE imageHandle, const struct PEAK_IPL_POINT_2D *pos, const struct PEAK_IPL_SIZE_2D *size, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image cropped to size starting at position.
PEAK_IPL_C_API PEAK_IPL_Image_Construct(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t width, size_t height, PEAK_IPL_IMAGE_HANDLE *imageHandle)
Creates an image.
PEAK_IPL_C_API PEAK_IPL_Image_Destruct(PEAK_IPL_IMAGE_HANDLE imageHandle)
Destroys the image associated with the given handle.