3.15. sample_pipeline 使用说明
3.15.1. 概述
3.15.1.1. 功能简介
sample_pipeline 用于实现1路或多路 sensor pipeline 串联,实现用户常见的 pipeline 场景,用户可在通过 sample_pipeline 子目录了解各个 pipeline 的搭建方法。
3.15.1.2. sample_pipeline架构说明
sample_pipeline 包含多个测试用例,每个测试用例均以子目录形式存在 app/samples/platform_samples/sample_pipeline 下,每个子目录描述如下
| 目录 | 描述 |
|---|---|
| common | 公共操作函数,本章节不做赘述 |
| single_pipe_vin_isp_vse | 1路 sensor 简单 pipeline 串联示例 |
| single_pipe_vin_isp_vse_vpu | 1路 sensor 简单 pipeline 串联并编码示例 |
| single_pipe_vin_isp_gdc | 1路 sensor 实现 GDC 处理示例 |
| multi_pipe_vin_isp_vse | 多路 sensor pipeline 串联并编码示例 |
| multi_pipe_crop_and_stitch | 多路 sensor 裁剪拼接测试用例 |
| multi_pipe_gdc_stitching | 2路 sensor 拼接测试用例 |
| multi_pipe_vin_isp_vse_gpu2d | 2路 sensor pipeline 实现 GPU 旋转画面 |
| sample_custom_capbuf | 测试 VSE / GDC 不同配置下的处理耗时 |
| uvc_gadget_camera | 虚拟 uvc 测试用例 |
| uvc_capture_sample | uvc 摄像头采集用例 |
| mp4_decode_and_display | Mp4 文件通过VPU解码后通过HDMI显示用例 |
3.15.2. single_pipe_vin_isp_vse
3.15.2.1. 功能概述
single_pipe_vin_isp_vse 示例串联MIPI CSI,VIN,ISP,VSE模块,是最基础的视频通路上各模块串联示例之一,用户可根据该示例简单了解 vnode 和 vflow 的创建方法。
Camera Sensor 图像经过 VIN、ISP 处理后到达 VSE 模块,VSE 模块配置了六个输出通道功能分别如下:
0 通道输出ISP处理后的原尺寸图像
1 通道输出16像素对齐的常用算法图像使用的分辨率:512 x 512。
2 通道输出非16像素对齐的常用算法图像使用的分辨率:224 x 224
3 通道输出以原图中心点不变,宽、高各裁剪一半,输出图像宽、高等于ROI区域宽高,输出缩小到支持的最小分辨率:64 x 64。
4 通道输出常用算法图像使用的分辨率:672 x 672。
5 通道输出放大到支持的最大分辨率(注意:图像只能最大放到4倍,仅本通道支持放大):4096 x 3076。
3.15.2.2. 软件架构说明

3.15.2.3. 数据流说明

3.15.2.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse目录结构
single_pipe_vin_isp_vse
├── Makefile
├── single_pipe_vin_isp_vse
└── single_pipe_vin_isp_vse.c
3.15.2.5. API 流程说明

3.15.2.6. 编译部署
编译
进入 single_pipe_vin_isp_vse 目录,执行
make编译输出成果物是 single_pipe_vin_isp_vse 源码目录下的
single_pipe_vin_isp_vse详细程序编译方式请查阅 编译方法 章节
程序部署
把 single_pipe_vin_isp_vse 上传到开发板上之后,运行chmod +x single_pipe_vin_isp_vse命令给程序赋予可执行权限。
3.15.2.7. 运行
程序运行方法
直接执行程序 ./single_pipe_vin_isp_vse 可以获得帮助信息
程序参数选项说明
single_pipe_vin_isp_vse -s/--sensor sensor_index
参数说明
-s: 指定Camera Sensor型号和配置
运行效果
single_pipe_vin_isp_vse 每隔60帧保存一张每个输出通道的 NV12 图至当前运行目录下。
示例: 以 sc230ai 作为 sensor 输入,执行 ./single_pipe_vin_isp_vse -s 3 ,实际请根据当前连接的 sensor 选择对应序号
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x512
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 3840x2160
[ 353.381931] hobot-sif 3d020000.sif: sif frame size incorrect, hsize count:0x780 vsize count:0x0 for inst:0
[ 353.414876] hobot-sif 3d020000.sif: sif frame size incorrect, hsize count:0x780 vsize count:0x438 for inst:0
####################### vse chn 0 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 23 -1 -1
Plane Count: 2
Format: 8
Width: 1920
Height: 1080
Stride: 1920
Vertical Stride: 1080
Is Contiguous: 1
Share IDs: 44 0 0
Flags: 67108881
Sizes: 2073600 1036800 0
Virtual Addresses: 0xffffbd120000 0xffffbd31a400 (nil)
Physical Addresses: 2795712512 2797786112 0
Offsets: 0 0 0
####################### vse chn 1 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 29 -1 -1
Plane Count: 2
Format: 8
Width: 512
Height: 512
Stride: 512
Vertical Stride: 512
Is Contiguous: 1
Share IDs: 50 0 0
Flags: 67108881
Sizes: 262144 131072 0
Virtual Addresses: 0xffffbcad0000 0xffffbcb10000 (nil)
Physical Addresses: 2805063680 2805325824 0
Offsets: 0 0 0
####################### vse chn 2 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 35 -1 -1
Plane Count: 2
Format: 8
Width: 224
Height: 224
Stride: 224
Vertical Stride: 224
Is Contiguous: 1
Share IDs: 56 0 0
Flags: 67108881
Sizes: 50176 25088 0
Virtual Addresses: 0xffffbc9fd000 0xffffbca09400 (nil)
Physical Addresses: 2806255616 2806305792 0
Offsets: 0 0 0
####################### vse chn 3 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 41 -1 -1
Plane Count: 2
Format: 8
Width: 64
Height: 64
Stride: 64
Vertical Stride: 64
Is Contiguous: 1
Share IDs: 62 0 0
Flags: 67108881
Sizes: 4096 2048 0
Virtual Addresses: 0xffffbdfa9000 0xffffbdfaa000 (nil)
Physical Addresses: 2806501376 2806505472 0
Offsets: 0 0 0
####################### vse chn 4 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 47 -1 -1
Plane Count: 2
Format: 8
Width: 672
Height: 672
Stride: 672
Vertical Stride: 672
Is Contiguous: 1
Share IDs: 68 0 0
Flags: 67108881
Sizes: 451584 225792 0
Virtual Addresses: 0xffffbc931000 0xffffbc99f400 (nil)
Physical Addresses: 2806538240 2806989824 0
Offsets: 0 0 0
####################### vse chn 5 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 353357434335
Systimestamps: 353357434418
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 53 -1 -1
Plane Count: 2
Format: 8
Width: 3840
Height: 2160
Stride: 3840
Vertical Stride: 2160
Is Contiguous: 1
Share IDs: 74 0 0
Flags: 67108881
Sizes: 8294400 4147200 0
Virtual Addresses: 0xffffbbc07000 0xffffbc3f0000 (nil)
Physical Addresses: 2808590336 2816884736 0
Offsets: 0 0 0
运行时会保存如下文件:
vse_ch0_0.yuv
vse_ch1_0.yuv
vse_ch2_0.yuv
vse_ch3_0.yuv
vse_ch4_0.yuv
vse_ch5_0.yuv
vse_ch0_60.yuv
vse_ch1_60.yuv
vse_ch2_60.yuv
vse_ch3_60.yuv
vse_ch4_60.yuv
vse_ch5_60.yuv
... ...
3.15.3. single_pipe_vin_isp_vse_vpu
3.15.3.1. 功能概述
single_pipe_vin_isp_vse_vpu 示例串联 MIPI CSI,VIN,ISP,VSE,CODEC 模块,是最基础的模块串联示例之一。Camera Sensor 图像经过 VIN、ISP 处理后到达 VSE 模块,VSE 模块配置了六个输出通道功能分别如下:
0 通道输出ISP处理后的原尺寸图像,本通道的输出数据会再送给编码器编码后保存为H264视频码流。
1 通道输出16像素对齐的常用算法图像使用的分辨率:512 x 512。
2 通道输出非16像素对齐的常用算法图像使用的分辨率:224 x 224
3 通道输出以原图中心点不变,宽、高各裁剪一半,输出图像宽、高等于ROI区域宽高,输出缩小到支持的最小分辨率:64 x 64。
4 通道输出常用算法图像使用的分辨率:672 x 672。
5 通道输出放大到支持的最大分辨率(注意:图像只能最大放到4倍):4096 x 3076。
3.15.3.2. 软件架构说明

