CSC

Function Description

Performs CSC on the input image and outputs the image to the Image object.

For details about the API, see ConvertFormat.

API Calling Process

Before calling the CSC APIs, prepare the image object to be converted.

Figure 1 Process of calling image processing (CSC) APIs

Key steps are demonstrated as follows:

  1. Perform global initialization by calling MxInit().
  2. Initialize ImageProcessor.

    Construct an ImageProcessor object and initialize the channel by calling InitVpcChannel(). If you skip this API, ImageProcessor automatically initializes the channel before CSC.

  3. Call the image decoding API to decode the input image.

    Decode the images based on services to generate an Image object that supports CSC. Subsequently, the image can be processed by using the image processing APIs to generate a final Image object that requires CSC.

  4. Construct the output Image object.

    Construct the Image object for storing CSC results by using the Image constructor.

  5. Perform CSC on the input image by calling ConvertFormat().
  6. Deinitialize the initialized global resources by calling MxDeInit().

Sample Code

The following is a code example of key steps of functions and features, which is for reference only and cannot be directly copied for compilation or running.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Initialization
MxInit();
{
    // Construct the image processing class.
    ImageProcessor imageProcessor(deviceId);

    // Decode the image for Image generation.
    // Decoded image class
    Image decodedImage;

    // Perform decoding based on the image path.
    APP_ERROR ret = imageProcessor.Decode(imagePath, decodedImage);
    if (ret != APP_ERR_OK) {
        std::cout << "Decode failed." << std::endl;
    }

    // (Optional) Initialize the image processing channel.
    imageProcessor.InitVpcChannel();

    // Perform CSC.
    // Image class after CSC
    Image convertImage;

    // Perform CSC.
    ret = imageProcessor.ConvertFormat(decodedImage, ImageFormat::RGB_888, convertImage);
    if (ret != APP_ERR_OK) {
        std::cout << "ConvertFormat failed." << std::endl;
    }
}
// Deinitialization
MxDeInit();