#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,
v4l2简单小案例!!!
于 2022-11-14 14:50:21 首次发布