3.15.3.3. 数据流说明

3.15.3.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_vpu目录结构
single_pipe_vin_isp_vse_vpu
├── Makefile
├── single_pipe_vin_isp_vse_vpu
└── single_pipe_vin_isp_vse_vpu.c
3.15.3.5. API 流程说明

3.15.3.6. 编译部署
编译
进入 single_pipe_vin_isp_vse_vpu 目录,执行
make编译输出成果物是 single_pipe_vin_isp_vse_vpu 源码目录下的
single_pipe_vin_isp_vse_vpu详细程序编译方式请查阅 编译方法 章节
程序部署
把 single_pipe_vin_isp_vse_vpu 上传到开发板上之后,运行chmod +x single_pipe_vin_isp_vse_vpu命令给程序赋予可执行权限。
3.15.3.7. 运行
程序运行方法
直接执行程序 ./single_pipe_vin_isp_vse_vpu 可以获得帮助信息
程序参数选项说明
single_pipe_vin_isp_vse -s/--sensor sensor_index
参数说明
-s: 指定Camera Sensor型号和配置
运行效果
single_pipe_vin_isp_vse_vpu 每隔60帧保存一张每个输出通道的 NV12 图至当前运行目录下,并保存 VSE 通道0 的 H264 编码文件。
示例: 以 sc230ai 作为 sensor 输入,执行 ./single_pipe_vin_isp_vse_vpu -s 3 ,实际请根据当前连接的 sensor 选择对应序号
日志示例如下所示:
# ./single_pipe_vin_isp_vse_vpu -s 3
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x512
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 3840x2160
[ 34.670395] hobot-sif 3d020000.sif: sif frame size incorrect, hsize count:0x780 vsize count:0x0 for inst:0
[ 34.703353] hobot-sif 3d020000.sif: sif frame size incorrect, hsize count:0x780 vsize count:0x438 for inst:0
Encode idx: 0, init successful
lunch read_vse_data thread
count:0
####################### vse chn 0 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 23 -1 -1
Plane Count: 2
Format: 8
Width: 1920
Height: 1080
Stride: 1920
Vertical Stride: 1080
Is Contiguous: 1
Share IDs: 44 0 0
Flags: 67108881
Sizes: 2073600 1036800 0
Virtual Addresses: 0xffff90d80000 0xffff90f7a400 (nil)
Physical Addresses: 2795712512 2797786112 0
Offsets: 0 0 0
####################### vse chn 1 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 39 -1 -1
Plane Count: 2
Format: 8
Width: 512
Height: 512
Stride: 512
Vertical Stride: 512
Is Contiguous: 1
Share IDs: 60 0 0
Flags: 67108881
Sizes: 262144 131072 0
Virtual Addresses: 0xffff8f858000 0xffff8f898000 (nil)
Physical Addresses: 2820648960 2820911104 0
Offsets: 0 0 0
####################### vse chn 2 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 55 -1 -1
Plane Count: 2
Format: 8
Width: 224
Height: 224
Stride: 224
Vertical Stride: 224
Is Contiguous: 1
Share IDs: 76 0 0
Flags: 67108881
Sizes: 50176 25088 0
Virtual Addresses: 0xffff8f5a5000 0xffff8f5b1400 (nil)
Physical Addresses: 2823827456 2823877632 0
Offsets: 0 0 0
####################### vse chn 3 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 71 -1 -1
Plane Count: 2
Format: 8
Width: 64
Height: 64
Stride: 64
Vertical Stride: 64
Is Contiguous: 1
Share IDs: 92 0 0
Flags: 67108881
Sizes: 4096 2048 0
Virtual Addresses: 0xffff91d95000 0xffff91d96000 (nil)
Physical Addresses: 2824482816 2824486912 0
Offsets: 0 0 0
####################### vse chn 4 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 87 -1 -1
Plane Count: 2
Format: 8
Width: 672
Height: 672
Stride: 672
Vertical Stride: 672
Is Contiguous: 1
Share IDs: 108 0 0
Flags: 67108881
Sizes: 451584 225792 0
Virtual Addresses: 0xffff8f47a000 0xffff8f4e8400 (nil)
Physical Addresses: 2824581120 2825032704 0
Offsets: 0 0 0
####################### vse chn 5 #######################
=== Frame Info ===
Frame ID: 0
Timestamps: 34646123641
Systimestamps: 34646123724
tv: 0.000000
trig_tv: 0.000000
Frame Done: 8
Buffer Index: 0
=== Graphic Buffer ===
File Descriptors: 103 -1 -1
Plane Count: 2
Format: 8
Width: 3840
Height: 2160
Stride: 3840
Vertical Stride: 2160
Is Contiguous: 1
Share IDs: 124 0 0
Flags: 67108881
Sizes: 8294400 4147200 0
Virtual Addresses: 0xffff8e412000 0xffff8ebfb000 (nil)
Physical Addresses: 2830053376 2838347776 0
Offsets: 0 0 0
...
运行时会保存如下文件:
single_pipe_vin_isp_vse_vpu.h264
vse_ch0_0.yuv
vse_ch1_0.yuv
vse_ch2_0.yuv
vse_ch3_0.yuv
vse_ch4_0.yuv
vse_ch5_0.yuv
vse_ch0_60.yuv
vse_ch1_60.yuv
vse_ch2_60.yuv
vse_ch3_60.yuv
vse_ch4_60.yuv
vse_ch5_60.yuv
... ...
3.15.4. single_pipe_vin_isp_gdc
3.15.4.1. 功能概述
single_pipe_vin_isp_gdc 用于演示配置和运行单路视频输入 (VIN) 到图像信号处理 (ISP) 和几何失真校正 (GDC) 的流程。
本示例程序会初始化 Camera Sensor,并且把视频通路打通到 GDC,并且把 ISP 处理后的图像数据给到两个GDC实例进行处理。
3.15.4.2. 软件架构说明

