Imaging Control 4 C Library 1.2.0
|
Image data is passed around in image buffer objects (IC4_IMAGE_BUFFER). More...
Data Structures | |
struct | IC4_ALLOCATOR_CALLBACKS |
Contains function pointers used to configure a custom allocator for image buffers. More... | |
struct | IC4_BUFFER_POOL_CONFIG |
Configures the behavior of a IC4_BUFFER_POOL. More... | |
struct | IC4_BUFFERPOOL_ALLOCATION_OPTIONS |
Contains options to configure the allocation when requesting an image buffer from a buffer pool. More... | |
struct | IC4_FRAME_METADATA |
A structure containing frame metadata. More... | |
struct | IC4_IMAGE_TYPE |
Represents an image type, including pixel format and image dimensions. More... | |
struct | IC4_BUFFER_POOL |
The buffer pool allows allocating additional image buffers for use by the program. More... | |
struct | IC4_IMAGE_BUFFER |
Represents an image buffer. More... | |
Typedefs | |
typedef void(* | ic4_imagebuffer_memory_release) (void *ptr, size_t buffer_size, void *user_ptr) |
Defines a callback function to be called when an image buffer created by ic4_imagebuffer_wrap_memory is destroyed and the image data will no longer be accessed through it. | |
Functions | |
bool | ic4_bufferpool_create (struct IC4_BUFFER_POOL **ppPool, const struct IC4_BUFFER_POOL_CONFIG *config) |
Creates a new buffer pool. | |
struct IC4_BUFFER_POOL * | ic4_bufferpool_ref (struct IC4_BUFFER_POOL *pPool) |
Increases the buffer pool's internal reference count by one. | |
void | ic4_bufferpool_unref (struct IC4_BUFFER_POOL *pPool) |
Decreases the pool's internal reference count by one. | |
bool | ic4_bufferpool_get_buffer (struct IC4_BUFFER_POOL *pPool, const struct IC4_IMAGE_TYPE *image_type, const struct IC4_BUFFERPOOL_ALLOCATION_OPTIONS *options, struct IC4_IMAGE_BUFFER **ppImageBuffer) |
Gets a buffer from the buffer pool. | |
struct IC4_IMAGE_BUFFER * | ic4_imagebuffer_ref (struct IC4_IMAGE_BUFFER *pImageBuffer) |
Increases the image buffer's internal reference count by one. | |
void | ic4_imagebuffer_unref (struct IC4_IMAGE_BUFFER *pImageBuffer) |
Decreases the image buffer's internal reference count by one. | |
void * | ic4_imagebuffer_get_ptr (const struct IC4_IMAGE_BUFFER *pImageBuffer) |
Returns a pointer to the data managed by the image buffer. | |
ptrdiff_t | ic4_imagebuffer_get_pitch (const struct IC4_IMAGE_BUFFER *pImageBuffer) |
Returns the pitch for the image buffer. | |
size_t | ic4_imagebuffer_get_buffer_size (const struct IC4_IMAGE_BUFFER *pImageBuffer) |
Returns the size of the image buffer. | |
bool | ic4_imagebuffer_get_image_type (const struct IC4_IMAGE_BUFFER *pImageBuffer, struct IC4_IMAGE_TYPE *image_type) |
Queries information about the image buffers's image data type. | |
bool | ic4_imagebuffer_get_metadata (const struct IC4_IMAGE_BUFFER *pImageBuffer, struct IC4_FRAME_METADATA *metadata) |
Retrieves metadata from an image buffer object. | |
bool | ic4_imagebuffer_copy (const struct IC4_IMAGE_BUFFER *source, struct IC4_IMAGE_BUFFER *destination, unsigned int flags) |
Copies the contents of one image buffer to another image buffer. | |
bool | ic4_imagebuffer_is_writable (const struct IC4_IMAGE_BUFFER *buffer) |
Checks whether an image buffer object is (safely) writable. | |
bool | ic4_imagebuffer_wrap_memory (struct IC4_IMAGE_BUFFER **ppBuffer, void *data, size_t buffer_size, ptrdiff_t pitch, const struct IC4_IMAGE_TYPE *image_type, ic4_imagebuffer_memory_release on_release, void *on_release_user_ptr) |
Creates an image buffer object using external memory as storage area for the image data. | |
const char * | ic4_pixelformat_tostring (enum IC4_PIXEL_FORMAT pixel_format) |
Returns the name of a pixel format. | |
size_t | ic4_pixelformat_bpp (enum IC4_PIXEL_FORMAT pixel_format) |
Returns the bits per pixel of a pixel format. | |
bool | ic4_imagetype_tostring (const struct IC4_IMAGE_TYPE *image_type, char *buffer, size_t *buffer_size) |
Convert a given image type into a string representation. | |
Image data is passed around in image buffer objects (IC4_IMAGE_BUFFER).
Image buffer objects are created automatically when using one of the various sink types of this library.
Image buffer objects are reference-counted. To share an image buffer object between multiple parts of a program, use ic4_imagebuffer_ref(). Call ic4_imagebuffer_unref() when a reference is no longer required.
If the reference count reaches zero, the image buffer is returned to its source to be reused. For example, an image buffer retrieved from ic4_queuesink_pop_output_buffer() will be re-queued.
typedef void(* ic4_imagebuffer_memory_release) (void *ptr, size_t buffer_size, void *user_ptr) |
Defines a callback function to be called when an image buffer created by ic4_imagebuffer_wrap_memory is destroyed and the image data will no longer be accessed through it.
[in] | ptr | Pointer to the image data as passed as data into ic4_imagebuffer_wrap_memory |
[in] | buffer_size | Buffer size as passed as buffer_size into ic4_imagebuffer_wrap_memory |
[in] | user_ptr | The on_release_user_ptr parameter that was specified when the image buffer was created. |
Contains options to configure the behavior of ic4_imagebuffer_copy().
Enumerator | |
---|---|
IC4_IMAGEBUFFER_COPY_SKIP_IMAGE | Instructs ic4_imagebuffer_copy() to skip the image data when copying. If included in the |
IC4_IMAGEBUFFER_COPY_SKIP_CHUNKDATA | Instructs ic4_imagebuffer_copy() to not copy the chunk data. This can be useful if the chunk data is large and not required in the destination frame. |
enum IC4_PIXEL_FORMAT |
The pixel format defines the representation of pixels in an image.
Enumerator | |
---|---|
IC4_PIXEL_FORMAT_Unspecified | Unspecified pixel format, used to partially define a image type. |
IC4_PIXEL_FORMAT_Mono8 | Monochrome 8-bit. |
IC4_PIXEL_FORMAT_Mono10p | Monochrome 10-bit packed. |
IC4_PIXEL_FORMAT_Mono12p | Monochrome 12-bit packed. |
IC4_PIXEL_FORMAT_Mono16 | Monochrome 16-bit. |
IC4_PIXEL_FORMAT_BayerBG8 | Bayer Blue-Green 8-bit. |
IC4_PIXEL_FORMAT_BayerBG10p | Bayer Blue-Green 10-bit packed. |
IC4_PIXEL_FORMAT_BayerBG12p | Bayer Blue-Green 12-bit packed. |
IC4_PIXEL_FORMAT_BayerBG16 | Bayer Blue-Green 16-bit. |
IC4_PIXEL_FORMAT_BayerGB8 | Bayer Green-Blue 8-bit. |
IC4_PIXEL_FORMAT_BayerGB10p | Bayer Green-Blue 10-bit packed. |
IC4_PIXEL_FORMAT_BayerGB12p | Bayer Green-Blue 12-bit packed. |
IC4_PIXEL_FORMAT_BayerGB16 | Bayer Green-Blue 16-bit. |
IC4_PIXEL_FORMAT_BayerGR8 | Bayer Green-Red 8-bit. |
IC4_PIXEL_FORMAT_BayerGR10p | Bayer Green-Red 10-bit packed. |
IC4_PIXEL_FORMAT_BayerGR12p | Bayer Green-Red 12-bit packed. |
IC4_PIXEL_FORMAT_BayerGR16 | Bayer Green-Red 16-bit. |
IC4_PIXEL_FORMAT_BayerRG8 | Bayer Red-Green 8-bit. |
IC4_PIXEL_FORMAT_BayerRG10p | Bayer Red-Green 10-bit packed. |
IC4_PIXEL_FORMAT_BayerRG12p | Bayer Red-Green 12-bit packed. |
IC4_PIXEL_FORMAT_BayerRG16 | Bayer Red-Green 16-bit. |
IC4_PIXEL_FORMAT_BGRa8 | Blue-Green-Red-alpha 8-bit. |
IC4_PIXEL_FORMAT_BGRa16 | Blue-Green-Red-alpha 16-bit. |
IC4_PIXEL_FORMAT_BGR8 | Blue-Green-Red 8-bit. |
IC4_PIXEL_FORMAT_Mono12Packed | GigE Vision specific format, Monochrome 12-bit packed. |
IC4_PIXEL_FORMAT_BayerBG12Packed | GigE Vision specific format, Bayer Blue-Green 12-bit packed. |
IC4_PIXEL_FORMAT_BayerGB12Packed | GigE Vision specific format, Bayer Green-Blue 12-bit packed. |
IC4_PIXEL_FORMAT_BayerGR12Packed | GigE Vision specific format, Bayer Green-Red 12-bit packed. |
IC4_PIXEL_FORMAT_BayerRG12Packed | GigE Vision specific format, Bayer Red-Green 12-bit packed. |
IC4_PIXEL_FORMAT_YUV422_8 | YUV 4:2:2 8-bit. |
IC4_PIXEL_FORMAT_YCbCr422_8 | YCbCr 4:2:2 8-bit. |
IC4_PIXEL_FORMAT_YCbCr411_8_CbYYCrYY | YCbCr 4:1:1 8-bit (CbYYCrYY) |
IC4_PIXEL_FORMAT_YCbCr411_8 | YCbCr 4:1:1 8-bit (YYCbYYCr) |
IC4_PIXEL_FORMAT_AnyBayer8 | Virtual pixel format value to select any 8-bit bayer format. When setting the camera's IC4_PROPID_PIXEL_FORMAT to this value, automatically selects one of the 8-bit bayer pixel formats IC4_PIXEL_FORMAT_BayerBG8, IC4_PIXEL_FORMAT_BayerGB8, IC4_PIXEL_FORMAT_BayerRG8 or IC4_PIXEL_FORMAT_BayerGR8. |
IC4_PIXEL_FORMAT_AnyBayer10p | Virtual pixel format value to select any 10-bit packed bayer format. When setting the camera's IC4_PROPID_PIXEL_FORMAT to this value, automatically selects one of the 10-bit packed bayer pixel formats IC4_PIXEL_FORMAT_BayerBG10p, IC4_PIXEL_FORMAT_BayerGB10p, IC4_PIXEL_FORMAT_BayerRG10p or IC4_PIXEL_FORMAT_BayerGR10p. |
IC4_PIXEL_FORMAT_AnyBayer12p | Virtual pixel format value to select any 12-bit packed bayer format. When setting the camera's IC4_PROPID_PIXEL_FORMAT to this value, automatically selects one of the 12-bit packed bayer pixel formats IC4_PIXEL_FORMAT_BayerBG12p, IC4_PIXEL_FORMAT_BayerGB12p, IC4_PIXEL_FORMAT_BayerRG12p, IC4_PIXEL_FORMAT_BayerGR12p, IC4_PIXEL_FORMAT_BayerBG12Packed, IC4_PIXEL_FORMAT_BayerGB12Packed, IC4_PIXEL_FORMAT_BayerRG12Packed or IC4_PIXEL_FORMAT_BayerGR12Packed. |
IC4_PIXEL_FORMAT_AnyBayer16 | Virtual pixel format value to select any 16-bit bayer format. When setting the camera's IC4_PROPID_PIXEL_FORMAT to this value, automatically selects one of the 16-bit bayer pixel formats IC4_PIXEL_FORMAT_BayerBG16, IC4_PIXEL_FORMAT_BayerGB16, IC4_PIXEL_FORMAT_BayerRG16 or IC4_PIXEL_FORMAT_BayerGR16. |
IC4_PIXEL_FORMAT_Invalid | Invalid pixel format. |
bool ic4_bufferpool_create | ( | struct IC4_BUFFER_POOL ** | ppPool, |
const struct IC4_BUFFER_POOL_CONFIG * | config | ||
) |
Creates a new buffer pool.
[in] | ppPool | Pointer to a buffer pool handle to receive the new buffer pool. When the buffer pool is no longer required, release the object reference using ic4_bufferpool_unref(). |
[in] | config | Pointer to a structure containing the buffer pool configuration |
true
on success, otherwise false
.bool ic4_bufferpool_get_buffer | ( | struct IC4_BUFFER_POOL * | pPool, |
const struct IC4_IMAGE_TYPE * | image_type, | ||
const struct IC4_BUFFERPOOL_ALLOCATION_OPTIONS * | options, | ||
struct IC4_IMAGE_BUFFER ** | ppImageBuffer | ||
) |
Gets a buffer from the buffer pool.
The buffer is either newly allocated, or retrieved from the buffer pool's buffer cache.
[in] | pPool | A buffer pool |
[in] | image_type | Image type of the requested buffer |
[in] | options | A pointer to a IC4_BUFFERPOOL_ALLOCATION_OPTIONS structure specifying advance allocation options. May be NULL to use default allocation parameters. |
[out] | ppImageBuffer | Pointer to an image buffer handle to receive the buffer. When the buffer is no longer required, release the object reference using ic4_imagebuffer_unref(). |
true
on success, otherwise false
.struct IC4_BUFFER_POOL * ic4_bufferpool_ref | ( | struct IC4_BUFFER_POOL * | pPool | ) |
Increases the buffer pool's internal reference count by one.
[in] | pPool | A pointer to a buffer pool |
NULL
, the function returns NULL
. An error value is not set.void ic4_bufferpool_unref | ( | struct IC4_BUFFER_POOL * | pPool | ) |
Decreases the pool's internal reference count by one.
If the reference count reaches zero, the object is destroyed.
[in] | pPool | A pointer to a buffer pool |
NULL
, the function does nothing. An error value is not set.bool ic4_imagebuffer_copy | ( | const struct IC4_IMAGE_BUFFER * | source, |
struct IC4_IMAGE_BUFFER * | destination, | ||
unsigned int | flags | ||
) |
Copies the contents of one image buffer to another image buffer.
source | Source buffer to copy from |
destination | Destination buffer to copy into |
flags | A bitwise combination of values from IC4_IMAGEBUFFER_COPY_FLAGS. |
source
and destination
is not equal, the image is converted. For example, if the pixel format of source
is IC4_PIXEL_FORMAT_BayerRG8 and the pixel format of destination
is IC4_PIXEL_FORMAT_BGR8, a demosaicing operation creates a color image.flags
contains IC4_IMAGEBUFFER_COPY_SKIP_IMAGE, the function does not copy the image data. The function then only copies the meta data, and a program-defined algorithm can handle the image copy operation.flags
contains IC4_IMAGEBUFFER_COPY_SKIP_CHUNKDATA, the function does not copy the chunk data contained in source
. This can be useful if the chunk data is large and not required.source
and destination
are not equal, the function fails and the error value is set to IC4_ERROR_CONVERSION_NOT_SUPPORTED.destination
frame is not writable, the function fails and the error value is set to IC4_ERROR_INVALID_OPERATION.true
on success, otherwise false
.size_t ic4_imagebuffer_get_buffer_size | ( | const struct IC4_IMAGE_BUFFER * | pImageBuffer | ) |
Returns the size of the image buffer.
[in] | pImageBuffer | An image buffer |
0
if an error occurred.bool ic4_imagebuffer_get_image_type | ( | const struct IC4_IMAGE_BUFFER * | pImageBuffer, |
struct IC4_IMAGE_TYPE * | image_type | ||
) |
Queries information about the image buffers's image data type.
[in] | pImageBuffer | An image buffer |
[out] | image_type | A IC4_IMAGE_TYPE structure receiving the image data type information. |
true
on success, otherwise false
.bool ic4_imagebuffer_get_metadata | ( | const struct IC4_IMAGE_BUFFER * | pImageBuffer, |
struct IC4_FRAME_METADATA * | metadata | ||
) |
Retrieves metadata from an image buffer object.
[in] | pImageBuffer | An image buffer |
[out] | metadata | A IC4_FRAME_METADATA structure receiving the metadata. |
true
on success, otherwise false
.ptrdiff_t ic4_imagebuffer_get_pitch | ( | const struct IC4_IMAGE_BUFFER * | pImageBuffer | ) |
Returns the pitch for the image buffer.
The pitch is the distance between the starting memory location of two consecutive lines.
[in] | pImageBuffer | An image buffer |
0
if an error occurred.void * ic4_imagebuffer_get_ptr | ( | const struct IC4_IMAGE_BUFFER * | pImageBuffer | ) |
Returns a pointer to the data managed by the image buffer.
[in] | pImageBuffer | An image buffer |
NULL
if an error occurred. Use ic4_get_last_error() to query error information.bool ic4_imagebuffer_is_writable | ( | const struct IC4_IMAGE_BUFFER * | buffer | ) |
Checks whether an image buffer object is (safely) writable.
In some situations, image buffer objects are shared between the application holding a handle to the image buffer object and the library. For example, the image buffer might be shared with a display or a video writer.
A shared buffer is not safely writable. Writing to a buffer that is shared can lead to unexpected behavior, for example a modification may partially appear in the result of an operation that is happening in parallel.
Passing the image buffer into a function such as ic4_display_display_buffer() or ic4_videowriter_add_frame() can lead to a buffer becoming shared.
[in] | buffer | An image buffer object |
true
if the image buffer is not shared with any part of the library, and is therefore safely writable.false
, if the image buffer is shared and therefore should not be written into. struct IC4_IMAGE_BUFFER * ic4_imagebuffer_ref | ( | struct IC4_IMAGE_BUFFER * | pImageBuffer | ) |
Increases the image buffer's internal reference count by one.
[in] | pImageBuffer | An image buffer |
NULL
, the function returns NULL
. An error value is not set.void ic4_imagebuffer_unref | ( | struct IC4_IMAGE_BUFFER * | pImageBuffer | ) |
Decreases the image buffer's internal reference count by one.
If the reference count reaches zero, the image buffer is returned to its source to be reused.
[in] | pImageBuffer | An image buffer |
NULL
, the function does nothing. An error value is not set.bool ic4_imagebuffer_wrap_memory | ( | struct IC4_IMAGE_BUFFER ** | ppBuffer, |
void * | data, | ||
size_t | buffer_size, | ||
ptrdiff_t | pitch, | ||
const struct IC4_IMAGE_TYPE * | image_type, | ||
ic4_imagebuffer_memory_release | on_release, | ||
void * | on_release_user_ptr | ||
) |
Creates an image buffer object using external memory as storage area for the image data.
This function can be useful when copying image data into buffers of third-party libraries:
[out] | ppBuffer | Pointer to an image buffer handle to receive the new buffer object. When the buffer is no longer required, release the object reference using ic4_imagebuffer_unref(). |
[in] | data | Pointer to a region of memory to be used as image data by the image buffer object |
[in] | buffer_size | Size of the region of memory pointed to by data |
[in] | pitch | Difference between memory addresses of two consecutive lines of image data |
[in] | image_type | Type of image to be stored in the image buffer |
[in] | on_release | Optional pointer to a callback function to be called when the image buffer object is destroyed. This can be useful when the program needs to keep track of the memory pointer to by the image buffer and has to release it once the image buffer object no longer exists. The lifetime of the image buffer can potentially be extended beyond the existance of its handle when it is shared with API functions, e.g. ic4_display_display_buffer or ic4_videowriter_add_frame. |
[in] | on_release_user_ptr | User pointer to be passed when calling on_release. |
true
on success, otherwise false
.bool ic4_imagetype_tostring | ( | const struct IC4_IMAGE_TYPE * | image_type, |
char * | buffer, | ||
size_t * | buffer_size | ||
) |
Convert a given image type into a string representation.
[out] | image_type | Pointer to a IC4_IMAGE_TYPE value to receive the error code. |
[out] | buffer | Pointer to a character array to receive the string. This parameter can be NULL to find out the required space without allocating an initial array. |
[in,out] | buffer_size | Pointer to a size_t describing the length of the array pointed to by buffer.The function always writes the actual number of characters required to store the string representation. |
true
on success. NULL
, the function fails and returns false
. NULL
, and *buffer_size
is smaller than the required number of bytes to store the string, the function fails and returns false
. size_t ic4_pixelformat_bpp | ( | enum IC4_PIXEL_FORMAT | pixel_format | ) |
Returns the bits per pixel of a pixel format.
[in] | pixel_format | pixel format |
0
if the bits per pixel of the pixel format is unknown. const char * ic4_pixelformat_tostring | ( | enum IC4_PIXEL_FORMAT | pixel_format | ) |
Returns the name of a pixel format.
[in] | pixel_format | A pixel format |
NULL
.