acldvppConvertColor
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
Description
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. aclCreateTensor needs to be called to create data of the aclTensor type (stored on the device). The data type of the input tensor can be UINT8 or FLOAT, and the format can be NHWC. Discontinuous tensors are not supported, in addition, N can be 1 or empty, and C can be 1, 3, or 4. The value 1 indicates the input GRAY image, the value 3 indicates the input RGB image, and the value 4 indicates that the alpha channel is 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: operator output tensor. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the output tensor can be UINT8 or FLOAT, and the format can be NHWC. Discontinuous tensors are not supported, in addition, N can be 1 or empty, and C can be 1, 3, or 4 (1 indicates the input GRAY image, 3 indicates the input RGB image, and 4 indicates that the alpha channel is included). The data type 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:
The status code acldvppStatus is returned. For details, see acldvpp Return Codes.
acldvppConvertColor
- Parameters:
- workspace: The aclrtMalloc API needs to be called to allocate the device memory. The memory size is workspaceSize. The memory address output by the aclrtMalloc API is passed here.
- 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 the task. You can reuse the created stream to save resources or call aclrtCreateStream to create a stream, and then pass the stream as an input parameter.
- Returns
The status code acldvppStatus is returned. 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.
Parent topic: Media Data Processing Operator APIs