3.15.4.3. 数据流说明

3.15.4.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_gdc目录结构
single_pipe_vin_isp_gdc
├── Makefile
├── single_pipe_vin_isp_gdc
└── single_pipe_vin_isp_gdc.c
3.15.4.5. API 流程说明

3.15.4.6. 编译部署
编译
进入 single_pipe_vin_isp_gdc 目录,执行
make编译输出成果物是 single_pipe_vin_isp_gdc 源码目录下的
single_pipe_vin_isp_gdc详细程序编译方式请查阅 编译方法 章节
程序部署
把 single_pipe_vin_isp_gdc 和 需要使用的 sensor 对应的 GDC BIN 上传到开发板上之后,运行chmod +x single_pipe_vin_isp_gdc命令给程序赋予可执行权限。
3.15.4.7. 运行
程序运行方法
直接执行程序 ./single_pipe_vin_isp_gdc 可以获得帮助信息
程序参数选项说明
Usage: single_pipe_vin_isp_gdc [OPTIONS]
Options:
-s <sensor_index> Specify sensor index
-m <sensor_mode> Specify sensor mode of camera_config_t
-f <gdc_bin_file> Specify sensor gdc_bin_file path
-h Show this help message
-s <sensor_index>指定
Camera Sensor索引。示例:
-s 0表示使用索引为 0 的传感器。
-m <sensor_mode>指定传感器模式 (sensor_mode) 的摄像头配置 (camera_config_t)。
示例:
-m 6表示使用模式 6(Slave),本选项是非所有Sensor都支持,请根据Camera Sensor模组的具体设计进行来使用。
-f <gdc_bin_file>指定 GDC 配置的 bin 文件的路径。
示例:
-f /path/to/gdc.bin表示使用指定路径的 GDC 二进制文件。
-h-显示帮助信息。运行此命令时,将输出以上选项的详细说明。
运行效果
本章节以 sc230ai 为例,演示 single_pipe_vin_isp_gdc 的使用方法
运行命令如下
./single_pipe_vin_isp_gdc -s 3 -f sc230ai_gdc.bin
注意事项
gdc bin文件需要根据每个
Camera Sensor专门调节,本示例代码一般使用vp_sensors/gdc_bin目录下预制好的文件。如果需要新增或者修改 gdc bin 文件,请参考 sample_gdc 示例了解 gdc 的使用。
日志示例如下所示:
./single_pipe_vin_isp_gdc -s 3 -f sc230ai_gdc.bin
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 202, so skip sci1.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@2 i2c bus: 2 mipi rx phy: 2
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x01
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@3 i2c bus: 7 mipi rx phy: 3
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 3, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
*************** Command Lists ***************
g -- get single frame
l -- get a set frames
q -- quit
h -- print help message
Command:
命令解释:
g: 分别从两个gdc的输出通道获取图像,支持输入多个 g 来连续获取图像,例如输入 gggg
Command: g
gdc(165733) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 4612, timestamp: 45479310356561
isp dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5490, timestamp: 45508577025491
gdc(231269) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5490, timestamp: 45508577025491
l: 连续获取12次图像,每次分别从两个gdc的输出通道获取图像,相当于输入12个 g
Command: l
gdc(165733) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 4613, timestamp: 45479343689602
isp dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5522, timestamp: 45509643692158
gdc(231269) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5522, timestamp: 45509643692158
... (省略,总共Dump 12 帧) ...
gdc(165733) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5532, timestamp: 45509977023200
isp dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5533, timestamp: 45510010356909
gdc(231269) dump yuv 1920x1080(stride:1920), buffer size: 2073600 + 1036800 frame id: 5533, timestamp: 45510010356909
q: 退出程序
Command: q
quit
3.15.5. multi_pipe_vin_isp_vse
3.15.5.1. 功能概述
multi_pipe_vin_isp_vse 是一个测试多路视频通路的程序, 完成 MIPI CSI,VIN,ISP,VSE,CODEC 相关模块的硬件初始化和通路串联,从CODEC获取h264编码数据的功能,用户可以参考本程序如何使用HBN API创建多路视频 vflow pipeline。
3.15.5.2. 软件架构说明

3.15.5.3. 数据流说明

3.15.5.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/multi_pipe_vin_isp_vse目录结构
multi_pipe_vin_isp_vse
├── Makefile
├── multi_pipe_vin_isp_vse
└── multi_pipe_vin_isp_vse.c
3.15.5.5. API 流程说明

