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 "batchcrop" sample in the cplusplus/level2_simple_inference/0_data_process/batchcrop directory.
In this example, eight 224 x 224 child images (YUV420SP NV12) are cropped out from the YUV420SP (NV12) input based on the specified cropping areas.
The following table lists the key functions involved in this sample. For details about the APIs, see AscendCL API Reference.
Initialization |
|
|---|---|
Device Management |
|
Context Management |
|
Stream Management |
|
Memory Management |
In media data processing, if you need to allocate device memory to store the input or output data, call acldvppMalloc to allocate memory and call acldvppFree to free up memory. |
Data Transfer |
aclrtMemcpy:
Data transfer is not required if your app runs in the board environment. |
Media Data Processing |
The sample directory is organized as follows:
├── data │ ├── dvpp_vpc_1920x1080_nv12.yuv //Test image. Obtain the test image according to the guide and save it to the data directory. ├── inc │ ├── dvpp_process.h //Header file that declares functions related to media data processing │ ├── sample_process.h //Header file that declares functions related to model processing │ ├── utils.h //Header file that declares common functions (such as the file reading function) ├── src │ ├── acl.json //Configuration file for system initialization │ ├── CMakeLists.txt //Build script │ ├── dvpp_process.cpp //Implementation file of functions related to media data processing │ ├── main.cpp //Implementation file of the main function, for single-image, multi-ROI cropping │ ├── sample_process.cpp //Implementation file of functions related to resource initialization and destruction │ ├── utils.cpp //Implementation file of common functions (such as the file reading function) ├── CMakeLists.txt //Build script that calls the CMakeLists file in the src directory