Imaging Control 4 C++ Library 1.2.0
|
Represents an image buffer. More...
Classes | |
struct | MetaData |
A structure containing frame metadata. More... | |
Public Types | |
enum class | CopyOptions : int { Default = 0 , SkipImage = c_interface::IC4_IMAGEBUFFER_COPY_SKIP_IMAGE , SkipChunkData = c_interface::IC4_IMAGEBUFFER_COPY_SKIP_CHUNKDATA } |
Contains options to configure the behavior of ImageBuffer::copyFrom(). More... | |
using | ReleaseMemoryHandler = std::function< void(void *ptr, size_t bufferSize)> |
Defines a callback function to be called when an image buffer created by ImageBuffer::wrapMemory is destroyed and the image data will no longer be accessed through it. | |
Public Member Functions | |
const ImageType & | imageType (Error &err=Error::Default()) const |
Queries information about the image buffers's image data type. | |
void * | ptr (Error &err=Error::Default()) const |
Returns a pointer to the data managed by the image buffer. | |
size_t | bufferSize (Error &err=Error::Default()) const |
Returns the size of the image buffer. | |
ptrdiff_t | pitch (Error &err=Error::Default()) const |
Returns the pitch for the image buffer. | |
MetaData | metaData (Error &err=Error::Default()) |
Retrieves frame metadata from an image buffer object. | |
bool | copyFrom (const ImageBuffer &buffer, CopyOptions options=CopyOptions::Default, Error &err=Error::Default()) |
Copies the contents of one image buffer to another image buffer. | |
bool | isWritable () const |
Checks whether an image buffer object is (safely) writable. | |
Static Public Member Functions | |
static std::shared_ptr< ImageBuffer > | wrapMemory (void *data, size_t bufferSize, ptrdiff_t pitch, const ImageType &imageType, ReleaseMemoryHandler on_release={}, Error &err=Error::Default()) |
Creates an image buffer object using external memory as storage area for the image data. | |
Represents an image buffer.
Image buffer objects are created automatically by the various Sink types. They can also be created manually on request by a BufferPool, or by calling ImageBuffer::wrapMemory().
Programs use image buffers via std::shared_ptr<ImageBuffer>
. If all pointers are released, the image buffer object is returned to its source for reuse. For example, an image buffer retrieved from QueueSink::popOutputBuffer() will be re-queued.
using ReleaseMemoryHandler = std::function<void(void* ptr, size_t bufferSize)> |
Defines a callback function to be called when an image buffer created by ImageBuffer::wrapMemory 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 wrapMemory |
[in] | bufferSize | Buffer size as passed as buffer_size into wrapMemory |
|
strong |
Contains options to configure the behavior of ImageBuffer::copyFrom().
Enumerator | |
---|---|
Default | Default behavior. Copy image data, meta data and chunk data. |
SkipImage | Instructs ImageBuffer::copyFrom() to skip the image data when copying. If included in the |
SkipChunkData | Instructs ImageBuffer::copyFrom() to not copy the chunk data. This can be useful if the chunk data is large and not required in the destination frame. |
|
inline |
Returns the size of the image buffer.
[out] | err | Reference to an error handler. See Error Handling for details. |
0
if an error occurred.err
output parameter for details.
|
inline |
Copies the contents of one image buffer to another image buffer.
[in] | buffer | Source buffer to copy from |
[in] | options | A bitwise combination of CopyOptions to customize the copy operation |
[out] | err | Reference to an error handler. See Error Handling for details. |
true
on success, otherwise false
.err
output parameter for details.source
and destination
is not equal, the image is converted. For example, if the pixel format of source
is PixelFormat::BayerRG8 and the pixel format of destination
is PixelFormat::BGR8, a demosaicing operation creates a color image.flags
contains CopyOptions::SkipImage, 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 CopyOptions::SkipChunkData, 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 ErrorCode::ConversionNotSupported. destination
image buffer is not writable, the function fails and the error value is set to ErrorCode::InvalidOperation.
|
inline |
Queries information about the image buffers's image data type.
[out] | err | Reference to an error handler. See Error Handling for details. |
|
inline |
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 Display::displayBuffer() or VideoWriter::addFrame() can lead to a buffer becoming shared.
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.
|
inline |
Retrieves frame metadata from an image buffer object.
[out] | err | Reference to an error handler. See Error Handling for details. |
|
inline |
Returns the pitch for the image buffer.
The pitch is the distance between the starting memory location of two consecutive lines.
[out] | err | Reference to an error handler. See Error Handling for details. |
0
if an error occurred.err
output parameter for details.
|
inline |
Returns a pointer to the data managed by the image buffer.
[out] | err | Reference to an error handler. See Error Handling for details. |
nullptr
if an error occurred.err
output parameter for details.
|
inlinestatic |
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:
[in] | data | Pointer to a region of memory to be used as image data by the image buffer object |
[in] | bufferSize | Size of the region of memory pointed to by data |
[in] | pitch | Difference between memory addresses of two consecutive lines of image data |
[in] | imageType | Type of image to be stored in the image buffer |
[in] | on_release | Optional 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. Display::displayBuffer or VideoWriter::addFrame. |
[out] | err | Reference to an error handler. See Error Handling for details. |
nullptr
if an error occurs.