5.10.3. GDC Bin API
5.10.3.1. 模块描述
GDC bin API 用于
指导 如何 生成 GDC bin 文件。 GDC bin API 通过
hbn_gen_gdc_bin_json或者hbn_gen_gdc_bin接口生成 GDC bin,通过 hbn_free_gdc_bin释放GDC bin的 buffer。GDC bin API 使用
时 通常 和 仿真 工具 GDC Tool 结合 起来 使用, GDC Tool 所有 的 变换 模式 生成 的 layout.json文件都 可以 通过GDC Bin API生成 GDC bin文件。
GDC Tool 使用
操作流程
使用 GDC Bin API 的
先
使用 GDC Tool 生成 json 后,然后 通过 hbn_gen_gdc_bin_json生成 GDC bin 文件,参考示例 generate_bin 。 将
生成 的 GDC bin 文件 读取 到 hbmem 分配 的 内存 中,然后 通过 hbn_vnode_set_attr配置应用 到 GDC 节点 上。 启动 GDC 节点:开始
处理 图像,通过 dump_2plane_yuv_to_file将处理 后 的 文件 保存 到 文件系统 中。 处理
完成 后 通过 hbn_free_gdc_bin释放存放 GDC bin 的 buffer。
使用 custom 变换
5.10.3.2. 参考示例
GDC 部分
示例 代码 可以 参考 sample_gdc 章节
5.10.3.3. API 参考
以下 API 用于 GDC BIN 生成, GDC 模块
| API 接口 | 接口 |
|---|---|
| hbn_gen_gdc_bin | 使用 window 的 |
| hbn_gen_gdc_bin_json | 读取 |
| hbn_free_gdc_bin | 释放 hbn_gen_gdc_bin() 或 hbn_gen_gdc_bin_json() 接口 |
hbn_gen_gdc_bin
【函数声明】
int32_t hbn_gen_gdc_bin(const param_t *gdc_param, const window_t *windows, uint32_t wnd_num, uint32_t **cfg_buf, uint64_t *cfg_size);
【功能描述】
使用 window 的
【参数描述】
[IN] param_t *gdc_parm: gdc 对应
参数,包括 分辨率,格式 等。 [IN] window_t *wnds: gdc 内部
区域 参数。 [IN] uint32_t wnd_num: window 数目。
[OUT] uint32_t **cfg_buf:生成
的 gdc cfg bin,内部 分配。 [OUT] uint64_t *cfg_size: gdc cfg bin 文件
的 大小。
【返回值】
成功: HBN_STATUS_SUCESS 0 。
失败:异常
为 负值 错误码,参考 返回值 说明 。
hbn_gen_gdc_bin_json
【函数声明】
int32_t hbn_gen_gdc_bin_json(const char *layout_file, char *config_file, uint32_t **cfg_buf, uint64_t *config_size);
【功能描述】
读取
【参数描述】
[IN] const char *layout_file: json 文件
路径,生成 gdc bin 的 参数 配置。 [IN] char *config_file:指定
一个 文件 路径,用于 存放 生成 的 gdc bin,可 为 NULL。 [OUT] uint32_t **cfg_buf:生成
的 gdc cfg bin,内部 分配。 [OUT] uint64_t *cfg_size: gdc cfg bin 文件
的 大小。
【返回值】
成功: HBN_STATUS_SUCESS 0 。
失败:异常
为 负值 错误码,参考 返回值 说明 。
【兼容性】
硬件: X5
hbn_free_gdc_bin
【函数声明】
void hbn_free_gdc_bin(uint32_t *cfg_buf);
【功能描述】
释放 hbn_gen_gdc_bin() 或 hbn_gen_gdc_bin_json() 接口
【参数描述】
[IN] uint32_t *cfg_buf: gdc bin 的 buffer 地址。
【返回值】
无。
【兼容性】
硬件: X5
5.10.3.4. 数据结构
typedef struct param_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| format | frame_format_t | - | - | - | 处理 |
是 |
| in | resolution_t | - | - | - | 实际 |
是 |
| out | resolution_t | - | - | - | 实际 |
是 |
| x_offset | int32_t | 0 | - | 0 | 输入 |
是 |
| y_offset | int32_t | 0 | - | 0 | 输入 |
是 |
| diameter | int32_t | 0 | 定义 |
是 | ||
| fov | double | 0 | 视场 |
是 |
typedef enum frame_format frame_format_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| FM T_UNKNOWN | - | - | - | - | 未知 |
- |
| FMT_LUMINANCE | - | - | - | - | 暂 |
- |
| FMT_PLANAR_444 | - | - | - | - | 暂 |
- |
| FMT_PLANAR_420 | - | - | - | - | 暂 |
- |
| FMT_SEMIPLANAR_420 | - | - | - | - | nv12 | - |
| FM T_GDC_MAX | - | - | - | - | - | - |
typedef struct resolution_s resolution_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| w | uint32_t | - | - | - | 宽度( 像素 ) | - |
| h | uint32_t | - | - | - | 高度( 像素 ) | - |
typedef struct window_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| out_r | rect_t | - | - | - | 输出 |
- |
| transform | transformation_t | 0 | 6 | 0 | 使用 |
- |
| input_roi_r | rect_t | roi 区域 | ||||
| pan | int32_t | 以 |
||||
| tilt | int32_t | 以 |
||||
| zoom | double | 目标 |
||||
| strength | double | 1.0 | x 方向 |
|||
| strengthY | double | 1.0 | y 方向 |
|||
| angle | double | 0 | 主 |
|||
| elevation | double | 0 | 指定 |
|||
| azimuth | double | 0 | 指定 |
|||
| keep_ratio | int32_t | 1 | 在 |
|||
| FOV_h | double | 90 | 输出 |
|||
| FOV_w | double | 90 | 输出 |
|||
| cylindricity_y | double | 0 | 目标 |
|||
| cylindricity_x | double | 0 | 目标 |
|||
| custom_file[128] | char | custom 模式 |
||||
| custom | custom_tranformation_t | 自定义 |
||||
| trapezoid_left_angle | double | 0 | 梯形 |
|||
| trapezoid_right_angle | double | 0 | 梯形 |
|||
| check_compute | uint8_t | 暂时 |
typedef struct rect_s rect_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| x | int32_t | - | - | - | 起始 |
- |
| y | int32_t | - | - | - | 起始 |
- |
| w | int32_t | 宽度,必须 |
||||
| h | int32_t | 高度,必须 |
typedef enum gdc_transformation transformation_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| PANORAMIC | - | - | - | - | 全景 |
|
| CYLINDRICAL | - | - | - | - | NA | |
| STEREOGRAPHIC | - | - | - | - | 畸变 |
|
| UNIVERSAL | - | - | - | - | Equidistant 等距 |
|
| CUSTOM | - | - | - | - | 用户 |
|
| AFFINE | - | - | - | - | 线性变换 | |
| DEWARP_KEYSTONE | - | - | - | - | 相对 |
typedef struct point_s point_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| x | double | - | - | - | x 坐标 | - |
| y | double | - | - | - | y 坐标 | - |
typedef struct custom_tranformation_s custom_tranformation_t
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| full_tile_calc | uint8_t | - | - | - | 是否 |
- |
| tile_incr_x | uint16_t | - | - | - | tile increase in x | - |
| tile_incr_y | uint16_t | - | - | - | tile increase in y | - |
| w | int32_t | 自定义 |
||||
| h | int32_t | 自定义 |
||||
| centerx | double | center along x axis,通常 |
||||
| centery | double | center along y axis,通常 |
||||
| *points | point_t | config.txt 转换 |