Interoperability with OpenCV library. More...
Functions | |
| VPIStatus | vpiImageCreateWrapperOpenCVMat (const cv::Mat &mat, VPIImageFormat fmt, uint64_t flags, VPIImage *img) |
Wraps a cv::Mat in an VPIImage with the given image format. More... | |
| VPIStatus | vpiImageCreateWrapperOpenCVMat (const cv::Mat &mat, uint64_t flags, VPIImage *img) |
Wraps a cv::Mat in a 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 | vpiImageCreateWrapperOpenCVMatPlanes (const std::vector< cv::Mat > &matPlanes, VPIImageFormat fmt, uint64_t flags, VPIImage *img) |
Wraps a vector of cv::Mats 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.
|
inline |
#include </opt/nvidia/vpi2/include/vpi/OpenCVInterop.hpp>
Wraps a cv::Mat in a 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 | Bit field specifying the desired characteristics of the image. VPI_BACKEND_CPU flag is always added internally.
|
| [out] | img | Pointer to memory that will receive the created image handle. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | mat type is not supported. |
| VPI_ERROR_INVALID_ARGUMENT | mat is empty or has wrong number of dimensions. |
| VPI_ERROR_INVALID_ARGUMENT | Output img is NULL. |
| VPI_ERROR_OUT_OF_MEMORY | Not enough resources to create image. |
| VPI_ERROR_INVALID_CONTEXT | Current context is destroyed. |
| VPI_ERROR_INVALID_OPERATION | Requested backend isn't enabled in current context. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 166 of file OpenCVInterop.hpp.
Here is the call graph for this function:
|
inline |
#include </opt/nvidia/vpi2/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.
|
| [in] | flags | Bit field specifying the desired characteristics of the image. VPI_BACKEND_CPU flag is always added internally.
|
| [out] | img | Pointer to memory that will receive the created image handle. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | fmt is invalid or inconsistent with mat. |
| VPI_ERROR_INVALID_ARGUMENT | mat is empty or has wrong number of dimensions. |
| VPI_ERROR_INVALID_ARGUMENT | Output img is NULL. |
| VPI_ERROR_OUT_OF_MEMORY | Not enough resources to create image. |
| VPI_ERROR_INVALID_CONTEXT | Current context is destroyed. |
| VPI_ERROR_INVALID_OPERATION | Requested backend isn't enabled in current context. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 117 of file OpenCVInterop.hpp.
Here is the call graph for this function:
|
inline |
#include </opt/nvidia/vpi2/include/vpi/OpenCVInterop.hpp>
Wraps a vector of cv::Mats in a VPIImage, each cv::Mat representing one image plane.
The wrapped cv::Mats 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::Mats 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.
|
| [in] | flags | Bit field specifying the desired characteristics of the image. VPI_BACKEND_CPU flag is always added internally.
|
| [out] | img | Pointer to memory that will receive the created image handle. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | fmt is not supported. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | matPlanes type not consistent with fmt. |
| VPI_ERROR_INVALID_ARGUMENT | Some cv::Mat in matPlanes is empty, or matPlanes is empty. |
| VPI_ERROR_INVALID_OPERATION | Requested backend isn't enabled in current context. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 263 of file OpenCVInterop.hpp.
Here is the call graph for this function:
|
inline |
#include </opt/nvidia/vpi2/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 vpiImageLockData. If the pixel type of a plane is VPI_PIXEL_TYPE_DEFAULT, it'll be inferred from the image format given.
|
| [out] | mat | cv::Mat that will refer to imgData contents.
|
| VPI_ERROR_INVALID_ARGUMENT | Output mat is NULL. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | imgData is invalid. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 346 of file OpenCVInterop.hpp.
|
inline |
#include </opt/nvidia/vpi2/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 vpiImageLockData. If the pixel type of a plane is VPI_PIXEL_TYPE_DEFAULT, it'll be inferred from the image format given.
|
| [out] | matPlanes | Vector of cv::Mat, each one wrapping one image plane in imgData.
|
| VPI_ERROR_INVALID_ARGUMENT | Output matPlanes is NULL. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | imgData is invalid. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 375 of file OpenCVInterop.hpp.
|
inline |
#include </opt/nvidia/vpi2/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.
|
| VPI_ERROR_INVALID_ARGUMENT | Input mat is empty. |
| VPI_ERROR_INVALID_ARGUMENT | mat has wrong number of dimensions. |
| VPI_ERROR_INVALID_ARGUMENT | imgData is NULL. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 405 of file OpenCVInterop.hpp.
|
inline |
#include </opt/nvidia/vpi2/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.
|
| [out] | imgData | VPIImageData that will be filled. Existing contents are discarded.
|
| VPI_ERROR_INVALID_ARGUMENT | Input mat is empty. |
| VPI_ERROR_INVALID_ARGUMENT | imgData is NULL. |
| VPI_ERROR_INVALID_ARGUMENT | mat has wrong number of dimensions. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | fmt not consistent with mat. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 440 of file OpenCVInterop.hpp.
|
inline |
#include </opt/nvidia/vpi2/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.
|
| [out] | imgData | VPIImageData that will be filled. Existing contents are discarded.
|
| VPI_ERROR_INVALID_ARGUMENT | imgData is NULL. |
| VPI_ERROR_INVALID_ARGUMENT | matPlanes is empty. |
| VPI_ERROR_INVALID_ARGUMENT | Some cv::Mat in matPlanes is empty or has wrong number of dimensions. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | fmt not consistent with matPlanes. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 480 of file OpenCVInterop.hpp.
#include </opt/nvidia/vpi2/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.
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.
|
| [in] | mat | cv::Mat object to be wrapped.
|
| VPI_ERROR_INVALID_ARGUMENT | mat is empty or has wrong number of dimensions. |
| VPI_ERROR_INVALID_ARGUMENT | Output img is NULL. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | mat type is not supported. |
| VPI_ERROR_INVALID_OPERATION | mat dimensions and/or format don't match img. |
| VPI_ERROR_INVALID_OPERATION | img is locked. |
| VPI_ERROR_INVALID_OPERATION | img is not created by vpiImageCreateWrapperOpenCVMat or vpiImageCreateWrapper with correct buffer type. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 207 of file OpenCVInterop.hpp.
Here is the call graph for this function:
|
inline |
#include </opt/nvidia/vpi2/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::Mats must have the same characteristics (type and dimensions) of the existing cv::Mats being wrapped.
The VPIImage must have been created by vpiImageCreateWrapperOpenCVMatPlanes.
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::Mats 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.
|
| [in] | matPlanes | Vector of cv::Mat, each one representing one image plane. |
| VPI_ERROR_INVALID_IMAGE_FORMAT | Image format is not supported. |
| VPI_ERROR_INVALID_ARGUMENT | Input matPlanes is NULL. |
| VPI_ERROR_INVALID_ARGUMENT | Input imgData is NULL. |
| VPI_ERROR_INVALID_OPERATION | img is not created by vpiImageCreateWrapperOpenCVMat or vpiImageCreateWrapper with correct buffer type. |
| VPI_SUCCESS | Operation executed successfully. |
Definition at line 304 of file OpenCVInterop.hpp.
Here is the call graph for this function: