---
title: YUV420SP_U8转BGR格式
description: "- 场景说明："
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/atctool/atlasatc_16_0028.html
sourcePath: /source/zh/canncommercial/900/devaids/atctool/atlasatc_16_0028.html
indexId: 6fa6e7bed3874f97e041f0f5770b08b3555a0ca0122bf2b069b571d3b65daec567
---
# YUV420SP_U8转BGR格式

- 场景说明：
  AIPP输入图像格式为YUV420SP_U8（NV12）、输出图像格式为BGR，输入图像尺寸为256*256；原始网络模型的C=3，H和W与AIPP输入图像尺寸相同。

- 该场景涉及以下AIPP配置：

  - 无需配置抠图功能参数crop；
  - 需要配置色域转换开关csc_switch和相应的CSC矩阵参数。
- AIPP配置文件示例如下：

```
aipp_op {
aipp_mode: static
input_format: YUV420SP_U8
csc_switch: true
# 如果输入的是YVU420SP_U8（NV21）图像，则需要将rbuv_swap_switch参数设置为true
rbuv_swap_switch: false
related_input_rank: 0
src_image_size_w: 256
src_image_size_h: 256
crop: false
matrix_r0c0: 298
matrix_r0c1: 516
matrix_r0c2: 0
matrix_r1c0: 298
matrix_r1c1: -100
matrix_r1c2: -208
matrix_r2c0: 298
matrix_r2c1: 0
matrix_r2c2: 409
input_bias_0: 16
input_bias_1: 128
input_bias_2: 128
# 归一化系数需要根据用户模型实际需求配置，如下所列常见值仅作为示例
# 归一化系数应用于色域转换和通道交换之后的通道
mean_chn_0: 104
mean_chn_1: 117
mean_chn_2: 123
min_chn_0: 0.0
min_chn_1: 0.0
min_chn_2: 0.0
var_reci_chn_0: 1.0
var_reci_chn_1: 1.0
var_reci_chn_2: 1.0
}
```
