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);
140 size_t Width()
const;
210 uint8_t*
Data()
const;
248 size_t outputImageBufferSize,
264 template <
typename Integer1,
typename Integer2,
265 typename std::enable_if_t<std::is_integral<Integer1>::value,
int> = 0,
266 typename std::enable_if_t<std::is_integral<Integer2>::value,
int> = 0>
269 return Scale(
peak::ipl::Size2D{
static_cast<std::size_t
>(width), static_cast<std::size_t>(height)}, algorithm);
317 template<
typename FloatingPoint1,
typename FloatingPoint2,
318 typename std::enable_if_t<std::is_floating_point<FloatingPoint1>::value,
int> = 0,
319 typename std::enable_if_t<std::is_floating_point<FloatingPoint2>::value,
int> = 0>
411 friend ImageBackendAccessor;
423 class ImageBackendAccessor
428 return image.m_backendHandle;
453 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.
PixelFormatName()), width, height, &m_backendHandle);
458 const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height)
462 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.
PixelFormatName()), buffer, bufferSize, width, height,
476 const peak::ipl::PixelFormat& pixelFormat, uint8_t* buffer,
size_t bufferSize,
size_t width,
size_t height, uint64_t timestamp_ns) :
477 Image::
Image(pixelFormat, buffer, bufferSize, width, height)
485 : m_backendHandle(imageHandle)
498 *
this = std::move(other);
506 m_backendHandle = other.m_backendHandle;
507 other.m_backendHandle =
nullptr;
538 uint8_t* pixelPosition =
nullptr;
544 return pixelPosition;
549 size_t byteCount = 0;
563 m_backendHandle, reinterpret_cast<PEAK_IPL_PIXEL_FORMAT*>(&pixelFormatName));
571 uint8_t* data =
nullptr;
584 static_cast<PEAK_IPL_PIXEL_FORMAT>(outputPixelFormat.
PixelFormatName()),
585 static_cast<PEAK_IPL_CONVERSION_MODE>(conversionMode), &outputImageHandle);
588 return ImageBackendAccessor::CreateImage(outputImageHandle);
597 static_cast<PEAK_IPL_PIXEL_FORMAT>(outputPixelFormat.
PixelFormatName()), outputImageBuffer,
598 outputImageBufferSize, static_cast<PEAK_IPL_CONVERSION_MODE>(conversionMode), &outputImageHandle);
601 return ImageBackendAccessor::CreateImage(outputImageHandle);
613 return ImageBackendAccessor::CreateImage(outputImageHandle);
618 return Scale(
Size2D{
static_cast<size_t>(
static_cast<double>(
Width()) * factor.
x),
static_cast<size_t>(
static_cast<double>(
Height()) * factor.
y)}, algorithm);
641 return ImageBackendAccessor::CreateImage(outputImageHandle);
646 return Crop({0,0}, size);
655 return ImageBackendAccessor::CreateImage(outputImageHandle);
665 uint64_t timestamp_ns;
701 return !(*
this == img);
PEAK_IPL_C_API PEAK_IPL_Image_GetData(PEAK_IPL_IMAGE_HANDLE imageHandle, uint8_t **data)
Queries the data pointer of the given image.
void ScaleInto(const peak::ipl::Size2D &size, uint8_t *buffer, std::size_t bufferSize, peak::ipl::InterpolationAlgorithm algorithm=InterpolationAlgorithm::linear) const
Scale the image to the supplied width and height using the supplied algorithm and save it into the su...
Definition: peak_ipl_image.hpp:621
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...
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
Image()
Creates an empty image, i.e. with size 0x0 and invalid pixel format.
Definition: peak_ipl_image.hpp:442
size_t height
Definition: peak_ipl_simple_types.hpp:180
Image ConvertTo(const peak::ipl::PixelFormat &outputPixelFormat, peak::ipl::ConversionMode conversionMode=peak::ipl::ConversionMode::Fast) const
Returns a new created image containing the data of the current image converted to the given pixel for...
Definition: peak_ipl_image.hpp:578
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
size_t ByteCount() const
Returns the size of the given image in number of bytes.
Definition: peak_ipl_image.hpp:547
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
bool operator!=(const Image &img) const
Checks whether the image is data wise different.
Definition: peak_ipl_image.hpp:699
Definition: peak_ipl_backend.h:59
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
size_t x
Definition: peak_ipl_simple_types.hpp:197
2D size of an image.
Definition: peak_ipl_simple_types.hpp:177
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.
double x
Definition: peak_ipl_simple_types.hpp:216
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_Scale(PEAK_IPL_IMAGE_HANDLE imageHandle, const PEAK_IPL_SIZE_2D *size, PEAK_IPL_INTERPOLATION_ALGORITHM algorithm, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image scaled to size using algorithm.
ConversionMode
Enum holding the possible conversion modes.
Definition: peak_ipl_simple_types.hpp:28
2D position in an image.
Definition: peak_ipl_simple_types.hpp:195
size_t Height() const
Returns the height.
Definition: peak_ipl_image.hpp:522
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.
PEAK_IPL_C_API PEAK_IPL_Image_ScaleInto(PEAK_IPL_IMAGE_HANDLE imageHandle, const 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.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:326
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()
Definition: peak_ipl_image.hpp:488
Image Clone() const
Returns a new created image containing the data of the current image as deep copy.
Definition: peak_ipl_image.hpp:649
double y
Definition: peak_ipl_simple_types.hpp:217
Scale Factors of an image.
Definition: peak_ipl_simple_types.hpp:214
uint64_t Timestamp() const
The timestamp in nanoseconds.
Definition: peak_ipl_image.hpp:663
peak::ipl::Size2D Size() const
Returns the Size.
Definition: peak_ipl_image.hpp:531
Image Scale(FloatingPoint1 scaleFactorX, FloatingPoint2 scaleFactorY, peak::ipl::InterpolationAlgorithm algorithm=InterpolationAlgorithm::linear) const
Scale the image to the supplied scale factors scaleFactorX and scaleFactorY using the supplied algori...
Definition: peak_ipl_image.hpp:320
Image Scale(Integer1 width, Integer2 height, peak::ipl::InterpolationAlgorithm algorithm=InterpolationAlgorithm::linear) const
Scale the image to the supplied width and height using the supplied algorithm.
Definition: peak_ipl_image.hpp:267
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_GetWidth(PEAK_IPL_IMAGE_HANDLE imageHandle, size_t *width)
Queries the width of the given image.
uint8_t * Data() const
Returns the pointer to the first pixel position in dependency on the size of the pixel format...
Definition: peak_ipl_image.hpp:569
InterpolationAlgorithm
Enum holding the possible interpolation algorithm.
Definition: peak_ipl_simple_types.hpp:163
bool operator==(const Image &img) const
Checks whether the image is data wise the same.
Definition: peak_ipl_image.hpp:673
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.
size_t Width() const
Returns the width.
Definition: peak_ipl_image.hpp:513
Image Crop(const peak::ipl::Point2D &pos, const peak::ipl::Size2D &size) const
Crop the image to the size starting at pos.
Definition: peak_ipl_image.hpp:631
uint8_t * PixelPointer(size_t xPos, size_t yPos) const
Returns the pixel pointer to the given pixel position in dependency of the size of the pixel format...
Definition: peak_ipl_image.hpp:536
size_t width
Definition: peak_ipl_simple_types.hpp:179
Definition: peak_ipl_backend.h:230
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:236
bool Empty() const
Checks whether the image is empty.
Definition: peak_ipl_image.hpp:658
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::PixelFormat PixelFormat() const
Returns the pixel format.
Definition: peak_ipl_image.hpp:557
PEAK_IPL_C_API PEAK_IPL_Image_Crop(PEAK_IPL_IMAGE_HANDLE imageHandle, const PEAK_IPL_POINT_2D *pos, const 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_Destruct(PEAK_IPL_IMAGE_HANDLE imageHandle)
Destroys the image associated with the given handle.
size_t y
Definition: peak_ipl_simple_types.hpp:198
Image & operator=(const Image &other)=delete