Cropping and Padding Configuration

AIPP supports cropping and padding to change image size. Do cropping and padding in sequence. Each operation can be performed only once.

After AIPP processing, the source image (srcImageSizeW * srcImageSizeH) is resized to dstImageSizeW * dstImageSizeH.

Figure 1 Image resize

The solid box indicates the current image size, and the dotted box indicates the image size resulting from AIPP processing.

In practice, you must specify the upper left coordinates (loadStartPosW, loadStartPosH) of the crop start and the size (crop_size_w and crop_size_h) of the cropped image in the configuration file. During padding, specify the padding size (left_padding_size, right_padding_size, top_padding_size, and bottom_padding_size) around the cropped image. The resized image must be of the same size as the image fed to the model, as specified by --input_shape.

For YUV420SP_U8 images, the values of load_start_pos_w and load_start_pos_h must be even numbers. A configuration example is as follows:

aipp_op {
    aipp_mode: static
    input_format: YUV420SP_U8

    src_image_size_w: 320  
    src_image_size_h: 240

    crop: true
    load_start_pos_w: 10
    load_start_pos_h: 20
    crop_size_w: 50
    crop_size_h: 60


    padding: true
    left_padding_size: 20
    right_padding_size: 15
    top_padding_size: 20
    bottom_padding_size: 15
    padding_value: 0

}