CvtColor
Function Usage
Converts the image color gamut type of a tensor to the specified type. Conversions between the following types are supported:
If keepMargin is set to true in the outputTensor, the output width is automatically aligned to a multiple of 16. The default value is false, indicating that the invalid boundary in the tensor is not reserved.
For details, see CSC.
- √: supported
- x: not supported
CSC Type |
Atlas inference product |
Atlas 800I A2 inference product |
|
|---|---|---|---|
YUVSP420 (nv12) to YUV400 (GRAY) |
√ |
√ |
√ |
YVUSP420 (nv21) to YUV400 (GRAY) |
x |
√ |
√ |
YUVSP420 (nv12) to RGB |
x |
√ |
√ |
YUVSP420 (nv12) to BGR |
x |
√ |
√ |
YVUSP420 (nv21) to RGB |
x |
√ |
√ |
YVUSP420 (nv21) to BGR |
x |
√ |
√ |
RGB to YUVSP420 (nv12) |
x |
√ |
√ |
RGB to YVUSP420 (nv21) |
x |
√ |
√ |
BGR to YUVSP420 (nv12) |
x |
√ |
√ |
BGR to YVUSP420 (nv21) |
x |
√ |
√ |
RGB to YUV400 (GRAY) |
x |
√ |
√ |
BGR to YUV400 (GRAY) |
x |
√ |
√ |
BGR to RGB |
x |
√ |
√ |
RGB to BGR |
x |
√ |
√ |
RGB to RGBA |
x |
√ |
√ |
RGBA to YUV400 (GRAY) |
x |
√ |
√ |
RGBA to RGB |
x |
√ |
√ |
GRAY to RGB |
x |
√ |
x |
RGBA to mRGBA |
x |
√ |
x |
The conversion from RGBA to mRGBA requires CANN 8.0.RC1 or later.
Prototype
1 | APP_ERROR CvtColor(const Tensor &inputTensor, Tensor &outputTensor, const CvtColorMode &mode, bool keepMargin = false, AscendStream &stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
inputTensor |
Input |
Tensor of type UINT8. The value cannot be empty. Memory needs to be allocated on the device or DVPP side.
|
outputTensor |
Output |
Tensor class, output tensor. If this parameter is not empty, allocate memory on the device or DVPP side and set the data type to UINT8. For RGBA-to-mRGBA and GRAY-to-RGB conversions, the tensor type must match the input tensor. |
mode |
Input |
Enumeration class, referring to the original type and target type of CSC. For details, see CvtColorMode. When the mode color gamut type is COLOR_BGR2YUVSP420, COLOR_RGB2YUVSP420, COLOR_RGB2YVUSP420, or COLOR_BGR2YVUSP420:
|
keepMargin |
Input |
Specifies whether to retain the invalid boundary in the tensor in the outputTensor. The default value is false, indicating that the invalid boundary in the tensor is not reserved. If keepMargin is set to true, the output width is automatically aligned with 16 and the invalid region is reserved. This parameter is invalid when mode is set to COLOR_GRAY2RGB or COLOR_RGBA2mRGBA. |
stream |
Input |
AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |