3.15. sample_pipeline 使用说明

3.15.1. 概述

3.15.1.1. 功能简介

sample_pipeline 用于实现1路多路 sensor pipeline 串联,实现用户常见的 pipeline 场景,用户通过 sample_pipeline 子目录了解各个 pipeline 的搭建方法。

注意:本产品支持多路 DOL2 的场景。当接入 HDR Sensor 时,VIN 和 ISP 的连接方式只能选择 online,由于 online 模式独占 ISP 资源,所以支持 1 路。

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 处理示例
single_pipe_vin_isp_vse_gdc 1路 sensor 经 VSE 后 bind GDC 动态切换 binbuf 示例
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显示用例
single_pipe_vin_isp_vse_vo 用于验证单路视频采集显示功能测试示例程序
single_pipe_vin_isp_vse_gpu2d 测试单路视频通路示例程序
single_format_convert_gpu2d 验证使用 2D GPU 进行图片格式转换测试示例程序
single_pipe_vin_isp_vse_multi_process 进程通信示例程序
single_pipe_vin_isp_vse_bpu Sensor 图像数据到 BPU 的算法推理通路示例

3.15.2. single_pipe_vin_isp_vse

3.15.2.1. 功能概述

single_pipe_vin_isp_vse 示例串联MIPI CSIVINISPVSE模块,是基础视频通路模块串联示例之一,用户根据示例简单了解 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。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.2.2. 编译部署

编译

  • 进入 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.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_vse 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message

参数说明

  • -s: 指定 Camera Sensor 型号配置

  • -c: 指定 VIN 和 ISP 之间,以及 ISP 和 VSE 之间连接方式,分别支持 Offline 和 Online 的连接方式

运行效果

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
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

Connection method from VIN to ISP: vin offline isp
Connection method from VIN to ISP: isp offline vse.

hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x480
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 480x480
hbn_vnode_set_ochn_attr: 5, 3840x2160
####################### 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 CSIVINISPVSECODEC 模块,是基础模块串联示例之一。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。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.3.2. 编译部署

编译

  • 进入 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.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_vse_vpu 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse_vpu [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse

参数说明

  • -s: 指定 Camera Sensor 型号配置

  • -c: 指定 VIN 和 ISP 之间,以及 ISP 和 VSE 之间连接方式,分别支持 Offline 和 Online 的连接方式

运行效果

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
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

Connection method from VIN to ISP: vin offline isp
Connection method from VIN to ISP: isp offline vse.

hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x480
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 480x480
hbn_vnode_set_ochn_attr: 5, 3840x2160
Encode idx: 0, init successful
lunch read_vse_data thread
ping pang file saver failed
Error writing y to file
####################### vse chn 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实例进行处理。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.4.2. 编译部署

编译

  • 进入 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.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_gdc 可以获得帮助信息

程序参数选项说明

Usage: single_pipe_vin_isp_gdc [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf
                                        1. vo: vin online isp
                                        2. vf: vin offline isp
                                        3. default is vf
  -f <gdc_bin_file>      Specify sensor gdc_bin_file path
  -h                     Show this help message
  • -s <sensor_index>

    • 指定 Camera Sensor 索引。

    • 示例:-s 0 表示使用索引为 0 的传感器。

  • -c:

    • 指定 VIN 和 ISP 之间连接方式,支持 Offline 和 Online 两种连接方式

    • 示例: -c vo 表示 VIN online ISP

  • -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. single_pipe_vin_isp_vse_gdc

3.15.5.1. 功能概述

single_pipe_vin_isp_vse_gdc 用于演示单路视频通路VINISPVSEGDC串联方式,以及动态切换 GDC binbuf场景。

示例支持如下链路配置:

  • VIN -> ISP:支持 online / offline

  • ISP -> VSE:支持 online / offline

  • VSE -> GDC:仅支持 offline(VSE 输出 DDR)

GDC 侧,示例使用 AFFINE 模式根据输入 ROI 预生成加载 4 组 binbuf(左上、右上、左下、右象限配置),运行过程动态切换 binbuf,并连续抓取 4 张 GDC 输出图像保存当前目录。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_gdc

  • 目录结构

single_pipe_vin_isp_vse_gdc
├── Makefile
├── single_pipe_vin_isp_vse_gdc
└── single_pipe_vin_isp_vse_gdc.c

API 流程说明

api_flow.png

3.15.5.2. 编译部署

编译

  • 进入 single_pipe_vin_isp_vse_gdc 目录,执行 make 编译

  • 输出成果物是 single_pipe_vin_isp_vse_gdc 源码目录single_pipe_vin_isp_vse_gdc

  • 详细程序编译方式查阅 编译方法 章节

程序部署

single_pipe_vin_isp_vse_gdc传到开发板之后,运行 chmod +x single_pipe_vin_isp_vse_gdc 命令程序赋予执行权限。

3.15.5.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_vse_gdc 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse_gdc [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message

参数说明

  • -s:指定 Camera Sensor 型号配置

  • -c:指定 VIN->ISPISP->VSE连接方式(online/offline)

  • -h:打印帮助信息

运行效果

示例运行依次切换 4 组 GDC binbuf 配置,并保存 4 张输出图像,文件名示例如下:

gdc_quad0_1920x1080_stride_1920.yuv
gdc_quad1_1920x1080_stride_1920.yuv
gdc_quad2_1920x1080_stride_1920.yuv
gdc_quad3_1920x1080_stride_1920.yuv

章节以 sc230ai 为例,演示 single_pipe_vin_isp_vse_gdc使用方法

运行命令如下:

./single_pipe_vin_isp_vse_gdc -s 3 -c vf:if

图像效果如下:

out_put_pic.png

注意事项

  • 多个不同的 binbuf 就占用多块 ION内存,相同的 binbuf 只会复用一块ion内存。

3.15.6. multi_pipe_vin_isp_vse

3.15.6.1. 功能概述

multi_pipe_vin_isp_vse 一个测试多路视频通路程序, 完成 MIPI CSIVINISPVSECODEC 相关模块硬件初始化通路串联,从CODEC获取h264编码数据功能,用户可以参考程序如何使用HBN API创建多路视频 vflow pipeline。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.6.2. 编译部署

编译

  • 进入 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.6.3. 运行

程序运行方法

直接执行程序 ./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.h264

    • sensor 名称: sc230ai-10fps

    • VSE 通道: 0

    • 编码类型: h264

    • 输出文件: output0.h264

  • 视频通路1: 配置参数 sensor=11 channel=1 type=h265 output=output1.h265

    • sensor 名称: imx415-30fps-2lane

    • VSE 通道: 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.7. multi_pipe_gdc_stitching

3.15.7.1. 功能概述

multi_pipe_gdc_stitching 程序从2路相同分辨率的 sensor 获取图像进行 gdc 拼接,拼接之后编码成 h264 视频输出

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/multi_pipe_gdc_stitching

  • 目录结构

multi_pipe_gdc_stitching
├── Makefile
├── multi_pipe_gdc_stitching
└── multi_pipe_gdc_stitching.c

API 流程说明

api_flow.png

3.15.7.2. 编译部署

编译

  • 进入 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.7.3. 运行

程序运行方法

直接执行程序 ./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.8. multi_pipe_vin_isp_vse_gpu2d

3.15.8.1. 功能概述

multi_pipe_vin_isp_vse_gpu2d 一个测试多路视频通路程序, 完成 MIPI CSIVINISPVSEGPU2D 相关模块硬件初始化通路串联,程序经过 SIF->ISP->VSE 通路之后进行 GPU2D 旋转,并旋转图像当前路径保存为 bmp 格式图片

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.8.2. 编译部署

编译

  • 进入 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.8.3. 运行

程序运行方法

直接执行程序 ./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.9. multi_pipe_crop_and_stitch

3.15.9.1. 功能概述

multi_pipe_crop_and_stitch 一个测试多路视频通路程序,完成 MIPI CSIVINISPVSE2D GPUCODEC 相关模块硬件初始化通路串联. 用户可以参考程序如何使用HBN API创建多路视频 vflow pipeline, 并结合2D GPU完成图、放大、拼接功能。

详细步骤如下:

  1. 2路视频流同时采集通过 VSE 放大到4K

  2. 分别从2路视频上、右上、左下、右下4个角,扣出640*480大小图, 共8张

  3. 步骤2得到的8张小图进行放大

  4. 把2路原视频图像和8张小图拼接一张4K的图像

  5. 拼接图像进行H265编码后,保存文件 output.h265

注意: 目前支持分辨率为: 1920*10803840*2160摄像头

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.9.2. 编译部署

编译

  • 进入 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.9.3. 运行

程序运行方法

直接执行程序 ./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.10. uvc_gadget_camera

3.15.10.1. 功能概述

uvc_gadget_camera 实现如下功能

  • 采集 MIPI 摄像头数据,经过如下流程 CSI,VIN,ISP,VSE,CODEC后,通过 USB Gadget 发送给 PC 端显示,目前支持H264的格式

  • UAC1 循环播放 PCM 文件,默认使用48K采样率,双通道,16bit

  • UAC1 录制 PCM 文件,默认使用48K采样率,双通道,16bit

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.10.2. 编译部署

编译

  • 进入 uvc_gadget_camera 目录,执行make编译

  • 输出成果物是 single_pipe_vin_isp_vse_vpu 源码目录uvc_gadget_camera

  • 详细程序编译方式查阅 编译方法 章节

程序部署

uvc_gadget_camera传到开发板之后,运行chmod +x uvc_gadget_camera命令程序赋予执行权限。

3.15.10.3. 运行

程序运行方法

直接执行程序 ./uvc_gadget_camera 可以获得帮助信息

程序参数选项说明

Usage: ./uvc_gadget_camera [OPTIONS]
Options:
  -s <sensor_index>      Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -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 的传感器。

  • -c <channel_type>:

    • 指定 VIN 和 ISP 之间,以及 ISP 和 VSE 之间连接方式,分别支持 Offline 和 Online 的连接方式

    • 示例: -c vo:io 表示 VIN Online ISP, ISP Online VSE

  • -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, 点击 检索更新

image-20220307220126767

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

image-20220307220126767

image-20220307220126767

注意事项

  • 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 设备

image-20241028220126767

运行结果

  • 执行命令 ./uvc_gadget_camera -s 3, 打印如下日志(uvc_gadget_camera等待PC上客户端发起连接)

 ./uvc_gadget_camera -s 3
Using index:3  sensor_name:sc230ai-30fps  config_file:linear_1920x1080_raw10_30fps_1lane.c
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

Connection method from VIN to ISP: vin offline isp
Connection method from VIN to ISP: isp offline vse.
##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.11. sample_custom_capbuf

3.15.11.1. 功能概述

sample_custom_capbuf通过参数选项实现各种 VSE/GDC 搭建场景,用户根据实际需求调整参数搭建 pipeline,并验证模块处理耗时。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.11.2. 编译部署

编译

  • 进入 sample_custom_capbuf 目录,执行make编译

  • 输出成果物是 sample_custom_capbuf 源码目录sample_custom_capbuf

  • 详细程序编译方式查阅 编译方法 章节

程序部署

sample_custom_capbuf run_test.shtest_res 目录传到开发板之后,运行chmod +x sample_custom_capbuf run_test.sh命令程序赋予执行权限。

3.15.11.3. 运行

程序运行方法

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 做畸变矫正,最后输出 NV12

  • gdc-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.12. uvc_capture_sample

3.15.12.1. 功能概述

uvc_capture_sample 一个测试 uvc camera 视频采集通路程序, 完成 uvc camera 的图像采集保存输出图片,支持显示 ISP 相关信息。

软件架构说明

software_arch.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow.png

3.15.12.2. 编译部署

编译

  • 进入 uvc_capture_sample 目录,执行make编译

  • 输出成果物是 uvc_capture_sample 源码目录uvc_capture_sample

  • 详细程序编译方式查阅 编译方法 章节

程序部署

uvc_capture_sample 目录传到开发板之后,运行chmod +x uvc_capture_sample命令程序赋予执行权限。

3.15.12.3. 运行

程序运行方法

运行需要连接 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.13. mp4_decode_and_display

3.15.13.1. 功能概述

mp4_decode_and_display 示例通过 ffmpeg 库解析 MP4 文件的 H264 或 H265 的裸码流,并送入 VPU 中进行解码,然后交给 HDMI 显示器显示。

并且程序运行支持指定播放位置:程序执行后,可以通过命令行指定当前播放位置

注意:

  1. 必须接入 HDMI 显示器,并且 HDMI 显示器支持 MP4 中视频文件分辨率

  2. 由于解码器只能关键帧开始解码,所以指定位置不是关键帧时,会指定位置附近选择合适位置开始播放

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 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

API 流程说明

api_flow_main.png

api_flow_thread.png

3.15.13.2. 编译部署

编译

  • 进入 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.13.3. 运行

运行需要准备如下:

  1. MP4 格式视频文件

  2. 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 执行效果如下:

  1. HDMI 显示屏显示 MP4 视频文件视频

  2. 最近指定播放位置,开始保存 H264 或 H265 的裸码文件 output.h264 或 output.h265

  3. 命令行输入数字可以指定播放位置

  4. 输入 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

3.15.14. single_pipe_vin_isp_vse_gpu2d

3.15.14.1. 功能概述

single_pipe_vin_isp_vse_gpu2d 一个测试单路视频通路示例程序,演示Sensor VIN ISP VSE GPU2D完整视频处理链路。

程序核心功能是:

  • 经 VIN、ISP、VSE 模块完成信号处理;

  • 使用 GPU2D 模块执行 图像裁剪(Crop)与缩放;

  • 最终通过队列处理将 NV12 图像保存为 .yuv 文件。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_gpu2d

  • 目录结构

single_pipe_vin_isp_vse_gpu2d
├── Makefile
├── single_pipe_vin_isp_vse_gpu2d
└── single_pipe_vin_isp_vse_gpu2d.c

API 流程说明

api_flow.png

3.15.14.2. 编译部署

编译

  • 进入 single_pipe_vin_isp_vse_gpu2d 目录,执行make编译

  • 输出成果物是 single_pipe_vin_isp_vse_gpu2d 源码目录single_pipe_vin_isp_vse_gpu2d

  • 详细程序编译方式查阅 编译方法 章节

程序部署

single_pipe_vin_isp_vse_gpu2d传到开发板之后,运行chmod +x single_pipe_vin_isp_vse_gpu2d命令程序赋予执行权限。

3.15.14.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_vse_gpu2d 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse_gpu2d [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -v                            Enable verbose mode
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message
  • -s <sensor_index>

    • 传感器索引(必选):整数类型,对应 vp_show_sensors_list() 打印出来的 sensor 列表。

  • -c <channel_type>

    • 指定 VIN/ISP/VSE 的在线/离线组合方式,默认 vf:if

    • 支持单独配置:vo / vf / io / if

    • 支持组合配置:vo:io / vo:if / vf:io / vf:if

  • -v

    • 打开 verbose 模式,会打印相关日志。

  • -h

    • 显示帮助信息退出。

运行效果

示例以1路 imx219 为例,演示如何使用 single_pipe_vin_isp_vse_gpu2d

运行以下命令:

./single_pipe_vin_isp_vse_gpu2d -s 30

日志示例如下所示:

root@buildroot:/userdata/app_test# ./single_pipe_vin_isp_vse_gpu2d -s 30
Verbose: 0
Using index:30  sensor_name:imx219-1920x1080-30fps  config_file:linear_1920x1080_raw10_30fps_2lane.c
[INFO] RDK board_id is 0x0503, so skip csi test for index 1 and index 3
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 6 mipi rx phy: 0
INFO: Found sensor_name:imx219-1920x1080-30fps on mipi rx csi 0, i2c addr 0x10, config_file:linear_1920x1080_raw10_30fps_2lane.c
        Sensor name: imx219-1920x1080-30fps
        Active mipi host: 0
Connection method from VIN to ISP: vin offline isp
Connection method from VIN to ISP: isp offline vse.

csi0 ignore mclk ex attr, because not config mclk.
hbn_vnode_set_ochn_attr: 1920x1080
GPU2D input  1920x1080 stride=1920
GPU2D output 1920x1080 stride=1920
pthread_create
Running... Press Ctrl+C to exit
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid0_ts_6076777994522.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid3_ts_6076876729480.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid6_ts_6076975461272.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid9_ts_6077074194939.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid12_ts_6077172930814.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid15_ts_6077271669189.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid18_ts_6077370402606.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid21_ts_6077469136064.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid24_ts_6077567869564.yuv ok
Saved frame to ./imx219-1920x1080-30fps_1920x1080_frameid27_ts_6077666604439.yuv ok
^CSaved frame to ./imx219-1920x1080-30fps_1920x1080_frameid30_ts_6077765336439.yuv ok
pthread_join success
...

运行保存如下nv12类型的yuv文件

ls -alh
drwxr-xr-x  2 root root  36K Jan  1 06:29 .
drwxr-xr-x 16 root root 4.0K Jan  1 01:13 ..
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid0_ts_6076777994522.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid12_ts_6077172930814.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid15_ts_6077271669189.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid18_ts_6077370402606.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid21_ts_6077469136064.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid24_ts_6077567869564.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid27_ts_6077666604439.yuv
-rw-r--r--  1 root root 3.0M Jan  1 06:29 imx219-1920x1080-30fps_1920x1080_frameid30_ts_6077765336439.yuv

3.15.15. single_pipe_vin_isp_vse_vo

3.15.15.1. 功能概述

single_pipe_vin_isp_vse_vo 一个用于验证单路视频采集显示功能测试示例程序,演示Sensor VIN ISP VSE HDMI 显示 的完整视频数据流处理链路。

程序核心功能是:

  • 经 VIN、ISP、VSE 模块完成信号处理;

  • 使用 DRM 接口 (vp_display) 在 HDMI 上实时显示图像;

  • 自动匹配显示设备支持分辨率;若当前分辨率支持列表中,程序尝试查找接近可用分辨率;若无法匹配,则终止运行提示错误信息。

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_vo

  • 目录结构

single_pipe_vin_isp_vse_vo
├── Makefile
├── single_pipe_vin_isp_vse_vo
└── single_pipe_vin_isp_vse_vo.c

API 流程说明

api_flow.png

3.15.15.2. 编译部署

编译

  • 进入 single_pipe_vin_isp_vse_vo 目录,执行make编译

  • 输出成果物是 single_pipe_vin_isp_vse_vo 源码目录single_pipe_vin_isp_vse_vo

  • 详细程序编译方式查阅 编译方法 章节

程序部署

single_pipe_vin_isp_vse_vo传到开发板之后,运行chmod +x single_pipe_vin_isp_vse_vo命令程序赋予执行权限。

3.15.15.3. 运行

程序运行方法

运行程序前,请确保正确连接显示设备: 将显示屏的 HDMI 线缆 接入 X5 板卡的 HDMI 输出接口。 随后,需手动加载相关驱动模块初始化显示子系统。

modprobe panel-jc-050hd134
modprobe galcore
modprobe vio_n2d
modprobe lontium_lt8618
modprobe vs-x5-syscon-bridge
modprobe vs_drm

直接执行程序 ./single_pipe_vin_isp_vse_vo 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse_vo [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message
  • -s --sensor <sensor_index>

    • sensor (必选):传感器索引,整数类型,对应系统传感器列表。

  • -c <channel_type>

    • channel_type (可选):指定 VIN 和 ISP 之间,以及 ISP 和 VSE 之间连接方式,分别支持 Offline 和 Online 的连接方式

  • -h, --help

    • 显示帮助信息。

运行效果

示例以1路 sc230ai 为例,演示如何使用 single_pipe_vin_isp_vse_vo

运行以下命令:

./single_pipe_vin_isp_vse_vo -s 3

日志示例如下所示:

Using index:3  sensor_name:sc230ai-30fps  config_file:linear_1920x1080_raw10_30fps_1lane.c
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: 1920x1080
[   59.491765] hobot-sif 3d020000.sif: sif frame size incorrect, hsize count:0x0 vsize count:0x438 for inst:0
Checking resolutions:
Mode 0: 2560x1440 @ 60Hz
Mode 1: 3840x2160 @ 30Hz
Mode 2: 3840x2160 @ 30Hz
Mode 3: 3840x2160 @ 25Hz
Mode 4: 3840x2160 @ 24Hz
Mode 5: 3840x2160 @ 24Hz
Mode 6: 2560x1440 @ 100Hz
Mode 7: 2560x1440 @ 75Hz
Mode 8: 1920x1080 @ 60Hz
hdmi support resolution 1920*1080
------------------------------------------------------
Plane 0:
  Plane ID: 64
  Src W: 1920
  Src H: 1080
  CRTC X: 0
  CRTC Y: 0
  CRTC W: 1920
  CRTC H: 1080
  Format: NV12
  Z Pos: -1
  Alpha: -1
  Pixel Blend Mode: -1
  Rotation: -1
  Color Encoding: -1
  Color Range: -1
------------------------------------------------------
Setting up KMS...
Checking mode 2560x1440@60.00Hz
Checking mode 3840x2160@30.00Hz
Checking mode 3840x2160@29.97Hz
Checking mode 3840x2160@25.00Hz
Checking mode 3840x2160@24.00Hz
Checking mode 3840x2160@23.98Hz
Checking mode 2560x1440@100.00Hz
Checking mode 2560x1440@75.00Hz
Checking mode 1920x1080@60.00Hz
Found resolution match: 1920x1080@60.00Hz
Checking mode 1920x1080@60.00Hz
Checking mode 1920x1080@59.94Hz
Checking mode 1920x1080@60.00Hz
Checking mode 1920x1080@59.94Hz
Checking mode 1920x1080@50.00Hz
Checking mode 1920x1080@50.00Hz
Checking mode 1280x1440@59.91Hz
Checking mode 1680x1050@59.88Hz
Checking mode 1280x1024@75.02Hz
Checking mode 1280x1024@60.02Hz
Checking mode 1440x900@59.90Hz
Checking mode 1280x720@60.00Hz
Checking mode 1280x720@60.00Hz
Checking mode 1280x720@59.94Hz
Checking mode 1280x720@50.00Hz
Checking mode 1024x768@75.03Hz
Checking mode 1024x768@70.07Hz
Checking mode 1024x768@60.00Hz
Checking mode 832x624@74.55Hz
Checking mode 800x600@75.00Hz
Checking mode 800x600@72.19Hz
Checking mode 800x600@60.32Hz
Checking mode 800x600@56.25Hz
Checking mode 720x576@50.00Hz
Checking mode 720x576@50.00Hz
Checking mode 720x480@60.00Hz
Checking mode 720x480@60.00Hz
Checking mode 720x480@59.94Hz
Checking mode 720x480@59.94Hz
Checking mode 640x480@75.00Hz
Checking mode 640x480@72.81Hz
Checking mode 640x480@66.67Hz
Checking mode 640x480@60.00Hz
Checking mode 640x480@59.94Hz
Checking mode 640x480@59.94Hz
Checking mode 720x400@70.08Hz
Using resolution-matched mode: 1920x1080@60.00Hz
vp_display_init ok: 1920x1080 -> 1920x1080
...

程序运行后,显示屏实时显示来自传感器图像内容。

3.15.16. single_format_convert_gpu2d

3.15.16.1. 功能概述

single_format_convert_gpu2d 一个用于验证使用2D GPU进行图片格式转换测试示例程序,演示了nv12转bmp、nv12转yuv422、yuv422转bmp以及yuv422转nv12。

程序核心功能是:

  • 读取需要转换图片文件;

  • 创建一个2D GPU node,并创建启动vflow;

  • 向2D GPU node发送数据获取数据;

  • 获取数据保存指定路径。

软件架构说明

software_arch.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_format_convert_gpu2d

  • 目录结构

single_format_convert_gpu2d
├── Makefile
├── bmp.c
├── bmp.h
├── res/nv12_1920x1080.yuv
├── res/yuv422_1920x1080.yuv422
├── single_format_convert_gpu2d
└── single_format_convert_gpu2d.c

API 流程说明

api_flow.png

3.15.16.2. 编译部署

编译

  • 进入 single_format_convert_gpu2d 目录,执行make编译

  • 输出成果物是 single_format_convert_gpu2d 源码目录single_format_convert_gpu2d

  • 详细程序编译方式查阅 编译方法 章节

程序部署

single_format_convert_gpu2d res传到开发板之后,运行chmod +x single_format_convert_gpu2d命令程序赋予执行权限。

3.15.16.3. 运行

程序运行方法

直接执行程序 ./single_format_convert_gpu2d -h 可以获得帮助信息

程序参数选项说明

Usage: single_format_convert_gpu2d [OPTIONS]
Options:
  -i <input_img_name>       input image name
  -o <output_img_name>      output image name
  -w <image_width>          input image width
  -h <image_height>         input image height
  -j <input_img_format>     intput image format index
  -k <output_img_format>    output image format index
   MEM_PIX_FMT_ARGB    index is 4
   MEM_PIX_FMT_NV12    index is 8
   MEM_PIX_FMT_YUYV422 index is 13
  -h                        Show this help message
Such as: nv12 -> bmp yuv422:
        ./single_format_convert_gpu2d -i ./res/nv12_1920x1080.yuv  -o ./test_nv12_1920x1080.bmp -w 1920 -h 1080 -j 8 -k 3
        ./single_format_convert_gpu2d -i ./res/nv12_1920x1080.yuv  -o ./test_nv12_1920x1080.yuv422 -w 1920 -h 1080 -j 8 -k 13
         yuv422 -> bmp nv12:
        ./single_format_convert_gpu2d -i ./res/yuv422_1920x1080.yuv422 -o ./test_yuv422_1920x1080.bmp -w 1920 -h 1080 -j 13 -k 3
        ./single_format_convert_gpu2d -i ./res/yuv422_1920x1080.yuv422 -o ./test_yuv422_1920x1080.yuv -w 1920 -h 1080 -j 13 -k 8

运行效果

示例以nv12转bmp为例,演示如何使用 single_format_convert_gpu2d

运行以下命令:

./single_format_convert_gpu2d -i ./res/nv12_1920x1080.yuv  -o ./test_nv12_1920x1080.bmp -w 1920 -h 1080 -j 8 -k 3

日志示例如下所示:

buffer.addr:0xffffaa278000 size:2073600
(read_yuvv_nv12_file):file read(./res/nv12_1920x1080.yuv), y-size(2073600)
input_format is MEM_PIX_FMT_NV12
output_format is MEM_PIX_FMT_ARGB
GPU2D input  1920x1080 stride=1920
GPU2D output 1920x1080 stride=1920
SaveBmpImage ./test_nv12_1920x1080.bmp succ, size=8294400

程序运行后,当前目录一个文件’test_yuv422_1920x1080.bmp’。

3.15.17. single_pipe_vin_isp_vse_multi_process

3.15.17.1. 功能概述

single_pipe_vin_isp_vse_multi_process一个进程通信示例程序,用于演示Sensor VIN ISP VSE 获取 NV12 图像后,分别通过 UNIX domain socket图像发送到:

  • 编码进程:将 NV12 图像送入 VPU 编码持续保存 H.264 码流文件;

  • HDMI 显示进程:将 NV12 图像通过 DRM 在 HDMI 显示器实时显示。

示例由 3 个进程(可执行文件)组成:

  • single_pipe_vin_isp_vse_process:主控进程,负责创建 vflow、从 VSE 获取发给进程,同时接收进程释放消息;

  • single_pipe_vin_isp_vse_hdmi:显示进程,接收在 HDMI 上显示;

  • single_pipe_vin_isp_vse_encode:编码进程,接收编码保存为 H.264 码流(ping/pang 轮转文件)。

软件架构说明

software_arch.png

数据流说明

data_flow.png

3.15.17.2. 函数流程图

VSE进程:single_pipe_vin_isp_vse_process.c

process_flow.png

HDMI进程:single_pipe_vin_isp_vse_hdmi.c

hdmi_flow.png

编码进程:single_pipe_vin_isp_vse_encode.c

encode_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_multi_process

  • 目录结构

single_pipe_vin_isp_vse_multi_process
├── Makefile
├── single_pipe_vin_isp_vse_process.c
├── single_pipe_vin_isp_vse_encode.c
├── single_pipe_vin_isp_vse_hdmi.c
├── unix_socket.c
├── unix_socket.h
├── ping_pang_file_saver.c
└── ping_pang_file_saver.h

3.15.17.3. 编译部署

编译

  • 进入 single_pipe_vin_isp_vse_multi_process 目录,执行 make 编译

  • 输出成果物是目录的 3 个可执行文件:

    • single_pipe_vin_isp_vse_process

    • single_pipe_vin_isp_vse_encode

    • single_pipe_vin_isp_vse_hdmi

  • 详细程序编译方式查阅 编译方法 章节

程序部署

上述3个可执行文件传到开发板之后,运行 chmod +x single_pipe_vin_isp_vse_* 命令赋予执行权限。

3.15.17.4. 运行

程序运行方法

运行HDMI显示进程前,请确保正确连接显示设备,并加载显示相关驱动模块(与 single_pipe_vin_isp_vse_vo 一致):

modprobe panel-jc-050hd134
modprobe galcore
modprobe vio_n2d
modprobe lontium_lt8618
modprobe vs-x5-syscon-bridge
modprobe vs_drm

推荐使用 3 个终端分别启动 3 个进程。启动顺序建议如下:

  1. 启动主控进程 single_pipe_vin_isp_vse_process

  2. 启动HDMI显示进程 single_pipe_vin_isp_vse_hdmi

  3. 启动编码进程 single_pipe_vin_isp_vse_encode

编码/显示进程主动连接主控进程创建的 socket;若先启动编码/显示进程,会提示“please start VSE process first”并退出。

程序参数选项说明

主控进程 single_pipe_vin_isp_vse_process 支持参数如下(其余两个进程无需参数,直接运行即可):

Usage: ./single_pipe_vin_isp_vse_process [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message
  • -s <sensor_index>

    • 传感器索引(必选):整数类型,对应系统传感器列表。

  • -c <channel_type>

    • 指定 VIN/ISP/VSE 的在线/离线组合方式,默认 vf:if

  • -h

    • 显示帮助信息退出。

运行效果

示例以 1 路 sensor 为例,演示如何使用 single_pipe_vin_isp_vse_multi_process

  1. 启动进程(示例以 sensor index=3 为例):

    ./single_pipe_vin_isp_vse_process -s 3
    

    典型日志包含:

    Wait encode process connect...
    Wait HDMI process connect...
    
  2. 一个终端启动 HDMI 显示进程:

    ./single_pipe_vin_isp_vse_hdmi
    

    连接成功后,HDMI 显示器实时显示来自 VSE 的图像,同时终端输出类似日志:

    HDMI display frame success: id=..., resolution=...x...
    
  3. 一个终端启动编码进程:

    ./single_pipe_vin_isp_vse_encode
    

    编码进程连接成功开始打印接收信息,并当前目录生成 ping/pang 轮转的 H.264 码流文件:

    • ping_single_pipe_vin_isp_vse_vpu.h264

停止程序时,可各个终端Ctrl+C 退出;主控进程清理 /tmp/vse_encode.sock/tmp/vse_hdmi.sock

3.15.18. single_pipe_vin_isp_vse_bpu

3.15.18.1. 功能概述

single_pipe_vin_isp_vse_bpu 示例演示如何将 Camera 采集图像数据传输至 BPU 模块进行算法推理:

  • 程序从 VSE 模块 1 输出通道获取完成缩放分辨率适配算法要求图像数据

  • 示例程序提供演示算法是: mobilenetv2

软件架构说明

software_arch.png

数据流说明

data_flow.png

代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_pipeline/single_pipe_vin_isp_vse_bpu

  • 目录结构

single_pipe_vin_isp_vse_bpu
├── bpu_mobilenetv2.c
├── bpu_mobilenetv2.h
├── Makefile
├── mobilenetv2_image_labels.h
├── model_zoom
│   └── mobilenetv2_224x224_nv12.bin
└── single_pipe_vin_isp_vse_bpu.c

API 流程说明

api_flow.png

3.15.18.2. 编译部署

编译

  • 进入 single_pipe_vin_isp_vse_bpu 目录,执行make编译

  • 输出成果物是 single_pipe_vin_isp_vse_bpu 源码目录single_pipe_vin_isp_vse_bpu

  • 详细程序编译方式查阅 编译方法 章节

程序部署

single_pipe_vin_isp_vse_bpumodel_zoom传到开发板之后,运行 chmod +x single_pipe_vin_isp_vse_bpu 命令程序赋予执行权限。

3.15.18.3. 运行

程序运行方法

直接执行程序 ./single_pipe_vin_isp_vse_bpu 可以获得帮助信息

程序参数选项说明

Usage: ./single_pipe_vin_isp_vse_bpu [OPTIONS]
Options:
  -s <sensor_index>             Specify sensor index
  -c <channel_type>             Specify channel type: vo and vf and io and if, default: vf:if
                Support both individual configuration and combined configuration.
                The individual configuration supports four types:
                                1. vo: vin online isp
                                2. vf: vin offline isp
                                3. io: isp online vse
                                4. if: isp offline vse
                The combination configuration supports four types:
                                1. vo:io  vin online isp + isp online vse
                                2. vo:if  vin online isp + isp offline vse
                                3. vf:io  vin offline isp + isp online vse
                                4. vf:if  vin offline isp + isp offline vse
  -h    Show help message

参数说明

  • -s: 指定 Camera Sensor 型号配置

  • -c: 指定 VIN 和 ISP 之间,以及 ISP 和 VSE 之间连接方式,分别支持 Offline 和 Online 的连接方式

运行效果

single_pipe_vin_isp_vse_bpu摄像头识别图像进行 mobilenetv2 算法推理,并打印算法推理结果。

示例: 以 sc230ai 作为 sensor 输入,执行 ./single_pipe_vin_isp_vse_bpu -s 3 -c vf:if ,实际根据当前连接的 sensor 选择对应序号

Using index:3  sensor_name:sc230ai-30fps  config_file:linear_1920x1080_raw10_30fps_1lane.c
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

Connection method from VIN to ISP: vin offline isp
Connection method from ISP to VSE: isp offline vse.

hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 224x224
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 480x480
hbn_vnode_set_ochn_attr: 5, 3840x2160
[BPU INFO] model_path[./model_zoom/mobilenetv2_224x224_nv12.bin]
[BPU_PLAT]BPU Platform Version(1.3.6)! soc info(x5)
[HBRT] set log level as 0. version = 3.15.55.0
[DNN] Runtime version = 1.24.5_(3.15.55 HBRT)
[A][DNN][packed_model.cpp:247][Model](1970-01-01,23:08:17.272.839) [HorizonRT] The model builder version = 1.23.0
[W][DNN]bpu_model_info.cpp:491][Version](1970-01-01,23:08:17.300.248) Model: mobilenetv2_224x224_nv12. Inconsistency between the hbrt library version 3.15.55.0 and the model build version 3.15.45.0 detected, in order to ensure correct model results, it is recommended to use compilation tools and the BPU SDK from the same OpenExplorer package.
Model info:
model_name: mobilenetv2_224x224_nv12
Input count: 1
input[0]: tensorLayout: 2 tensorType: 1 validShape:(1, 3, 224, 224, ), alignedShape:(1, 3, 224, 224, )
Output count: 1
Output[0]: tensorLayout: 2 tensorType: 13 validShape:(1, 1000, 1, 1, ), alignedShape:(1, 1000, 1, 1, )
[BPU INFO] model_name_list[0]:mobilenetv2_224x224_nv12
[BPU INFO] packed_dnn_handle: 0x2291840, dnn_handle: 0x22931f0
[BPU INFO] model input NCHW = (1, 3, 224, 224)
[BPU mobilenetv2] [classification result: id=572(goblet(酒杯)), score=0.095]
[BPU mobilenetv2] [classification result: id=794(shower curtain(浴帘)), score=0.149]
[BPU mobilenetv2] [classification result: id=807(solar dish(太阳能板)), score=0.224]
[BPU mobilenetv2] [classification result: id=461(breastplate(盔甲)), score=0.204]
[BPU mobilenetv2] [classification result: id=807(solar dish(太阳能板)), score=0.201]
... ...
... ...
... ...
[BPU mobilenetv2] [classification result: id=897(washer(洗衣机)), score=0.124]
[BPU mobilenetv2] [classification result: id=882(vacuum(吸尘器)), score=0.113]
[BPU mobilenetv2] [classification result: id=897(washer(洗衣机)), score=0.098]
[BPU mobilenetv2] [classification result: id=882(vacuum(吸尘器)), score=0.116]
[BPU mobilenetv2] [classification result: id=897(washer(洗衣机)), score=0.126]
^C[BPU mobilenetv2] [classification result: id=882(vacuum(吸尘器)), score=0.093]
[BPU INFO] bpu_wrap_deinit successful