v4l2测试源码截图

本文主要探讨了使用V4L2接口进行摄像头测试的源码实现,通过详细解析关键代码,帮助读者理解如何操作摄像头设备,并展示了相关的截图以辅助说明。
摘要由CSDN通过智能技术生成
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <linux/videodev2.h>
#include <linux/fb.h>
#include <sys/poll.h>
#include <poll.h>
#include <stdlib.h>
#include <time.h>
 
 
#define NB_BUFFER 4
#define FB_DEVICE_NAME "/dev/fb0"
static int iWidth;
static int iHeight;
static int iVideoBufCnt;
static unsigned char *pucVideBuf[NB_BUFFER];
static int VideoBufMaxLen;
static int iFd;
static int VideoBufCurIndex;
static int iPixelFormat;
static struct fb_var_screeninfo g_tFBVar;
static int g_aiSupportedFormats[] = {V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_RGB565};
 
 
 
 
static int *LutYr = NULL;
static int *LutYg = NULL;;
static int *LutYb = NULL;;
static int *LutVr = NULL;;
static int *LutVrY = NULL;;
static int *LutUb = NULL;;
static int *LutUbY = NULL;;
static int *LutRv = NULL;
static int *LutGu = NULL;
static int *LutGv = NULL;
static int *LutBu = NULL;
void initLut(void)
{
    int i;
    #define Rcoef 299
    #define Gcoef 587
    #define Bcoef 114
    #define Vrcoef 711 //656 //877
    #define Ubcoef 560 //500 //493 564
    
    #define CoefRv 1402
    #define CoefGu 714 // 344
    #define CoefGv 344 // 714
    #define CoefBu 1772
    
    LutYr = malloc(256*sizeof(int));
    LutYg = malloc(256*sizeof(int));
    LutYb = malloc(256*sizeof(int));
    LutVr = malloc(256*sizeof(int));
    LutVrY = malloc(256*sizeof(int));
    LutUb = malloc(256*sizeof(int));
    LutUbY = malloc(256*sizeof(int));
    
    LutRv = malloc(256*sizeof(int));
    LutGu = malloc(256*sizeof(int));
    LutGv = malloc(256*sizeof(int));
    LutBu = malloc(256*sizeof(int));
    for (i= 0;i < 256;i++){
        LutYr[i] = i*Rcoef/1000 ;
        LutYg[i] = i*Gcoef/1000 ;
        LutYb[i] = i*Bcoef/1000 ;
        LutVr[i] = i*Vrcoef/1000;
        LutUb[i] = i*Ubcoef/1000;
        LutVrY[i] = 128 -(i*Vrcoef/1000);
        LutUbY[i] = 128 -(i*Ubcoef/1000);
        LutRv[i] = (i-128)*CoefRv/1000;
        LutBu[i] = (i-128)*CoefBu/1000;
        LutGu[i] = (128-i)*CoefGu/1000;
        LutGv[i] = (128-i)*CoefGv/1000;
    }    
}
#define CLIP(color) (unsigned char)(((color)>0xFF)?0xff:(((color)<0)?0:(color)))
R_FROMYV(unsigned char y, unsigned char v)
{
return CLIP((y) + LutRv[(v)]);
}
unsigned char
G_FROMYUV(unsigned char y, unsigned char u
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值