General Description

For the open classes described in this section, the same class instance is used in a single thread. Do not use the same class instance in different threads.

This chapter provides a set of easy-to-use APIs for media processing and model inference, facilitating the flexible development of AI applications. Six classes, including VideoDecoder, VideoEncoder, Image, ImageProcessor, Tensor, and Model, are provided for end-to-end inference applications.

  • When the Image class is used as the abstraction of video frames, images can be decoded by using the VideoDecoder class (for example, H.264 video frames to YUV video frames), or be encoded by using the VideoEncoder class.
  • When the Image class is used as the abstraction of images, images can be decoded by using the Decode API of the ImageProcessor class (for example, JPG image to YUV images), or be encoded by using the Encode API of the ImageProcessor class.

In addition, the ImageProcessor class provides other APIs, such as image cropping and resizing APIs, for the Image class.

The Tensor class is a data class that connects to the Model class. The Model class is the abstraction of the inference model and is responsible for allocating resources required for model inference. The inference is performed based on the Infer API. The Image class connects the Tensor class with the ToTensor API.

Figure 1 Overall structure