3.15.5.6. 编译部署
编译
进入 multi_pipe_vin_isp_vse 目录,执行
make编译输出成果物是 multi_pipe_vin_isp_vse 源码目录下的
multi_pipe_vin_isp_vse详细程序编译方式请查阅 编译方法 章节
程序部署
把 multi_pipe_vin_isp_vse 上传到开发板上之后,运行chmod +x multi_pipe_vin_isp_vse命令给程序赋予可执行权限。
3.15.5.7. 运行
程序运行方法
直接执行程序 ./multi_pipe_vin_isp_vse -h 可以获得帮助信息
程序参数选项说明
Options:
-c, --config="sensor=id channel=vse_chn type=TYPE output=FILE"
Configure parameters for each video pipeline, can be repeated up to 4 times.
sensor -- Sensor index,can have multiple parameters, reference sensor list.
mode -- Sensor mode of camera_config_t
channel -- Vse channel index bind to encode, default 0, can be set to [0-5].
type -- Encode type, default is h264, can be set to [h264, h265].
output -- Save codec stream data to file, defaule is 'pipeline[xx]_[width]x[height]_[xxx]fps.[type]'.
-v, --verbose Enable verbose mode
-h, --help Show help message
-c, --config="sensor=id channel=vse_chn type=TYPE output=FILE"配置每一路视频通路的参数。此选项最多可以重复4次以配置最多4路视频通路。
sensor 是必须的参数,channel、type、output是可选参数,用户不配置时,程序会使用默认值。
sensor:传感器索引,必须参数,可以有多个参数,参考传感器列表。channel:VSE 通道索引,可选参数,默认为 0,可以设置为 [0-5]。type:编码类型,可选参数,默认为 h264,可以设置为 [h264, h265]。output:保存编码流数据到文件,可选参数,默认为pipeline[xx]_[width]x[height]_[xxx]fps.[type]。
-v, --verbose启用详细模式。
-h, --help显示帮助信息。
注意: 如果需要调整视频通路的数量,增减 -c 参数集合的数量即可,最大支持4路视频通路
运行效果
本章节以两路视频通路为例,演示 multi_pipe_vin_isp_vse 的使用方法
运行命令如下:
./multi_pipe_vin_isp_vse -c "sensor=2 channel=0 type=h264 output=output0.h264" -c "sensor=11 channel=1 type=h265 output=output1.h265" -v
每一路视频通路配置说明如下:
视频通路0: 配置参数
sensor=2 channel=0 type=h264 output=output0.h264sensor 名称:
sc230ai-10fpsVSE 通道: 0
编码类型: h264
输出文件: output0.h264
视频通路1: 配置参数
sensor=11 channel=1 type=h265 output=output1.h265sensor 名称:
imx415-30fps-2laneVSE 通道: 1
编码类型: h265
输出文件: output1.h265
日志示例如下所示:
# ./multi_pipe_vin_isp_vse -c "sensor=2 channel=0 type=h264 output=output0.h264" -c "sensor=11 channel=1 type=h265 output=output1.h265" -v
Using index:2 sensor_name:sc230ai-10fps config_file:linear_1920x1080_raw10_10fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-10fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_10fps_1lane.c
Using index:11 sensor_name:imx415-30fps-2lane config_file:linear_3840x2160_raw10_30fps_2lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@1 i2c bus: 1 mipi rx phy: 1
WARN: Sensor Name: imx415-30fps-2lane, Expected Chip ID: 0x03, Actual Chip ID Read: 0x00
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@2 i2c bus: 2 mipi rx phy: 2
WARN: Sensor Name: imx415-30fps-2lane, Expected Chip ID: 0x03, Actual Chip ID Read: 0x00
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@3 i2c bus: 7 mipi rx phy: 3
INFO: Found sensor_name:imx415-30fps-2lane on mipi rx csi 3, i2c addr 0x1a, config_file:linear_3840x2160_raw10_30fps_2lane.c
Pipeline index 0:
Sensor index: 2
Sensor name: sc230ai-10fps
Active mipi host: 0
Vse Channel: 0
Encode type: h264
Output file: output0.h264
Pipeline index 1:
Sensor index: 11
Sensor name: imx415-30fps-2lane
Active mipi host: 3
Vse Channel: 1
Encode type: h265
Output file: output1.h265
MIPI host: 0x9
Host 0: Used
Host 3: Used
Verbose: 1
hbn_vnode_set_ochn_attr: 1920x1080
Create Encode idx: 0, init successful
Input width 3840 exceeds maximum width 1920 for channel 1. Adjusting to maximum width.
Input height 2160 exceeds maximum height 1080 for channel 1. Adjusting to maximum height.
hbn_vnode_set_ochn_attr: 1920x1080
Create Encode idx: 1, init successful
Encodec idx: 0 type:0 get stream size:306122
Encodec idx: 0 type:0 get stream size:150586
Encodec idx: 1 type:1 get stream size:8447
Encodec idx: 1 type:1 get stream size:10329
Encodec idx: 0 type:0 get stream size:154342
Encodec idx: 1 type:1 get stream size:10957
Encodec idx: 1 type:1 get stream size:10894
Encodec idx: 1 type:1 get stream size:7949
Encodec idx: 0 type:0 get stream size:111222
Encodec idx: 1 type:1 get stream size:7741
Encodec idx: 1 type:1 get stream size:9076
Encodec idx: 1 type:1 get stream size:8035
Encodec idx: 0 type:0 get stream size:132560
运行后会保存如下编码视频文件:
output0.h264 output1.h265
3.15.6. multi_pipe_gdc_stitching
3.15.6.1. 功能概述
multi_pipe_gdc_stitching 程序从2路相同的分辨率的 sensor 获取图像并进行 gdc 拼接,拼接之后会编码成 h264 视频输出
3.15.6.2. 软件架构说明

3.15.6.3. 数据流说明

3.15.6.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/multi_pipe_gdc_stitching目录结构
multi_pipe_gdc_stitching
├── Makefile
├── multi_pipe_gdc_stitching
└── multi_pipe_gdc_stitching.c
3.15.6.5. API 流程说明

3.15.6.6. 编译部署
编译
进入 multi_pipe_gdc_stitching 目录,执行
make编译输出成果物是 multi_pipe_gdc_stitching 源码目录下的
multi_pipe_gdc_stitching详细程序编译方式请查阅 编译方法 章节
程序部署
把 multi_pipe_gdc_stitching 上传到开发板上之后,运行chmod +x multi_pipe_gdc_stitching命令给程序赋予可执行权限。
3.15.6.7. 运行
程序运行方法
直接执行程序 ./multi_pipe_gdc_stitching 可以获得帮助信息
程序参数选项说明
Usage: multi_pipe_gdc_stitching [Options]
Options:
-c, --config="sensor=id"
Configure parameters for each video pipeline, can be repeated up to 2 times.
sensor -- Sensor index,can have multiple parameters, reference sensor list.
-v, --verbose Enable verbose mode
-h, --help Show help message
-c, --config="sensor=id"配置每一路视频通路的参数,目前只支持配置2路摄像头。
-v, --verbose启用详细模式。
-h, --help显示帮助信息。
注意: 需配置2路相同分辨率的摄像头
运行效果
日志示例如下所示:
# ./multi_pipe_gdc_stitching -c "sensor=3" -c "sensor=3"
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@1 i2c bus: 1 mipi rx phy: 1
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@2 i2c bus: 2 mipi rx phy: 2
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@3 i2c bus: 7 mipi rx phy: 3
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 3, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
total_pipeline_num:2
Pipeline index 0:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 0
Pipeline index 1:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 3
Encode type: h264
Output file: pipeline1_1920x1080_30fps.h264
MIPI host: 0x9
Host 0: Used
Verbose: 0
Create Encode idx: 0, init successful
q
^C[ 145.555162] [VPF ops]:[L153][S2][gdc0] vpf_safety_close: sudden close
[ 145.561818] vin sensor1: sensor_frame_end_stop_wait 488 fe 0ms abort
[ 145.569080] [VPF ops]:[L153][S1][vin3] vpf_safety_close: sudden close
[ 145.577640] [VPF ops]:[L153][S1][isp0] vpf_safety_close: sudden close
[ 145.589144] vin sensor0: sensor_frame_end_stop_wait 509 fe 0ms abort
[ 145.596381] [VPF ops]:[L153][S0][vin0] vpf_safety_close: sudden close
[ 145.604412] [VPF ops]:[L153][S0][isp0] vpf_safety_close: sudden close
...
运行后保存如下编码视频文件:
pipeline1_1920x1080_30fps.h264
3.15.7. multi_pipe_vin_isp_vse_gpu2d
3.15.7.1. 功能概述
multi_pipe_vin_isp_vse_gpu2d 是一个测试多路视频通路的程序, 完成 MIPI CSI,VIN,ISP,VSE,GPU2D 相关模块的硬件初始化和通路串联,程序经过 SIF->ISP->VSE 通路之后并进行 GPU2D 旋转,并将旋转后的图像在当前路径下保存为 bmp 格式图片
3.15.7.2. 软件架构说明

3.15.7.3. 数据流说明

3.15.7.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/multi_pipe_vin_isp_vse_gpu2d目录结构
multi_pipe_vin_isp_vse_gpu2d
├── Makefile
├── create_n2d_buffer_wraper.c
├── create_n2d_buffer_wraper.h
├── multi_pipe_vin_isp_vse_gpu2d
└── multi_pipe_vin_isp_vse_gpu2d.c
3.15.7.5. API 流程说明

