Sample Overview

Sample Obtaining

Go to the Ascend samples repository on Gitee or GitHub and download the sample package that matches the required version. For the version mapping, see "Release Notes" in the README file. Find the sample in the cplusplus/level1_single_api/7_dvpp/vpc_sample directory.

Description

This sample implements image cropping, resizing, padding, color space conversion (CSC), pyramid, lookup table (LUT) remapping, and histogram analysis.

Principles

The following table lists the key functions involved in this sample. For details about the APIs, see AscendCL API Reference.

Initialization

  • aclInit: initializes AscendCL.
  • aclFinalize: deinitializes AscendCL.

Device Management

  • aclrtSetDevice: sets the compute device.
  • aclrtGetRunMode: obtains the run mode of the software stack. The internal processing varies depending on the run mode.
  • aclrtResetDevice: resets the compute device and cleans up all resources associated with the device.

Context Management

  • aclrtCreateContext: creates a context.
  • aclrtDestroyContext: destroys a context.

Memory Management

  • aclrtMallocHost/aclrtFreeHost: allocates and frees host memory, respectively.
  • hi_mpi_dvpp_malloc/hi_mpi_dvpp_free: allocates and frees device memory respectively for storing input and output data during media data processing.

Data Transfer

aclrtMemcpy:

  • Transfers decode source data from the host to the device.
  • Transfers the inference result from the device to the host.

Data transfer is not required if your app runs in the board environment.

Media Data Processing V2

See the APIs provided in VPC.

Directory Structure

The sample directory is organized as follows:

├── common                       //Directory of the sample code files
│   ├── sample_comm.cpp         //Implementation file of common functions
│   ├── sample_comm.h           //Header file that declares common functions
│   ├── sample_comm_vpc_*.cpp   //Implementation file of functions for implementing image cropping and resizing

├── smoke_vpc                    //Directory of the sample code files
│   ├── sample_vpc.cpp          //Implementation file of the main function
                                         
├── CMakeLists.txt               //Build script