Ingenic hardware acceleration for cameras
Find a file
2025-10-20 19:19:54 +00:00
example V11 buildroot version 2025-10-20 19:08:00 +00:00
include V11 buildroot version 2025-10-20 19:08:00 +00:00
syncframe V11 buildroot version 2025-10-20 19:08:00 +00:00
test V11 buildroot version 2025-10-20 19:08:00 +00:00
v4l2 V11 buildroot version 2025-10-20 19:08:00 +00:00
v4l2enc V11 buildroot version 2025-10-20 19:08:00 +00:00
.gitignore Update gitignore 2025-10-20 19:19:36 +00:00
Build.mk V11 buildroot version 2025-10-20 19:08:00 +00:00
CMakeLists.txt V11 buildroot version 2025-10-20 19:08:00 +00:00
README.md V11 buildroot version 2025-10-20 19:08:00 +00:00
TODO.md V11 buildroot version 2025-10-20 19:08:00 +00:00
xburst2.cmake V11 buildroot version 2025-10-20 19:08:00 +00:00

sync-frames

简介

本工程生成两个库文件libsyncframe.so和libv4l2enc.so。
libsyncframe.so提供获取同步帧接口支持单个摄像头数据的获取数据源格式为NV12和NV21。
libv4l2enc.so提供jpg编码接口支持NV12和NV21格式编码成jpg格式。

在Manhattun目录下编译

#make sync-frames

生成文件说明

提供库中函数测试程序驱动双摄提取同步帧、重置camera队列缓冲区、驱动单摄获取单帧的demo。 生成test, get_syncframe, reset_syncframe, get_monoframe, osd_syncframe_client可执行文件。

test :

对双目摄像头库中所有函数进行测试test/test.c为示例。

设备要求

双目摄像头

输入参数
Parameter 1 : width 1280/640
Parameter 2 : height 720/480
Parameter 3 : format 0 : V4L2_PIX_FMT_NV21 | 1 : V4L2_PIX_FMT_NV12
Parameter 4 : bcount 3/4/5
Parameter 5 : get the number of frames (the max is bcount-1)
Parameter 6 : open two cameras or one camera 1/0
Parameter 7 : The name of one of the two cameras
Parameter 8 : The name of one of the two cameras
Parameter 9 : The name of one camera
Parameter 10 :The name of  encode device
运行命令示例
#syncframe_test 640 480 0 3 1 1 /dev/video0 /dev/video3 0 /dev/video1

get_syncframe :

双目摄像头提取同步帧demo对提取同步帧API的调用并把帧数据写入文件example/syncframe.c为示例。

设备要求

双目摄像头

运行命令
#get_syncframe

reset_syncframe :

libsyncframe.so支持提取同步帧时重置camera缓存的数据example/reset_syncframe.c 为调用示例。

设备要求

双目摄像头

运行命令
#reset_syncframe

get_monoframe :

驱动单摄取帧demosyncframe库支持驱动单个摄像头取帧操作并把帧数据写入文件example/monoframe.c 为调用示例。

设备要求

双目摄像头

运行命令
#get_monoframe

osd_syncframe_client :

获取同步帧并在LCD上显示串口输出同步帧时间差example/osd_syncframe_client.cpp 为调用示例。

设备要求

双目摄像头LCD屏。

运行条件

编译osd运行osdServer后在adb shell中运行osd_syncframe_client运行成功后LCD屏显示获取到的同步帧串口输出同步帧时间差。

minicom端

#osdServer

adb shell端

#osd_syncframe_client

libsyncframe.so库接口说明

结构体

struct buf_info{//单帧信息结构体
    void *camera_buf;//帧数据
    __u32 index;//帧索引
}
    
struct cameras_buf{//同步帧信息结构体
    struct buf_info Rcamera;//右摄像头帧信息
    struct buf_info Lcamera;//左摄像头帧信息
    float time_diff;//同步帧时间差
}
    
struct config{//用户设置
    bool video_flag;//是否取同步帧标志
    
    char *camera_r_name;//右摄像头设备节点
    char *camera_l_name;//左摄像头设备节点
    char *camera_name;//单摄时,摄像头设备节点
    
    __u32 width;//数据帧的宽
    __u32 height;//数据帧的高
    __u23 pixfmt;//数据帧的格式
    __u32 buffer_size;//一帧的大小
    __u32 bcount;//申请buffer数量
    
    void *camera;   
}

库宏

#define SYNCFRAME       true
#define MONOFRAME       false

库函数

摄像头初始化函数

int cameras_init(bool video_flag, struct config *config);

参数说明:

bool video_flag : SYNCFRAME(开启双摄) 或者 MONOFRAME开启单摄
struct config : 用户设置结构体。

函数功能:

camera init函数init成功返回0失败返回-1。

提取同步帧函数

struct cameras_buf *dqbuf_syncframe(struct config *config);

参数说明:

struct cameras_buf : 同步帧信息结构体
struct config : 用户设置结构体

函数功能:

提取同步帧成功返回同步帧信息错误返回NULL。

释放同步帧函数

void qbuf_syncframe(struct config *config, struct cameras_buf *syncframe);

参数说明:

struct config : 用户设置结构体
struct cameras_buf : 同步帧信息结构体

函数功能:

释放当前同步帧,把buffer重新放回输入队列。

重置队列缓存帧数据函数

void reset_buf(struct config *config);

参数说明:

struct config : 用户设置结构体

函数功能:

更新队列中的buffer保证buffer的实时性。在处理同步帧时间过长导致下一个缓存中的同步帧失去实时性的时候使用。

获取单摄像头的帧数据

struct buf_info *get_monoframe(struct config *config);

参数说明:

struct buf_info : 单帧buffer信息结构体。
struct config : 用户设置结构体。

函数功能:

获取单帧摄像头的数据成功返回单身信息结构体指针失败返回NULL。

释放单帧函数

void qbuf_monoframe(struct config *config, struct buf_info *monoframe);

参数说明:

struct config : 用户设置结构体
struct buf_info : 单帧信息结构体

函数功能:

把单个摄像头的buffer放回输入队列。

uninit函数

void uninit_video(strcut config *config)

参数说明:

struct config : 用户设置结构体。

函数功能:

关流,关闭设备节点,取消内存映射。

libv4l2enc.so库接口说明

结构体

struct encode_config {                              
    char *name;//编码设备节点
    __u32 width;//帧宽度
    __u32 height;//帧高度
    __u32 pixfmt;//帧格式
    void *input_buf;//编码输入buffer指针
    void *output_buf;//编码输出buffer指针
    void *encode;//
}; 

库函数

编码初始化函数

int jpeg_enc_init(struct encode_config *encode_config)

参数说明:

struct encode_config :用户设置结构体

函数功能:

初始化编码设备节点初始化成功返回0失败返回-1。

编码函数

int jpeg_enc_start(struct encode_config *encode_config)

参数说明:

struct encode_config :用户设置结构体

函数功能:

对V4L2_PIX_FMT_NV21和V4L2_PIX_FMT_NV12格式编码成jpg格式。编码成功返回编码后数据大小失败返回-1。

停止编码函数

int jpeg_enc_stop(struct encode_config *encode_config);

参数说明:

struct encode_config :用户设置结构体

函数功能:

停止编码关闭设备节点释放占用资源。成功返回0失败返回-1。