3.15.7.6. 编译部署
编译
进入 multi_pipe_vin_isp_vse_gpu2d 目录,执行
make编译输出成果物是 multi_pipe_vin_isp_vse_gpu2d 源码目录下的
multi_pipe_vin_isp_vse_gpu2d详细程序编译方式请查阅 编译方法 章节
程序部署
把 multi_pipe_vin_isp_vse_gpu2d 上传到开发板上之后,运行chmod +x multi_pipe_vin_isp_vse_gpu2d命令给程序赋予可执行权限。
3.15.7.7. 运行
程序运行方法
直接执行程序 ./multi_pipe_vin_isp_vse_gpu2d 可以获得帮助信息
程序参数选项说明
Usage: multi_pipe_vin_isp_vse_gpu2d [Options]
Options:
-c, --config="sensor=id output=FILE"
Configure parameters for each video pipeline, can be repeated up to 4 times.
sensor -- Sensor index,can have multiple parameters, reference sensor list.
output -- Save bmp data to file.
-v, --verbose Enable verbose mode
-y, --enable yuv-debug
-h, --help Show help message
-c, --config="sensor=id channel=vse_chn output=FILE"配置每一路视频通路的参数。此选项最多可以重复4次以配置最多4路视频通路。
sensor 是必须的参数,channel、type、output是可选参数,用户不配置时,程序会使用默认值。
sensor (必选):传感器索引,可以有多个参数,参考传感器列表。output (可选):保存编码流数据到文件,默认命名格式为’output_sensor’id_[width]x[height]_rotated_count.[bmp]’。
-v, --verbose启用详细模式。
-h, --help显示帮助信息。
运行效果
本示例以2路 sc230ai 为例,演示如何使用 multi_pipe_vin_isp_vse_gpu2d
运行以下命令:
./multi_pipe_vin_isp_vse_gpu2d -c "sensor=3" -c "sensor=3"
日志示例如下所示:
root@buildroot:/app/platform_samples/sample_pipeline/multi_pipe_vin_isp_vse_gpu2d# ./multi_pipe_vin_isp_vse_gpu2d -c "sensor=3" -c "sensor=3"
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 0x0202, not need skip sci1.
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@1 i2c bus: 1 mipi rx phy: 1
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@2 i2c bus: 2 mipi rx phy: 2
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 2, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
total_pipeline_num:2
Pipeline index 0:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 0
Vse Channel: 0
Encode type: bmp
Output file:
Pipeline index 1:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 2
Vse Channel: 0
Encode type: bmp
Output file:
MIPI host: 0x5
Host 0: Used
Host 2: Used
Verbose: 0
mipi rx = 0,active_mipi_host = 0
isp_width:1920 , isp_height:1080hbn_vnode_set_ochn_attr: 1920x1080
mipi rx = 2,active_mipi_host = 2
isp_width:1920 , isp_height:1080hbn_vnode_set_ochn_attr: 1920x1080
************ n2d read start*********
Saved file to [./_width:1920_height:1080_stride1920_frameid20.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid5.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid32.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid16.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid43.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid27.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid55.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid39.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid70.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid53.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid78.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid59.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid85.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid66.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid92.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid93.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid118.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid99.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid125.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid106.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid132.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid113.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid139.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid120.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid146.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid127.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid153.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid134.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid160.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid141.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid167.bmp].
Saved file to [./_width:1920_height:1080_stride1920_frameid148.bmp].
encode thread end
运行后将保存如下编码文件
_width:1920_height:1080_stride1920_frameid160.bmp
_width:1920_height:1080_stride1920_frameid167.bmp
3.15.8. multi_pipe_crop_and_stitch
3.15.8.1. 功能概述
multi_pipe_crop_and_stitch 是一个测试多路视频通路的程序,完成 MIPI CSI,VIN,ISP,VSE,2D GPU,CODEC 相关模块的硬件初始化和通路串联. 用户可以参考本程序如何使用HBN API创建多路视频 vflow pipeline, 并结合2D GPU完成抠图、放大、拼接的功能。
详细步骤如下:
2路视频流同时采集通过 VSE 放大到4K
分别从2路视频的左上、右上、左下、右下4个角,扣出640*480大小的图, 共8张
对步骤2得到的8张小图进行放大
把2路原视频图像和8张小图拼接到一张4K的图像中
对拼接后的图像进行H265编码后,保存到文件
output.h265
注意: 目前支持分辨率为: 1920*1080 和 3840*2160 的摄像头
3.15.8.2. 软件架构说明

3.15.8.3. 数据流说明

3.15.8.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/multi_pipe_crop_and_stitch目录结构
multi_pipe_crop_and_stitch
├── Makefile
├── bpu_limit.sh
├── multi_pipe_crop_and_stitch
├── multi_pipe_crop_and_stitch.c
├── param_parser.c
├── param_parser.h
├── qos.sh
├── qos_read.sh
├── run_gdc_yolo_h264_mjpeg.sh
├── run_gdc_yolo_h265.sh
├── run_gdc_yolo_hdmi.sh
└── run_noqos.sh
3.15.8.5. API 流程说明

