acldvppConvertColor
Applicability
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
x |
|
|
x |
|
|
x |
Function Usage
Description: changes the color space of an image.
Prototype
Each operator has two-phase API calls. First, acldvppConvertColorGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppConvertColor is called to perform computation. The two-phase APIs are as follows:
- First-phase API:
1acldvppStatus acldvppConvertColorGetWorkspaceSize(const aclTensor *self, acldvppConvertMode convertMode, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)
- Second-phase API:
1acldvppStatus acldvppConvertColor(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
acldvppConvertColorGetWorkspaceSize
- Parameters:
- self: input tensor of the operator, which is of the aclTensor type created by calling aclCreateTensor (the tensor data is stored on the device). The value of dataType of the input tensor can be UINT8 or FLOAT, the value of Format can be NHWC, and non-contiguous tensors are not supported. The value of N can be 1 or left empty, and the value of C can be 1, 3, or 4 (1: input GRAY image; 3: input RGB image; 4: alpha channel included).
- convertMode: color space conversion (CSC) mode of the image. The enumerated values are the same as those of OpenCV. If the configured conversion mode involves the alpha channel, only the UINT8 input and output data are supported. convertMode can be set to any of the values listed in the following:
- COLOR_BGR2BGRA: converts BGR images into BGRA images.
- COLOR_RGB2RGBA: converts RGB images into RGBA images.
- COLOR_BGRA2BGR: converts BGRA images into BGR images.
- COLOR_RGBA2RGB: converts RGBA images into RGB images.
- COLOR_BGR2RGBA: converts BGR images into RGBA images.
- COLOR_RGB2BGRA: converts RGB images into BGRA images.
- COLOR_RGBA2BGR: converts RGBA images into BGR images.
- COLOR_BGRA2RGB: converts BGRA images into RGB images.
- COLOR_BGR2RGB: converts BGR images into RGB images.
- COLOR_RGB2BGR: converts RGB images into BGR images.
- COLOR_BGRA2RGBA: converts BGRA images into RGBA images.
- COLOR_RGBA2BGRA: converts RGBA images into BGRA images.
- COLOR_BGR2GRAY: converts BGR images to GRAY images.
- COLOR_RGB2GRAY: converts RGB images into GRAY images.
- COLOR_GRAY2BGR: converts a GRAY image to a BGR image.
- COLOR_GRAY2RGB: converts GRAY images into RGB images.
- COLOR_GRAY2BGRA: converts GRAY images to BGRA images.
- COLOR_GRAY2RGBA: converts GRAY images into RGBA images.
- COLOR_BGRA2GRAY: converts BGRA images to GRAY images.
- COLOR_RGBA2GRAY: converts RGBA images into GRAY images.
- out: output tensor of the operator, which is of the aclTensor type created by calling aclCreateTensor (the tensor data is stored on the device). The value of dataType of the output tensor can be UINT8 or FLOAT, the value of Format can be NHWC, and non-contiguous tensors are not supported. The value of N can be 1 or left empty, and the value of C can be 1, 3, or 4 (1: input GRAY image; 3: input RGB image; 4: alpha channel included), and the values of dataType and Format must be the same as those of self.
- workspaceSize: size of the workspace to be allocated on the device.
- executor: operator executor, containing the operator computation process.
- Returns:
acldvppStatus status code. For details, see acldvpp Return Codes.
acldvppConvertColor
- Parameters:
- workspace: address of the device memory allocated by calling aclrtMalloc. The size of the device memory is specified by workspaceSize.
- workspaceSize: The value must be the same as that obtained by calling acldvppConvertColorGetWorkspaceSize.
- executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppConvertColorGetWorkspaceSize API.
- stream: stream for executing a task, which can be a created stream for saving resources or newly created by the aclrtCreateStream API call.
- Returns:
acldvppStatus status code. For details, see acldvpp Return Codes.
Constraints
- The supported image resolution ranges from 6 x 4 to 4096 x 8192.
- For the conversion mode involving the alpha channel, only the UINT8 input and output data are supported.