v4l2简单小案例!!!

#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/videodev2.h>
#include <linux/v4l2-subdev.h>
#include <linux/v4l2-common.h>
#define BUFINFOR_NUM  (4)

struct capbuffer{
    void *start[3];
    int length[3];
};
void YUV420P_to_RGB24(unsigned char *yuyv, unsigned char *rgb, int width, int height);
void LCD_SHOW_RGB(unsigned char *rgb,int w,int h);


static unsigned int *lcdptr = NULL;
static unsigned char *rgb = NULL;
int fd =0,ret =0,nplanes =0,width =1280,height = 720;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct capbuffer *buffers;
struct v4l2_ext_control ctrls[4];
struct v4l2_ext_controls ext_ctrls;
struct v4l2_control control;
struct v4l2_input inp;
struct v4l2_streamparm parms;
struct v4l2_requestbuffers req;
struct v4l2_exportbuffer exp;
struct v4l2_capability cap;
struct v4l2_control ctrl;
struct v4l2_crop crop;
struct v4l2_fmtdesc v4fmt;
struct v4l2_format fmt;
static struct fb_var_screeninfo var;
#define CLEAR(x) (memset(&(x), 0, sizeof(x)))
#define ALIGN(x,a) (((x) + (a-1)) & ~(a-1))
int Init()
{
	
	int i= 0;
	buffers = reinterpret_cast<struct capbuffer *>(::calloc(BUFINFOR_NUM, sizeof(struct capbuffer)));
	fd = open("/dev/video0",O_RDWR,0);
        if(fd<0)
        {
                perror("open failed");
        }
	ret = ioctl(fd,
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值