3.15.8.6. 编译部署
编译
进入 multi_pipe_crop_and_stitch 目录,执行
make编译输出成果物是 multi_pipe_crop_and_stitch 源码目录下的
multi_pipe_crop_and_stitch详细程序编译方式请查阅 编译方法 章节
程序部署
把 multi_pipe_crop_and_stitch 上传到开发板上之后,运行chmod +x multi_pipe_crop_and_stitch命令给程序赋予可执行权限。
3.15.8.7. 运行
程序运行方法
直接执行程序 ./multi_pipe_crop_and_stitch 可以获得帮助信息
程序参数选项说明
Usage: multi_pipe_crop_and_stitch [Options]
Options:
-c, --config="sensor=id "
Configure parameters for each video pipeline, can be repeated up to 4 times.
sensor -- Sensor index,can have multiple parameters, reference sensor list.
gdc -- Enable gdc, default is disable.
out264 -- Enable codec h264 stream, default is disable.
outmjpeg -- Enable codec mjpeg stream, default is disable.
file -- Enable codec stream save as file, default is disable.
-o, --output="file or hdmi, default is nothing output
-r, --ratio="camera image width ratio, used to blend, default is 0.0
-b, --bpu_enable Enable bpu, default is disable
-p, --bpu_postprocess_enable Enable bpu postprocess, default is disable
-v, --verbose Enable verbose mode
-h, --help Show help message
-c, --config="sensor=id"配置每一路视频通路的参数,目前只支持配置2路摄像头,每路 sensor 可单独配置参数如下
sensor:传感器索引,参考传感器列表。gdc:是否开启GDC,默认为 0,可以设置为 [0-1]。out264:是否开启 H264 编码,默认为 0,可以设置为 [0-1]。outmjpeg:是否开启 MJPEG 编码,默认为 0,可以设置为 [0-1]。file:以上编码流是否保存为文件,文件名Chn[通道号].[编码类型]。
-o, --output图像拼接后的输出方式,支持输出方式。
-o file:输出 H265 编码文件,文件名output.h265。-o hdmi:输出 hdmi 显示,目前仅支持 4K 分辨率显示器。
-b, --bpu_enable是否开启算法线程,使用 yolov5 进行人形检测。
-p, --bpu_postprocess_enable是否开启算法后处理。
-v, --verbose是否开启详细打印信息。
-h, --help显示帮助信息。
运行效果
本示例以2路 sc230ai 为例,演示如何使用 multi_pipe_crop_and_stitch 测试用例实现抠图并拼接输出 H265 编码文件
输入测试命令如下
./multi_pipe_crop_and_stitch -c "sensor=3" -c "sensor=3" -o file
日志示例如下所示:
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@1 i2c bus: 1 mipi rx phy: 1
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@2 i2c bus: 2 mipi rx phy: 2
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 2, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
mipi host 2
MIPI host: 0x4
Host 2: Used
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@1 i2c bus: 1 mipi rx phy: 1
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@3 i2c bus: 7 mipi rx phy: 3
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 3, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
mipi host 3
MIPI host: 0xc
Host 2: Used
Host 3: Used
Show sensor info:
Pipeline index 0:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 2
Vse Channel: 5
Pipeline index 1:
Sensor index: 3
Sensor name: sc230ai-30fps
Active mipi host: 3
Vse Channel: 5
hbn_vnode_set_ochn_attr: 3840x2160 fps:30
hbn_vnode_set_ochn_attr: 3840x2160 fps:30
Codec param:
codec type :H265
codec fps :30
codec width :3840
codec height :2160
Create Encode idx: 0, init successful
input q to stop :
运行时会保存如下编码后的视频文件:
output.h265
3.15.9. uvc_gadget_camera
3.15.9.1. 功能概述
uvc_gadget_camera 实现如下功能
采集 MIPI 摄像头的数据,经过如下流程 CSI,VIN,ISP,VSE,CODEC后,通过 USB Gadget 发送给 PC 端显示,目前只支持H264的格式
UAC1 循环播放 PCM 文件,默认使用48K采样率,双通道,16bit
UAC1 录制 PCM 文件,默认使用48K采样率,双通道,16bit
3.15.9.2. 软件架构说明

3.15.9.3. 数据流说明

3.15.9.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/uvc_gadget_camera目录结构
.
├── Makefile
├── alsa_device.c
├── audio
│ └── count10_48K_chn2_s16le.pcm
├── include
│ ├── alsa_device.h
│ ├── uac_common.h
│ ├── uac_gadget.h
│ ├── uac_micphone.h
│ ├── uac_speaker.h
│ ├── utils.h
│ ├── uvc.h
│ ├── uvc_gadget.h
│ └── uvc_gadget_api.h
├── lib
│ └── libguvc.a
├── mqueue.c
├── mqueue.h
├── uac_gadget.c
├── uac_micphone.c
├── uac_speaker.c
├── uvc_gadget_camera
├── uvc_gadget_camera.c
├── uvc_gadget_wraper.c
├── uvc_gadget_wraper.h
├── vp_codec.c
├── vp_codec.h
├── vp_pipeline.h
└── vp_pipeline.c
3.15.9.5. API 流程说明

3.15.9.6. 编译部署
编译
进入 uvc_gadget_camera 目录,执行
make编译输出成果物是 single_pipe_vin_isp_vse_vpu 源码目录下的
uvc_gadget_camera详细程序编译方式请查阅 编译方法 章节
程序部署
把 uvc_gadget_camera 上传到开发板上之后,运行chmod +x uvc_gadget_camera命令给程序赋予可执行权限。
3.15.9.7. 运行
程序运行方法
直接执行程序 ./uvc_gadget_camera 可以获得帮助信息
程序参数选项说明
Usage: get_isp_data [OPTIONS]
Options:
-s <sensor_index> Specify sensor index
-m <sensor_mode> Specify sensor mode of camera_config_t
-p <play PCM file> Specifies the audio playback file path
-r <record PCM file> Specify the audio recording file path
-h Show this help message
-s <sensor_index>指定
Camera Sensor索引。示例:
-s 0表示使用索引为 0 的传感器。
-m <sensor_mode>指定传感器模式 (sensor_mode) 的摄像头配置 (camera_config_t)。
示例:
-m 6表示使用模式 6(Slave),本选项是非所有Sensor都支持,请根据Camera Sensor模组的具体设计进行来使用。
-p <play PCM file>指定要播放的PCM文件路径。
示例:
-p /userdata/play.pcm,默认使用48K采样率,双通道,16bit
-r <record PCM file>指定录制的PCM文件路径,
示例:
-r /userdata/rec.pcm,默认使用48K采样率,双通道,16bit
-h显示帮助信息。运行此命令时,将输出以上选项的详细说明。
运行效果
示例1:测试 UVC:
使用USB数据线连接 开发板和电脑,参考USB 2.0 接口
USB接口开机默认用作 adb 的功能,需要执行如下命令切换为 uvc 设备的功能
/etc/init.d/usb-gadget.sh stop
/etc/init.d/usb-gadget.sh start uvc isoc
出现设备节点
/dev/video0证明切换成功
root@buildroot:~# ls /dev/video0
/dev/video0
启动uvc_gadget_camera
以 sc230ai 为例,使用如下参数命令
./uvc_gadget_camera -s 3
PC 端打开 USB Camera 播放器,比如 PotPlayer, 快捷键
Alt+D打开摄像头配置界面, 选择 UVC Camera, 点击检索更新

PC机端根据摄像头的分辨率和帧率信息选择对应的配置, 并打开摄像头


注意事项
usb-gadget.sh 脚本启动 UVC 后,并不会在 PC 端直接生成 UVC 外设,需要执行
uvc_gadget_camera程序后才生成 UVC 外设。PC 端通过 PotPlayer 程序打开摄像头时,如果格式信息无法选择时,点击
检索更新PC 端通过 PotPlayer 程序打开摄像头时,要根据实际接入的摄像头的参数下发格式信息,如果分辨率和格式错误
uvc_gadget_camera程序会直接退出
示例2:测试UVC + UAC1
/etc/init.d/usb-gadget.sh stop
/etc/init.d/usb-gadget.sh start uvc-uac1 isoc
启动uvc_gadget_camera
以 sc230ai 为例,同时循环播放count10_48K_chn2_s16le.pcm,将PC端音频录制到/userdata/rec.pcm,使用如下参数命令,
cd /app/platform_samples/sample_pipeline/uvc_gadget_camera/
./uvc_gadget_camera -s 3 -p count10_48K_chn2_s16le.pcm -r /userdata/rec.pcm
PC 端设备管理器将新增 UVC 和 UAC 设备

