Restrictions
For the
Resolution Restrictions
- Input image resolution
During image processing by VPC, the general input resolution ranges from 10 x 6 to 8192 x 8192. The resolution restrictions of some APIs may be different. For details, see the API descriptions in Vision Preprocessing Core (VPC). When the input image format is YUV440SP or YUV440P, the maximum width of the image is 4096.
- Output image resolution
Model
Resolution Range
Atlas inference products 10 x 6 to 4096 x 4096
Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products Atlas 200I/500 A2 inference products 10 x 6 to 4096 x 8192
APIs for Buffer Allocation and Freeing
For details about the requirements on the input and output buffer sizes, see the calculation formulas in Restrictions on Image Formats, Width and Height Alignment, and Buffers.
|
Model |
APIs for Buffer Allocation and Freeing |
|---|---|
|
|
During image processing by VPC, call hi_mpi_dvpp_malloc to allocate the input and output buffers on the device, and hi_mpi_dvpp_free to free the input and output buffers. The buffer lifetime is managed by the user. |
|
|
During image processing by VPC, the following two types of APIs for buffer allocation and freeing are supported:
Note: hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer resources are limited, aclrtMalloc is recommended for allocating buffer. |
Restrictions on Image Formats, Width and Height Alignment, and Buffers
When calling APIs to implement VPC functions:
- For details about the image format, see hi_pixel_format. For details about the width stride and height stride, see Terminology.
- Different APIs may have different requirements on image formats. For details, see the API descriptions in Vision Preprocessing Core (VPC).
|
Model |
Image Format |
Width x Height Alignment |
Width Stride x Height Stride Alignment |
Width Stride x Height Stride Alignment |
Buffer Size (in Bytes) |
|---|---|---|---|---|---|
|
General format, supported by all models |
YUV400 8-bit |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
YUV420SP NV12 8-bit YUV420SP NV21 8-bit |
Width: Must be a multiple of 2. Height: Must be a multiple of 2. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Round up the height to the nearest multiple of 2. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride x 3/2 |
|
|
YUV422SP 8-bit YVU422SP 8-bit |
Width: Must be a multiple of 2. Height: No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride x 2 |
|
|
YUV422 Packed YUYV 8-bit YUV422 Packed UYVY 8-bit YUV422 Packed YVYU 8-bit YUV422 Packed VYUY 8-bit |
Width: Must be a multiple of 2. Height: No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 2. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: Width x 2. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
|
YUV444 Packed 8-bit RGB888 BGR888 |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: Width x 3. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
|
Only the following models support this format: |
YUV444SP 8-bit YVU444SP 8-bit |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride x 3 |
|
ARGB8888 ABGR8888 RGBA8888 BGRA8888 |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: Width x 4. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
|
YUV440SP 8-bit YVU440SP 8-bit |
Width: No alignment requirements, but the width must be ≤ 4096. Height: Must be a multiple of 2. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Round up the height to the nearest multiple of 2. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: Round up the height to the nearest multiple of 2. |
Width stride x Height stride x 2 |
|
|
Only the following models support this format: |
YVU420 Planar YUV420 Planar |
Width: Must be a multiple of 2. Height: Must be a multiple of 2. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3/2 |
|
YVU422 Planar YUV422 Planar |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 2 |
|
|
YVU444 Planar YUV444 Planar |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3 |
|
|
YVU444 Packed 8-bit |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 3. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride |
|
|
YUV440 Planar YVU440 Planar |
Width: No alignment requirements, but the width must be ≤ 4096. Height: Must be a multiple of 2. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 2 |
|
|
RGB888 Planar BGR888 Planar |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3 |
|
|
Only the following models support this format: |
YUV400 FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride |
|
RGB888 FP32 BGR888 FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 3 x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride |
|
|
RGB888 Planar FP32 BGR888 Planar FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3 |
|
Model |
Image Format |
Width x Height Alignment |
Width Stride x Height Stride Alignment |
Width Stride x Height Stride Alignment |
Buffer Size (in Bytes) |
|---|---|---|---|---|---|
|
General format, supported by all models |
YUV400 8-bit |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
YUV420SP NV12 8-bit YUV420SP NV21 8-bit |
Width: Must be a multiple of 2. Height: Must be a multiple of 2. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: Round up the height to the nearest multiple of 2. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride x 3/2 |
|
|
YUV422SP 8-bit YVU422SP 8-bit |
Width: Must be a multiple of 2. Height: No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: No alignment requirements. The value is the same as the width. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride x 2 |
|
|
YUV444 Packed 8-bit RGB888 BGR888 |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 3. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: Width x 3. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
|
ARGB8888 ABGR8888 RGBA8888 BGRA8888 |
No alignment requirements. |
Width stride: Round up the width to the nearest multiple of 16 and multiply the result by 4. Height stride: No alignment requirements. The value is the same as the height. |
Width stride: Width x 4. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
|
Only the following models support this format: |
YUV422 Packed YUYV 8-bit YUV422 Packed UYVY 8-bit YUV422 Packed YVYU 8-bit YUV422 Packed VYUY 8-bit |
Width: No alignment requirements. Height: Must be a multiple of 2. |
- |
Width stride: Width x 2. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
Only the following models support this format: |
YVU444 Packed |
No alignment requirements. |
- |
Width stride: Width x 3. Height stride: No alignment requirements. The value is the same as the height. |
Width stride x Height stride |
|
RGB888 Planar BGR888 Planar |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the same as the width. Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3 |
|
|
Only the following models support this format: |
YUV400 FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride |
|
RGB888 FP32 BGR888 FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 3 x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride |
|
|
RGB888 Planar FP32 BGR888 Planar FP32 |
No alignment requirements. |
- |
Width stride: No alignment requirements, but the value must be the width x 4 (4 indicates that FP32 occupies four bytes). Height stride: No alignment requirements, but the value must be the same as the height. |
Width stride x Height stride x 3 |
Atlas A3 training products /Atlas A3 inference products : The minimum width stride is 10 and the minimum height stride is 6.Atlas A2 training products /Atlas A2 inference products : The minimum width stride is 10 and the minimum height stride is 6.Atlas 200I/500 A2 inference products : The minimum width stride is 10 and the minimum height stride is 6.Atlas inference products : The width stride ranges from 32 to 16384 (4096 x 4). For an ARGB image with a width of 4096, one pixel occupies four bytes, and a line of pixels occupy 4096 x 4 bytes. The height stride ranges from 6 to 16384.
Restrictions on Image Cropping and Pasting
- The cropped ROI must not be larger than the input image.
- Restrictions on the odd and even numbers of the cropped and pasted ROIs:
If the output image is in YUV420SP format, the left offset and top offset of the pasted ROI must be even numbers, and the right offset and bottom offset must be odd numbers.
If the output image is in YUV422SP format, the left offset of the pasted ROI must be an even number, and the right offset must be an odd number.
For other formats, there are no such limits.
- The pasted ROI must not be larger than the output image. A maximum of 256 pasted ROIs are supported.
Due to the 16-pixel alignment requirement, the following restrictions apply to
Atlas inference products :- Round up the left offset of the pasted ROI to the nearest multiple of 16. The pasted ROI can locate on the leftmost side of the output image, that is, with zero left offset relative to the output image.
- It is recommended that the width of the output image be a multiple of 16. Otherwise, an extra segment of invalid data is padded. As shown in Figure 4 and Figure 5, the green box indicates invalid data.
For inference, when the VPC output is used as the input of model inference, if the width of the valid pasted ROI is not a multiple of 16, you can resize this width to a multiple of 16 before pasting, or use AIPP to crop the valid ROI and remove invalid data to ensure inference accuracy.
- For resizing with the aspect ratio preserved, the left offset for pasting must be a multiple of 16. Therefore, the hi_mpi_vpc_crop_resize_paste call may result in paste ROI deviation from the center of the output image. In this case, you can add the hi_mpi_vpc_crop_resize_make_border or hi_mpi_vpc_batch_crop_resize_make_border call to implement the cropping, resizing, and padding functions together.
Restrictions on Downsampling of YUV Images
VPC converts the input image format to YUV444 or RGB for internal processing based on the input or output image format. YUV444 or RGB output format has no restriction on the odd and even numbers of the width and height, while the YUV420SP or YUV422SP output format, which is downsampled, has such restrictions due to the data format. Therefore, abnormal data may exist on the output image boarders.
The root cause is that during the computation, when the output image is at an odd start point, the image is correct for the YUV444 format. However, when the YUV420SP format is downsampled, the odd and even lines share the same UV. In this case, the Y of the start line and the UV of the previous line form a new pixel and abnormal data is generated.