资源简介
通过v4l2接口,采集摄像头数据(yuyv),并保存为24位bmp图,再将此bmp显示在lcd上(rgb32)

代码片段和文件信息
/*
* v4l2.c
*
* Created on: Aug 8 2011
* Author: gavin
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
#include
#include “v4l2grab.h“
#include “camera.h“
static int fd = -1;
struct buffer {
void * start;
size_t length;
};
//static io_method io = IO_METHOD_MMAP;
struct buffer * buffers = NULL;
static unsigned int n_buffers = 0;
// global settings
static unsigned int width = 800;
static unsigned int height = 480;
static char* deviceName = “/dev/video0“;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
static int fb_bpp;
static int cam_fp = -1;
static int fb_fp = -1;
static char *fb_addr = NULL;
unsigned char frame_buffer[640*480*3];
int fb_init(void)
{
int dev_fp = -1;
int fb_size;
// struct fb_var_screeninfo vinfo;
dev_fp = open(“/dev/fb0“ O_RDWR);
if (dev_fp < 0) {
perror(“/dev/fb0“);
return -1;
}
if(-1==xioctl(dev_fpFBIOGET_FSCREENINFO&finfo))
{
perror(“finfo“);
return -1;
}
if (ioctl(dev_fp FBIOGET_VSCREENINFO &vinfo)) {
printf(“Error reading variable information.\n“);
exit(1);
}
width=vinfo.xres;
height=vinfo.yres;
fb_bpp=vinfo.bits_per_pixel;
if(fb_bpp==24)
fb_bpp=32;
fb_size=width*height*fb_bpp/8;
if ((fb_addr = mmap(0 fb_sizePROT_READ | PROT_WRITE MAP_SHARED dev_fp 0)) < 0)
{
perror(“mmap()“);
return -1;
}
printf(“%dx%d bpp:%d mmaped 0x%08x\n“widthheightfb_bppfb_addr);
return dev_fp;
}
void deviceOpen(void)
{
fd = open(deviceName O_RDWR /* required */ | O_NONBLOCK 0);
// check if opening was successfull
if (-1 == fd) {
fprintf(stderr “Cannot open ‘%s‘: %d %s\n“ deviceName errno strerror (errno));
exit(EXIT_FAILURE);
}
}
/**
initialize device
*/
int deviceInit(void)
{
struct v4l2_capability cap;
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
struct v4l2_format fmt;
unsigned int min;
if (-1 == xioctl(fd VIDIOC_QUERYCAP &cap)) {
if (EINVAL == errno) {
fprintf(stderr “%s is no V4L2 device\n“deviceName);
exit(EXIT_FAILURE);
} else {
errno_exit(“VIDIOC_QUERYCAP“);
}
}
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
{
fprintf(stderr “%s is no video capture device\n“deviceName);
exit(EXIT_FAILURE);
}
struct v4l2_input input;
input.index = 0;
if ( ioctl(fd VIDIOC_ENUMINPUT &input) != 0)
{
printf(“ set input error.\n“);
exit(0);
}
if ((i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 753 2013-08-16 11:25 save\camera.h
文件 783 2013-08-11 16:48 save\main.c
文件 1981 2012-12-18 06:37 save\v4l2grab.h
文件 16046 2013-08-16 15:50 save\camera.c
目录 0 2013-08-19 16:17 save
----------- --------- ---------- ----- ----
19563 5
- 上一篇:springboot开发的物业管理系统-毕业设计
- 下一篇:节日彩灯控制器
相关资源
- 基于V4L2的视频采集,能够采集YUVJPE
- 使用RTMPdump(libRTMP)直播来自v4l2的摄
- 617张国内车牌60-17bmp图片用于OpenCV正样
- ORL人脸数据集,40个人,共400张bmp格式
- 批量快速将多张bmp图片合并转换为b
- BMP图片读写,24位输入转换成8位输出
- AES加密BMP图片
- qt5_V4L2_Camera 实现摄像头实时画面显示
- v4l2中文手册(规范)全五章(包含驱
- bmp图片转yuv420
- USB摄像头通过v4l2技术采集、储存视频
- V4L2采集YUYV数据x264编码成H264视频
- linux下关于Qt界面的摄像头v4l2操作源码
- linux+QT下基于RTP协议的实时视频传输客
- v4l2采集+yuyv转yuv420p+h264编码+tcp传输
- 兄弟连2014年新版Linux视频教程课件
- freetype2+SDL+SDL_ttf源码包及字符串转b
- 网易云兄弟连Linux视频教程课件完整版
- linux+qt+v4l2 摄像头视频捕捉--源代码
- ISODATA聚类分析,对BMP图片操作
- Linux下使用Qt+V4L2测试UVC相机
- 编程常用高清晰bmp图片
- Jpg图片和Bmp图片转为YUV数据
- mnist 手写数据图片转换到bmp图片格式
- 2018年最新全套linux视频教程源码笔记
- 基于v4l2的qt视频实时显示
- v4l2 USB摄像头图像采集程序C
- 将24位BMP图片转16位565格式-特别适合
- BMP图像转换为JPG算法
- linux下基于V4L2/Qt的usb摄像头采集显示
评论
共有 条评论