Interoperability with OpenCV library. More...
Functions | |
VPIStatus | vpiImageCreateOpenCVMatWrapper (const cv::Mat &mat, VPIImageFormat fmt, uint32_t flags, VPIImage *img) |
Wraps a cv::Mat in an VPIImage with the given image format. More... | |
VPIStatus | vpiImageCreateOpenCVMatWrapper (const cv::Mat &mat, uint32_t flags, VPIImage *img) |
Wraps a cv::Mat in an VPIImage and infers the image format from its type. More... | |
VPIStatus | vpiImageSetWrappedOpenCVMat (VPIImage img, const cv::Mat &mat) |
Redefines the wrapped cv::Mat of an existing VPIImage wrapper. More... | |
VPIStatus | vpiImageCreateOpenCVMatPlanesWrapper (const std::vector< cv::Mat > &matPlanes, VPIImageFormat fmt, uint32_t flags, VPIImage *img) |
Wraps a vector of cv::Mat in a VPIImage , each cv::Mat representing one image plane. More... | |
VPIStatus | vpiImageSetWrappedOpenCVMatPlanes (VPIImage img, const std::vector< cv::Mat > &matPlanes) |
Replaces the wrapped cv::Mat planes with new ones. More... | |
VPIStatus | vpiImageDataExportOpenCVMat (const VPIImageData &imgData, cv::Mat *mat) |
Fills an existing cv::Mat with data from VPIImageData coming from a locked VPIImage. More... | |
VPIStatus | vpiImageDataExportOpenCVMatPlanes (const VPIImageData &imgData, std::vector< cv::Mat > *matPlanes) |
Fills a vector of cv::Mat with all planes from VPIImageData. More... | |
VPIStatus | vpiImageDataImportOpenCVMat (const cv::Mat &mat, VPIImageData *imgData) |
Fills an existing VPIImageData with data from given cv::Mat . More... | |
VPIStatus | vpiImageDataImportOpenCVMat (const cv::Mat &mat, VPIImageFormat fmt, VPIImageData *imgData) |
Fills an existing VPIImageData with data from given cv::Mat , forcing the given image format. More... | |
VPIStatus | vpiImageDataImportOpenCVMatPlanes (const std::vector< cv::Mat > &matPlanes, VPIImageFormat fmt, VPIImageData *imgData) |
Fills a vector of cv::Mat describing all planes from given VPIImageData forcing the given image format. More... | |
Interoperability with OpenCV library.
VPI allows easy interoperability with OpenCV. This makes it easy to wrap existing cv::Mat
object into VPIImage to be used in VPI pipelines.
It's also possible to create a cv::Mat
out of a VPIImageData. EGL is our main vehicle for interoperability with multimedia, camera and graphics APIs.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Wraps a vector of cv::Mat
in a VPIImage
, each cv::Mat
representing one image plane.
The wrapped cv::Mat
s must not be destroyed while there's a VPIImage still wrapping it. The std::vector
object itself isn't used so it can be destroyed, or even be temporary. Failure to keep cv::Mat
s allocated leads to undefined behavior.
[in] | matPlanes | Vector of cv::Mat , each one representing one image plane. |
[in] | fmt | The image format associated with matPlanes. An error is returned if this format isn't consistent the vector size and the contained cv::Mat 's dimensions and type. |
[in] | flags | Image flags. Here it can be specified in what backends the image can be used by or-ing together VPIBackend flags. Set flags to 0 to enable it in all backends supported by the active VPI context. |
[out] | img | Pointer to memory that will receive the created image handle. |
Definition at line 201 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Wraps a cv::Mat in an VPIImage and infers the image format from its type.
The rules to infer the image type are:
The cv::Mat must not be destroyed while there's a VPIImage still wrapping it. Failure to do so leads to undefined behavior.
[in] | mat | The OpenCV matrix to be wrapped. |
[in] | flags | Image flags. Here it can be specified in what backends the image can be used by or-ing together VPIBackend flags. Set flags to 0 to enable it in all backends supported by the active VPI context. |
[out] | img | Pointer to memory that will receive the created image handle. |
Definition at line 133 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Wraps a cv::Mat
in an VPIImage with the given image format.
It also wraps YUV images in 4:2:2 (packed and semi-planar) and 4:2:0 (semi-planar) formats that are understood by cv::cvtColor
.
The cv::Mat must not be destroyed while there's a VPIImage still wrapping it. Failure to do so leads to undefined behavior.
[in] | mat | The OpenCV matrix to be wrapped. |
[in] | fmt | The image format associated with mat. An error is returned if this format isn't consistent with mat dimensions and type. |
[in] | flags | Image flags. Here it can be specified in what backends the image can be used by or-ing together VPIBackend flags. Set flags to 0 to enable it in all backends supported by the active VPI context. |
[out] | img | Pointer to memory that will receive the created image handle. |
Definition at line 101 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Fills an existing cv::Mat
with data from VPIImageData coming from a locked VPIImage.
No image contents will be copied, they're just referenced by cv::Mat. The result can be used in OpenCV operations.
If imgData has 2 or 3 planes that are contiguous in memory and represent some multi-planar formats as understood by cv::cvtColor
such as NV12 or YUV422, the resulting mat will be filled so that cv::cvtColor
understand it as having these types. In other works, they can be used with cv::COLOR_YUV2RGB_NV12
or COLOR_YUV2RGB_UYVY
.
[in] | imgData | Reference to VPIImageData returned by vpiImageLock. |
[out] | mat | cv::Mat that wil refer to imgData contents. |
Definition at line 269 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Fills a vector of cv::Mat
with all planes from VPIImageData.
No image contents will be copied, they're just referenced by cv::Mat. The result can be used in OpenCV operations.
[in] | imgData | Reference to VPIImageData returned by vpiImageLock. |
[out] | matPlanes | Vector of cv::Mat , each one wrapping one image plane in imgData. |
Definition at line 290 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Fills an existing VPIImageData with data from given cv::Mat
.
It performs the inverse operation of vpiImageDataExportOpenCVMat. Please refer to this function's description on what is the criteria used for image format deduction.
[in] | mat | Reference to cv::Mat with information to be filled in output |
[out] | imgData | VPIImageData that will be filled. Existing contents are discarded. |
Definition at line 312 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Fills an existing VPIImageData with data from given cv::Mat
, forcing the given image format.
It performs the inverse operation of vpiImageDataExportOpenCVMat. Please refer to this function's description on what is the criteria used for image format deduction.
[in] | mat | Reference to cv::Mat with information to be filled in output |
[in] | fmt | The image format associated with mat. An error is returned if this format isn't consistent the vector size and the contained cv::Mat 's dimensions and type. |
[out] | imgData | VPIImageData that will be filled. Existing contents are discarded. |
Definition at line 338 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Fills a vector of cv::Mat
describing all planes from given VPIImageData forcing the given image format.
It performs the inverse operation of vpiImageDataExportOpenCVMatPlanes. Please refer to this function's description on what is the criteria used for image format deduction.
The image format isn't deduced from the input cv::Mat
, but is given by the user. If the format isn't compatible with the cv::Mat
, an error is returned.
[in] | matPlanes | Vector of cv::Mat , each describing one plane. |
[in] | fmt | The image format associated with matPlanes. An error is returned if this format isn't consistent the vector size and the contained cv::Mat 's dimensions and type. |
[out] | imgData | VPIImageData that will be filled. Existing contents are discarded. |
Definition at line 367 of file OpenCVInterop.hpp.
#include <vpi/OpenCVInterop.hpp>
Redefines the wrapped cv::Mat
of an existing VPIImage wrapper.
The new cv::Mat
must have the same characteristics (type and dimensions) of the existing cv::Mat
being wrapped.
The VPIImage must have been created by vpiImageCreateOpenCVMatWrapper.
This operation is efficient and does not allocate memory. The wrapped memory will be accessible to the same backends specified during wrapper creation.
The wrapped cv::Mat
must be valid while it's still being wrapped.
[in] | img | Handle to an image created by vpiImageCreateOpenCVMatWrapper . |
[in] | mat | cv::Mat object to be wrapped. |
Definition at line 163 of file OpenCVInterop.hpp.
|
inline |
#include <vpi/OpenCVInterop.hpp>
Replaces the wrapped cv::Mat planes with new ones.
The new cv::Mat
vector must have the same size, and contained cv::Mat
s must have the same characteristics (type and dimensions) of the existing cv::Mat
s being wrapped.
The VPIImage must have been created by vpiImageCreateOpenCVMatPlanesWrapper.
This operation is efficient and does not allocate memory. The wrapped memory will be accessible to the same backends specified during wrapper creation.
The wrapped cv::Mat
s must be valid while it's still being wrapped. The std::vector
object itself can be destroyed, or even be temporary.
[in] | img | Handle to an image created by vpiImageCreateOpenCVMatPlanesWrapper . |
[in] | matPlanes | Vector of cv::Mat , each one representing one image plane. |
Definition at line 234 of file OpenCVInterop.hpp.