|
USB中星微zc301p摄像头
Device Drivers --->
<*> Multimedia support --->
<*> Video For Linux
[*] Video capture adapters (NEW) --->
[*] V4L USB devices (NEW) --->
<*> USB Video Class (UVC)
[*] UVC input events device support (NEW)
<*> GSPCA based webcams ---> 注意:这里不要设为M
<*> ZC3XX USB Camera Driver
[*] USB support --->
<*> EHCI HCD (USB 2.0) support
[*] OHCI support for loognson1 chips
<*> OHCI HCD support
[*] OHCI support for loognson1 chips
测试程序(通过摄像头抓取图片)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <linux/videodev2.h>
int main()
{
struct v4l2_capability cap;
struct v4l2_format fmt;
int fd = 0;
void *buff = NULL;
int size = 0;
fd = open("/dev/video0", O_RDWR);
ioctl(fd, VIDIOC_QUERYCAP, &cap);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = 640;
fmt.fmt.pix.height = 480;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG; // 使用JPEG格式帧,用于静态图像采集
ioctl(fd, VIDIOC_S_FMT, &fmt);
buff = malloc(1024 * 1024); // 分配缓存足以容纳一帧图像
size = read(fd, buff, 1024 * 1024);
int filefd = open("./capture.jpg", O_RDWR | O_CREAT);
write(filefd, buff, size);
return 0;
}
|
|