50 #ifndef NV_VPI_DETAIL_OPENCV_UTILS_HPP
51 #define NV_VPI_DETAIL_OPENCV_UTILS_HPP
54 #include "../ImageFormat.h"
55 #include "../Status.h"
57 #include <opencv2/core/core.hpp>
64 namespace nv {
namespace vpi {
namespace detail {
70 switch (CV_MAT_DEPTH(cvType))
73 switch (CV_MAT_CN(cvType))
94 switch (CV_MAT_CN(cvType))
115 switch (CV_MAT_CN(cvType))
138 switch (CV_MAT_CN(cvType))
159 switch (CV_MAT_CN(cvType))
180 switch (CV_MAT_CN(cvType))
201 switch (CV_MAT_CN(cvType))
309 case VPI_PACKING_X64_Y64:
325 assert(elemSize != 0);
334 if (ToOpenCVType(pixType) != mat.type())
356 if (mat.type() == CV_8UC1)
364 else if (mat.type() == CV_16UC1)
431 if (mat.step[0] != (
size_t)mat.cols)
436 for (
int p = 0; p < 3; ++p)
447 if (mat.step[0] != (
size_t)mat.cols * 2)
452 for (
int p = 0; p < 3; ++p)
505 assert(imgData != NULL);
507 if (mat.data == NULL)
528 status = FillImageDataOnePlaneImpl(mat, fmt, imgData);
532 status = FillImageDataTwoPlanesImpl(mat, fmt, imgData);
536 status = FillImageDataThreePlanesImpl(mat, fmt, imgData);
555 assert(imgData != NULL);
557 if (matPlanes.empty())
570 for (
size_t p = 0; p < matPlanes.size(); ++p)
572 const cv::Mat &mat = matPlanes[p];
574 if (mat.data == NULL)
586 if (ToOpenCVType(pixType) != mat.type())
603 assert(imgData != NULL);
605 if (mat.data == NULL)
683 for (
int i = 0; i < 3; ++i)
710 for (
int i = 0; i < 2; ++i)
741 status = CalcHeightOpenCVMatOnePlane(imgData, height);
745 status = CalcHeightOpenCVMatTwoPlanes(imgData, height);
749 status = CalcHeightOpenCVMatThreePlanes(imgData, height);
778 for (
int i = 0; i < imgData.
numPlanes; ++i)
782 if (cvTypes[i] == -1)
790 for (
int i = 0; i < imgData.
numPlanes; ++i)
VPIMemLayout vpiPixelTypeGetMemLayout(VPIPixelType type)
Get the memory layout of a pixel type.
VPIPacking vpiPixelTypeGetPacking(VPIPixelType type)
Get the packing of a pixel type.
VPIDataType vpiPixelTypeGetDataType(VPIPixelType type)
Get the data type of a pixel type.
int vpiPixelTypeGetBitsPerPixel(VPIPixelType type)
Get the number of bits per pixel of a pixel type.
VPIChromaSubsampling
Defines how chroma-subsampling is done.
int vpiChromaSubsamplingGetSamplesVert(VPIChromaSubsampling css)
Get the number of chroma samples for each group of 4 vertical luma samples.
int vpiChromaSubsamplingGetSamplesHoriz(VPIChromaSubsampling css)
Get the number of chroma samples for each group of 4 horizontal luma samples.
VPIDataType
Defines the channel data type.
@ VPI_PACKING_X64
One 64-bit channel.
@ VPI_PACKING_X8_Y8_Z8_W8
Four 8-bit channels in one 32-bit word.
@ VPI_PACKING_X8_Y8_Z8
Three 8-bit channels in three 8-bit words.
@ VPI_PACKING_X32_Y32_Z32_W32
Four 32-bit channels in three 32-bit words.
@ VPI_PACKING_X8
One 8-bit channel.
@ VPI_PACKING_X32_Y32_Z32
Three 32-bit channels in three 32-bit words.
@ VPI_PACKING_X32
One 32-bit channel.
@ VPI_PACKING_X8_Y8
Two 8-bit channels in two 8-bit words.
@ VPI_PACKING_X64_Y64_Z64
Three 64-bit channels in three 64-bit words.
@ VPI_PACKING_X64_Y64_Z64_W64
Four 64-bit channels in four 64-bit words.
@ VPI_PACKING_X16_Y16_Z16
Three 16-bit channels in three 16-bit words.
@ VPI_PACKING_X16
One 16-bit channel.
@ VPI_PACKING_X16_Y16
Two 16-bit channels in two 16-bit words.
@ VPI_PACKING_X16_Y16_Z16_W16
Four 16-bit channels in one 64-bit word.
@ VPI_PACKING_X8_Y8__X8_Z8
2 pixels of 2 8-bit channels each, totalling 4 8-bit words.
@ VPI_PACKING_X32_Y32
Two 32-bit channels in two 32-bit words.
@ VPI_PACKING_Y8_X8__Z8_X8
2 pixels of 2 swapped 8-bit channels each, totalling 4 8-bit words.
@ VPI_MEM_LAYOUT_PITCH_LINEAR
Pixels are laid out in row-major order, i.e., .
@ VPI_DATA_TYPE_FLOAT
Channel are floating point values.
@ VPI_DATA_TYPE_UNSIGNED
Channels are unsigned integer values.
@ VPI_DATA_TYPE_SIGNED
Channels are signed integer values.
int32_t height
Height of this plane in pixels.
VPIPixelType pixelType
Type of each pixel within this plane.
int32_t numPlanes
Number of planes.
int32_t width
Width of this plane in pixels.
void * data
Pointer to the first row of this plane.
int32_t pitchBytes
Difference in bytes of beginning of one row and the beginning of the previous.
VPIImagePlane planes[VPI_MAX_PLANE_COUNT]
Data of all image planes.
VPIImageFormat format
Image format.
#define VPI_MAX_PLANE_COUNT
Maximum number of data planes an image can have.
Stores information about image characteristics and content.
@ VPI_SUCCESS
Operation completed successfully.
@ VPI_ERROR_INTERNAL
Internal, non specific error.
@ VPI_ERROR_INVALID_ARGUMENT
Invalid argument, either wrong range or value not accepted.
@ VPI_ERROR_INVALID_IMAGE_FORMAT
Image type not accepted.