#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;
}
我要赚赏金打赏帖 |
|
|---|---|
| 【S32DS】S32K3 RTD7.0.1 HSE 组件配置报错问题解决被打赏¥27元 | |
| 【S32K3XX】MCME 启动 CORE1被打赏¥23元 | |
| AG32VH407下温度大气压传感器及其检测被打赏¥20元 | |
| AG32VH407下光照强度传感器BH1750及其检测被打赏¥22元 | |
| AT32VH407下使用温湿度传感器DHT22进行检测被打赏¥20元 | |
| DIY一个婴儿澡盆温度计被打赏¥34元 | |
| 【FreeRtos】FreeRtos+MPU region 配置规则被打赏¥23元 | |
| 【分享开发笔记,赚取电动螺丝刀】三分钟快速上手驱动墨水屏(ArduinoIDE)被打赏¥28元 | |
| 【S32K3XX】LIN 通讯模块使用被打赏¥31元 | |
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
我要赚赏金
