嵌入式linux相机 摄像头模块

video_manager.c

cpp 复制代码
/**********************************************************************
 * 函数名称: RegisterVideoOpr
 * 功能描述: 注册"字体模块", 所谓字体模块就是取出字符位图的方法
 * 输入参数: ptVideoOpr - 一个结构体,内含"取出字符位图"的操作函数
 * 输出参数: 无
 * 返 回 值: 0 - 成功, 其他值 - 失败
 * 修改日期        版本号     修改人	      修改内容
 * -----------------------------------------------
 * 2013/02/08	     V1.0	  韦东山	      创建
 ***********************************************************************/

int RegisterVideoOpr(PT_VideoOpr ptVideoOpr)
{
	PT_VideoOpr ptTmp;

	if (!g_ptVideoOprHead)
	{
		g_ptVideoOprHead   = ptVideoOpr;
		ptVideoOpr->ptNext = NULL;
	}
	else
	{
		ptTmp = g_ptVideoOprHead;
		while (ptTmp->ptNext)
		{
			ptTmp = ptTmp->ptNext;
		}
		ptTmp->ptNext     = ptVideoOpr;
		ptVideoOpr->ptNext = NULL;
	}

	return 0;
}


/**********************************************************************
 * 函数名称: ShowVideoOpr
 * 功能描述: 显示本程序能支持的"字体模块"
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 修改日期        版本号     修改人	      修改内容
 * -----------------------------------------------
 * 2013/02/08	     V1.0	  韦东山	      创建
 ***********************************************************************/

void ShowVideoOpr(void)
{
	int i = 0;
	PT_VideoOpr ptTmp = g_ptVideoOprHead;

	while (ptTmp)
	{
		printf("%02d %s\n", i++, ptTmp->name);
		ptTmp = ptTmp->ptNext;
	}
}

/**********************************************************************
 * 函数名称: GetVideoOpr
 * 功能描述: 根据名字取出指定的"字体模块"
 * 输入参数: pcName - 名字
 * 输出参数: 无
 * 返 回 值: NULL   - 失败,没有指定的模块, 
 *            非NULL - 字体模块的PT_VideoOpr结构体指针
 * 修改日期        版本号     修改人	      修改内容
 * -----------------------------------------------
 * 2013/02/08	     V1.0	  韦东山	      创建
 ***********************************************************************/

PT_VideoOpr GetVideoOpr(char *pcName)
{
	PT_VideoOpr ptTmp = g_ptVideoOprHead;
	
	while (ptTmp)
	{
		if (strcmp(ptTmp->name, pcName) == 0)
		{
			return ptTmp;
		}
		ptTmp = ptTmp->ptNext;
	}
	return NULL;
}


/**********************************************************************
 * 函数名称: FontsInit
 * 功能描述: 调用各个字体模块的初始化函数
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 0 - 成功, 其他值 - 失败
 * 修改日期        版本号     修改人	      修改内容
 * -----------------------------------------------
 * 2013/02/08	     V1.0	  韦东山	      创建
 ***********************************************************************/

int VideoInit(void)
{
	int iError;

    iError = V4l2Init();

	return iError;
}

video_manager.h

cpp 复制代码
#ifndef _VIDEO_MANAGER_H
#define _VIDEO_MANAGER_H

#include <config.h>
#include <pic_operation.h>

#define NB_BUFFER 4

struct VideoDevice;
struct VideoOpr;
typedef struct VideoDevice T_VideoDevice, *PT_VideoDevice;
typedef struct VideoOpr T_VideoOpr, *PT_VideoOpr;

typedef struct VideoDevice {
    int iFd;
    int iPixelFormat;
    int iWidth;
    int iHeight;

    int iVideoBufCnt;
    int iVideoBufMaxLen;
    int iVideoBufCurIndex;
    unsigned char *pucVideBuf[NB_BUFFER];

    /* ���� */
    PT_VideoOpr ptOPr;
}T_VideoDevice, *PT_VideoDevice;

typedef struct VideoBuf {
    T_PixelDatas tPixelDatas;
    int iPixelFormat;
}T_VideoBuf, *PT_VideoBuf;

typedef struct VideoOpr {
    char *name;
    int (*InitDevice)(char *strDevName, PT_VideoDevice ptVideoDevice);
    int (*ExitDevice)(PT_VideoDevice ptVideoDevice);
    int (*GetFrame)(PT_VideoDevice ptVideoDevice, PT_VideoBuf ptVideoBuf);
    int (*PutFrame)(PT_VideoDevice ptVideoDevice, PT_VideoBuf ptVideoBuf);
    int (*StartDevice)(PT_VideoDevice ptVideoDevice);
    int (*StopDevice)(PT_VideoDevice ptVideoDevice);
}T_VideoOpr, *PT_VideoOpr;


int V4l2Init(void);

#endif /* _VIDEO_MANAGER_H */

v4l2.c(链接)

v4l2.c

相关推荐
ai_xiaogui1 分钟前
AIStarter:全网唯一跨平台桌面AI管理工具,支持Windows、Mac和Linux一键部署
linux·人工智能·macos·跨平台ai项目一键部署工具·comfyui模型库·高效管理2.19tb模型库·一键配置comfyui模型库
飘飘燃雪18 分钟前
在 Linux 系统上安装 Docker 的步骤如下(以 Ubuntu/Debian为例)
linux·ubuntu·docker·debian
哈基米喜欢哈哈哈1 小时前
Linux常用命令(后端开发版)
linux·运维·服务器
玖剹1 小时前
深入解析Linux信号处理机制
linux·运维·服务器·网络·c++·ubuntu
skywalk816311 小时前
docker的开源跨平台替代Vagrant
linux·运维·docker·容器·vagrant
捏尼卜波卜13 小时前
try/catch/throw 简明指南
linux·开发语言·c++
IDOlaoluo13 小时前
Linux 安装 JDK 8u291 教程(jdk-8u291-linux-x64.tar.gz 解压配置详细步骤)
java·linux·运维
烷烯15 小时前
安全基础DAY1-安全概述
linux·服务器·安全·常见网路攻击
YueiL16 小时前
Linux文件系统基石:透彻理解inode及其核心作用
linux·网络·数据库
神即道 道法自然 如来16 小时前
如何在linux(CentOS7)上面安装 jenkins?
linux·运维·jenkins