#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/videodev.h>
#include <string.h>
#define Video "/dev/video0"
#define Audio "/dev/dsp"
#define DEF_WIDTH 320
#define DEF_HEIGHT 240
/************************************
*name : main
*
*
*
*
*
*
************************************/
int main(int argc,char*argv[])
{
unsigned char buf[(320*240)/8];
int fd,;
int num;
/*define the struct */
struct video_capability vid_cap; /*摄像头参数结构*/
/*get the device number and saved to fd*/
fd=open(Video,O_WRONLY);
if(fd==-1){
perror("Can't open the Video device!\n");
return 1;
}else printf("Open the video device success!\n fd = %d\n",fd);
/*through ioctl function to init the device struct*/
if(ioctl(fd,VIDIOCGCAP,&vid_cap)<0)
{
perror("VIDIOCGCAP");
return 1;
}
fprintf(stderr,"Video Capture Device Name : %s\n",vid_cap.name);
fprintf(stderr,"Video Capture Device type : %d\n",vid_cap.type);
fprintf(stderr,"Video Capture Device channels : %d\n",vid_cap.channels);
fprintf(stderr,"Video Capture Device audios : %d\n",vid_cap.audios);
fprintf(stderr,"Video Capture Device max_W : %d\n",vid_cap.maxwidth);
fprintf(stderr,"Video Capture Device max_H : %d\n",vid_cap.maxheight);
fprintf(stderr,"Video Capture Device min_W : %d\n",vid_cap.minwidth);
fprintf(stderr,"Video Capture Device min_H : %d\n",vid_cap.minheight);
这个程序是获取摄像头的属性,接下来的步骤是获取图像信息,读取、保存图像,
直接通过read读取,但是不成功
if(read(fd,buf,(240*320)/8)<0)
{
perror("Can't read the picture!\n");
return 1;
}
打赏帖 | |
---|---|
分享博世的两种不同的喷射系统模式被打赏5分 | |
汽车+开路实验与短路实验被打赏10分 | |
多点式电子控制汽油喷射系统知识分享被打赏10分 | |
分享机械控制式汽油喷射系统被打赏5分 | |
汽车显示屏——第2部分:TFTLCD、OLED和micro-LED显示屏电源技术被打赏50分 | |
汽车+汽车电路板的走线规则被打赏20分 | |
五一劳动节快乐被打赏5分 | |
【分享开发笔记,赚取电动螺丝刀】s32k146适配zephyr(六)使用Ozone调试镜像被打赏29分 | |
【分享开发笔记,赚取电动螺丝刀】s32k146适配zephyr(五)添加设备树节点被打赏33分 | |
【分享开发笔记,赚取电动螺丝刀】s32k146适配zephyr(四)使用I2C总线驱动RA8900CE芯片被打赏23分 |