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, the output width is automatically aligned with 16. The default value is false, indicating that the invalid boundary in the tensor is not reserved. Table 1 lists the CSC types supported by each product. The meanings of the symbols are as follows:
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 |
RGB to mRGBA |
x |
√ |
x |
The conversion from RGBA to mRGBA requires CANN 8.0.RC1 or later.
cvt_color(inputTensor: Tensor, cvtColorMode: cvt_color_mode, keepMargin = False)
Parameter |
Input/Output |
Description |
|---|---|---|
inputTensor |
Input |
Tensor of type dtype.uint8. The value cannot be empty. Memory needs to be allocated on the device side.
|
cvtColorMode |
Input |
Enumeration class, referring to the original type and target type of CSC. If the cvtColorMode CSC type is base.color_bgr2yuvsp420, base.color_rgb2yuvsp420, base.color_rgb2yvusp420, or base.color_bgr2yvusp420:
|
keepMargin |
Input |
Whether to retain the invalid boundary in the tensor in the output tensor. The default value is False, indicating that the invalid boundary is not retained. 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 cvtColorMode is set to base.color_gray2rgb or base.color_rgba2mrgba. |
Converted tensor data