#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;
}
我要赚赏金打赏帖 |
|
|---|---|
| PCF8574功能模块及其使用被打赏¥20元 | |
| 传感器LSM6DSO及LIS3MDL的功能检测被打赏¥18元 | |
| LPS25HB气压传感器及其检测被打赏¥18元 | |
| HTS221温湿度传感器及其检测被打赏¥18元 | |
| 【S32K3XX】HSE FW 版本更新被打赏¥21元 | |
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |
| TCS3472S传感器及其色彩检测被打赏¥19元 | |
| 【S32DS】S32K3 RTD7.0.1 HSE 组件配置报错问题解决被打赏¥27元 | |
| 【S32K3XX】MCME 启动 CORE1被打赏¥23元 | |
| AG32VH407下温度大气压传感器及其检测被打赏¥20元 | |
我要赚赏金