运行结果
执行命令
./uvc_gadget_camera -s 3, 打印如下日志(uvc_gadget_camera等待PC上的客户端发起连接)
./uvc_gadget_camera -s 3
index:3 settle=-1 sensor_mode=0
Using index:3 sensor_name:sc230ai-30fps config_file:linear_1920x1080_raw10_30fps_1lane.c
[INFO] board_id is 202, not need skip sci1.
mipi mclk is configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 4 mipi rx phy: 0
INFO: Found sensor_name:sc230ai-30fps on mipi rx csi 0, i2c addr 0x30, config_file:linear_1920x1080_raw10_30fps_1lane.c
##function uvc_gadget_init in
using uvc device: /dev/video0
###uvc_gadget_init###
using uvc device: /dev/video0
width: 1920
height: 1080
format: 1
io_method: 0
bulk_mode: 0
nbufs: 2
mult: 2
burst: 0
speed: 3
mult_alts: 0
h264_quirk: 0
maxpkt_quirk: 3072
uvc device is dwc3-gadget on bus gadget.0
uvc open succeeded, file descriptor = 4
uvc_size=3, maxpkt_size=3072
##function uvc_gadget_init succeed
##function uvc_gadget_start in
##function uvc_gadget_start succeed
'q' for exit
##function uvc_loop in
PC端发起连接,在摄像头格式信息下发正确的情况下,打印如下日志:
STREAM ON! show video info:
==============================================
fcc: h264(0x34363248)
run_standalone: 1
uvc_devname: /dev/video0
mem: 0xffff9003b2a0
dummy_buf: (nil)
nbufs: 2
width: 1920
height: 1080
bulk: 0
imgsize: 0
imgdata: (nil)
maxpkt: 1024
speed: 3
mult_alts: 0
h264_quirk: 0
maxpkt_quirk: 3072
==============================================
3.15.10. sample_custom_capbuf
3.15.10.1. 功能概述
sample_custom_capbuf 可通过参数选项实现各种 VSE/GDC 搭建场景,用户可根据实际需求调整参数搭建 pipeline,并验证模块处理耗时。
3.15.10.2. 软件架构说明

3.15.10.3. 数据流说明

3.15.10.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/sample_custom_capbuf目录结构
sample_custom_capbuf
├── Makefile
├── feedback_gdc.c
├── feedback_gdc.h
├── feedback_vse.c
├── feedback_vse.h
├── mem_ion.c
├── mem_ion.h
├── run_test.sh
├── sample_custom_capbuf
├── sample_custom_capbuf.c
├── test_res
│ ├── gdc.bin
│ └── test_image_1920x1080.yuv
├── vflow_connection.h
└── vflow_connection.c
3.15.10.5. API 流程说明

3.15.10.6. 编译部署
编译
进入 sample_custom_capbuf 目录,执行
make编译输出成果物是 sample_custom_capbuf 源码目录下的
sample_custom_capbuf详细程序编译方式请查阅 编译方法 章节
程序部署
把 sample_custom_capbuf run_test.sh 和 test_res 目录上传到开发板上之后,运行chmod +x sample_custom_capbuf run_test.sh命令给程序赋予可执行权限。
3.15.10.7. 运行
程序运行方法
sample_custom_capbuf 预置了测试脚本 run_test.sh,用于验证各个场景下的 VSE / GDC 模块耗时。用户可根据实际需求修改 run_test.sh。
直接执行脚本 ./run_test.sh 可以运行本测试用例
程序参数选项说明
Usage: program -e <engine> [OPTIONS]
Options for vse:
-i, --input_file FILE Specify the input file
-w, --input_width WIDTH Specify the input width
-h, --input_height HEIGHT Specify the input height
-V, --verbose Enable verbose mode
Options for gdc:
-c, --config_file FILE Specify the config file
-i, --input_file FILE Specify the input file
-o, --output_file FILE Specify the output file
-w, --input_width WIDTH Specify the input width
-h, --input_height HEIGHT Specify the input height
-x, --output_width WIDTH Specify the output width
-y, --output_height HEIGHT Specify the output height
Options for gdc-0-vse:
-i, --input_file FILE Specify the input file
-w, --input_width WIDTH Specify the input width
-h, --input_height HEIGHT Specify the input height
-V, --verbose Enable verbose mode
-c, --config_file FILE Specify the config file for gdc
-o, --output_file FILE Specify the output file for gdc
-x, --output_width WIDTH Specify the output width for gdc
-y, --output_height HEIGHT Specify the output height for gdc
本用例通过 -e 选项指定要测试的模块类型,支持如下测试模块类型
vse: 表示通过 VSE 缩放一张 NV12 图片gdc: 表示通过 GDC 对一张 NV12 图片做畸变矫正vse-0-gdc: 表示先通过 VSE 通道0缩放,再通过 GDC 做畸变矫正,最后输出 NV12gdc-0-vse: 表示先通过 GDC 做畸变矫正,再通过 VSE 通道0缩放,最后输出 NV12
本 sample 通过脚本 run_test.sh 中的环境变量控制测试选项。各个环境变量说明如下
CAP_LOOP_CNT表示测试循环的次数,
CAP_LOOP_CNT为空则表示仅测试一次
CAP_LOOP_FLAG表示 vnode 操作类型,其支持的值如下
CAP_LOOP_ONLY_FEEDBACK: 其值为0,表示每次循环 vnode 不销毁直接进行回灌CAP_LOOP_FEEDBACK_AND_CREATE: 其值为1,表示每次循环 vnode 需重新创建初始化
CAP_BUF_FLAG表示回灌 VSE / GDC 的输出 buffer 类型
CAP_BUF_CUSTOM: 其值为0,表示通过 hbm 接口申请 buffer 内存
CAP_BUF_CUSTOM_EXT: 其值为1,表示通过 ION 接口申请 buffer 内存CAP_BUF_INTERNAL: 其值为2,表示通过模块内部获得 buffer 内存
CAP_DUMP_FLAG表示是否保存输出 yuv 图像
对于 VSE 模块,其默认输出目录
/userdata/vse对于 GDC 模块,其默认输出目录
/userdata/gdc
CAP_THREAD_NUM表示创建的线程数量,用于对模块并发操作,
CAP_THREAD_NUM为空则表示仅创建一个测试线程
注意事项
只支持 VSE,GDC 和 GDC 绑定 VSE 的回灌模式。
用户自定义的输出 buffer,需Y和UV地址空间要连续,需使用 ION 空间,需填充必要 bufferindex 和 share_id。
运行效果
执行./run_test.sh
...
==== feedback_thread_vse buf flag CAP_BUF_CUSTOM loop 100 time cost 1263.837 ms
==== feedback_thread_gdc buf flag CAP_BUF_CUSTOM loop 100 time cost 895.005 ms
==== feedback_thread_vse buf flag CAP_BUF_INTERNAL loop 100 time cost 1640.084 ms
==== feedback_thread_gdc buf flag CAP_BUF_INTERNAL loop 100 time cost 966.076 ms
...
3.15.11. uvc_capture_sample
3.15.11.1. 功能概述
uvc_capture_sample 是一个测试 uvc camera 视频采集通路的程序, 完成 uvc camera 的图像采集并保存输出的图片,支持显示 ISP 相关信息。
3.15.11.2. 软件架构说明

3.15.11.3. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/uvc_capture_sample目录结构
uvc_capture_sample
├── Makefile
├── common_utils.c
├── common_utils.h
├── uvc_capture_sample.c
├── uvc_capture_sample.h
├── v4l2_common_utils.c
└── v4l2_common_utils.h
3.15.11.4. API 流程说明

