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... | |
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 fmt. 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. |
[in] | 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. |
[in] | matPlanes | Vector of cv::Mat , each one wrapping one image plane in imgData. |
Definition at line 290 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.