3.15.11.5. 编译部署
编译
进入 uvc_capture_sample 目录,执行
make编译输出成果物是 uvc_capture_sample 源码目录下的
uvc_capture_sample详细程序编译方式请查阅 编译方法 章节
程序部署
把 uvc_capture_sample 目录上传到开发板上之后,运行chmod +x uvc_capture_sample命令给程序赋予可执行权限。
3.15.11.6. 运行
程序运行方法
运行前需要连接 uvc 摄像头到 开发板的 USB HOST 接口
直接执行程序 ./uvc_capture_sample -h 可以获得帮助信息
程序参数选项说明
选项:
-i, --video_id <id>指定对应的 video 的节点,比如 video0、video1等。
系统中的 /dev/videoX 节点用途可能不同,可通过以下命令查看支持格式和功能:
v4l2-ctl --device=/dev/videoX --list-formats-ext
-d, --dump_file是否保存图像文件。启用此选项会将捕获的图像保存为文件。
-F, --format设置图像格式,如 YUYV、NV12 等,需与实际 UVC Camera 所支持格式一致。
-l, --loop_cnt <num>设置采集循环的次数(即捕获多少帧图像)。
-H, --height <px>设置图像的高度(单位为像素)。
-W, --width <px>设置图像的宽度(单位为像素)。
-E, --isp_info显示 ISP exposure 和 white balance 信息。
-H, --help显示帮助信息。
示例:
配置一条 uvc camera 视频通路,使用video0,指定格式 YUYV,保存 5 帧采集到的图像。
./uvc_capture_sample -i 0 -l 5 -W 1920 -H 1080 -F YUYV -d
配置一条 uvc camera 视频通路,使用video0,指定格式 YUYV,保存 5 帧采集到的图像,并打印当前的 exposure 和 white balance 信息。
./uvc_capture_sample -i 0 -l 5 -W 1920 -H 1080 -F YUYV -d -E
运行效果
运行以下命令:
./uvc_capture_sample -i 0 -l 5 -W 1920 -H 1080 -F YUYV -d
日志示例如下所示:
ptc[0].video_id = 0
ptc[0].loop_cnt = 5
ptc[0].pic_width = 1920
ptc[0].pic_height = 1080
ptc[0].pic_format = 6
ptc[0].dump_mask = 1
DEBUG: index = 0, max_num = 24
pipe_num:0
TestContext[0] create pthread success
loop_cnt: 5
open device: /dev/video0 (fd=3)
driver: uvcvideo
card: FHD Camera Microphone: FHD Came
version: 6.1.83
all caps: 84a00001
device caps: 04200001
0: Motion-JPEG 0x47504a4d 0x1
...
filedump(/userdata/yuv_dump/isp_5_s0_c0_b1_f0_005838.yuv, size(4147200) is successed
loop cnt use up
pipe(0)Test thread 281473524101408---join done.
------ Test case uvc_capture_sample done ------
3.15.12. mp4_decode_and_display
3.15.12.1. 功能概述
mp4_decode_and_display 示例通过 ffmpeg 库解析 MP4 文件中的 H264 或 H265 的裸码流,并送入 VPU 中进行解码,然后交给 HDMI 显示器显示。
并且程序运行后支持指定播放位置:程序执行后,可以通过命令行指定当前播放的位置
注意:
必须接入 HDMI 显示器,并且 HDMI 显示器要支持 MP4 中视频文件的分辨率
由于解码器只能从关键帧开始解码,所以当指定的位置不是关键帧时,会从指定位置附近选择合适的位置开始播放
3.15.12.2. 软件架构说明

3.15.12.3. 数据流说明

3.15.12.4. 代码位置及目录结构
代码位置
app/samples/platform_samples/sample_pipeline/mp4_decode_and_display目录结构
mp4_decode_and_display
.
├── Makefile
├── codec_helper.c
├── codec_helper.h
├── mp4_decode_and_display.c
├── uthash.h
├── vp_codec.c
├── vp_codec.h
├── vp_display.c
└── vp_display.h
3.15.12.5. API 流程说明


3.15.12.6. 编译部署
编译
进入 mp4_decode_and_display 目录,执行
make编译输出成果物是 mp4_decode_and_display 源码目录下的
mp4_decode_and_display详细程序编译方式请查阅 编译方法 章节
程序部署
把 mp4_decode_and_display 上传到开发板上之后,运行chmod +x mp4_decode_and_display命令给程序赋予可执行权限。
3.15.12.7. 运行
运行前需要准备如下:
MP4 格式的视频文件
HDMI 显示屏幕,并且显示屏幕要支持 MP4 视频文件中视频的分辨率
程序运行方法
直接执行程序 ./mp4_decode_and_display 可以获得帮助信息
程序参数选项说明
./mp4_decode_and_display
Usage: ./mp4_decode_and_display <input_mp4_file>
Example: ./mp4_decode_and_display input.mp4
参数说明
input_mp4_file: 指定 MP4 文件
运行效果
mp4_decode_and_display 执行效果如下:
HDMI 显示屏中会显示 MP4 视频文件中的视频
从最近指定的播放位置,开始保存 H264 或 H265 的裸码流到文件 output.h264 或 output.h265
命令行输入数字可以指定播放的位置
输入 q 或 quit 退出程序或者文件播放完毕后输入回车也会退出程序
./mp4_decode_and_display ./20250829-172933.mp4
[MP4_PLAYER]Printf video info:
[MP4_PLAYER] Input file: ./20250829-172933.mp4
[MP4_PLAYER] Output file:
[MP4_PLAYER] Codec: h264
[MP4_PLAYER] Duration: 136 seconds
[MP4_PLAYER] Total frames: 3146
[MP4_PLAYER] Video FPS: 23.00 or TotalFrames/Duration: 23.13
[MP4_PLAYER] Codec: H264
[MP4_PLAYER] Resolution: 1920x1080
[MP4_PLAYER] hdmi is connected.
[Decoder] Decode idx: 0, init successful
[MP4_PLAYER] Init video decode instance 0 successful
[Decoder] Decode idx: 0, start successful
[MP4_PLAYER] Parser thread start.
[MP4_PLAYER] MP4 decoder started. Enter seek position in seconds (or 'q' to quit):
[MP4_PLAYER] Example: 30 (seek to 30 seconds)[MP4_PLAYER] Seek to (seconds):
[MP4_PLAYER] Player thread start.
[MP4_PLAYER] playback progress: 0/136 s
[MP4_PLAYER] playback progress: 1/136 s
[MP4_PLAYER] playback progress: 2/136 s
[MP4_PLAYER] playback progress: 3/136 s
[MP4_PLAYER] playback progress: 4/136 s
[MP4_PLAYER] playback progress: 5/136 s
q
[MP4_PLAYER] Quitting...
[MP4_PLAYER] Parse thread finished
[MP4_PLAYER] Player thread finished
DRM resources cleaned up.
[MP4_PLAYER] MP4 decoder stopped