当前位置: 代码迷 >> 驱动开发 >> 中星微 webcam 0AC8 3450 摄像头 在ARMLINUX下的使用有关问题
  详细解决方案

中星微 webcam 0AC8 3450 摄像头 在ARMLINUX下的使用有关问题

热度:477   发布时间:2016-04-28 10:53:49.0
中星微 webcam 0AC8 3450 摄像头 在ARMLINUX下的使用问题
买了一个摄像头,控制器型号id是中星微的 0ac8 3450,在linux2.6.30里配置了UVC后,插入摄像头显示出驱动已经加载并识别出了摄像头:

usb 1-1: new high speed USB device using atmel-ehci and address 4
usb 1-1: New USB device found, idVendor=0ac8, idProduct=3450
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: Venus USB2.0 Camera
usb 1-1: Manufacturer: Vimicro Corp.
usb 1-1: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device Venus USB2.0 Camera (0ac8:3450)
input: Venus USB2.0 Camera as /class/input/input4

但是/dev/video* 节点没有,自己建立节点 mknod /dev/video0 c 81 0。

在网上下了一个摄像头测试程序,代码:
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>  
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <asm/types.h>
//#include <linux/videodev.h>
#include <linux/videodev2.h>
#include <sys/mman.h>
#include <string.h>
#include <malloc.h>




//#define ANDROID_ENV
#ifdef ANDROID_ENV
#define LOG LOGV
#else
#define LOG printf
#endif
#define CAMERA_DEVICE "/dev/video0"
#define CAPTURE_FILE "frame.jpg"
#define VIDEO_WIDTH 640
#define VIDEO_HEIGHT 480
#define VIDEO_FORMAT V4L2_PIX_FMT_YUYV
#define BUFFER_COUNT 10
struct fimc_buffer {
int length;
void *start;
} framebuf[BUFFER_COUNT];

int main()
{
int i, ret;

// Open Device
int fd;
fd = open(CAMERA_DEVICE, O_RDWR, 0);
if (fd < 0) {
LOG("Open %s failed\n", CAMERA_DEVICE);
return -1;
}
 




// Query Capability
struct v4l2_capability cap;
ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
if (ret < 0) {
LOG("VIDIOC_QUERYCAP failed (%d)\n", ret);
return ret;
}
// Print capability infomations
LOG("Capability Informations:\n"); 
LOG(" driver: %s\n", cap.driver);
LOG(" card: %s\n", cap.card);
LOG(" bus_info: %s\n", cap.bus_info);
LOG(" version: %08X\n", cap.version);
LOG(" capabilities: %08X\n", cap.capabilities);


// Set Stream Format
struct v4l2_format fmt; 
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = VIDEO_WIDTH;
fmt.fmt.pix.height = VIDEO_HEIGHT;
fmt.fmt.pix.pixelformat = VIDEO_FORMAT;
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
ret = ioctl(fd, VIDIOC_S_FMT, &fmt);
if (ret < 0) 
{
LOG("VIDIOC_S_FMT failed (%d)\n", ret);
return ret;
}
LOG("VIDIOC_S_FMT ok\r\n");
 //memset(&fmt, 0, sizeof(fmt)); 
// Get Stream Format
ret = ioctl(fd, VIDIOC_G_FMT, &fmt);
if (ret < 0) {
LOG("VIDIOC_G_FMT failed (%d)\n", ret);
return ret;
}
// Print Stream Format
LOG("...........................................\r\n");
LOG("Stream Format Informations:\n");
LOG(" type: %d\n", fmt.type);
LOG(" width: %d\n", fmt.fmt.pix.width);
LOG(" height: %d\n", fmt.fmt.pix.height);

char fmtstr[8];
memset(fmtstr, 0, 8);
memcpy(fmtstr, &fmt.fmt.pix.pixelformat, 4);
LOG(" pixelformat: %s\n", fmtstr);
LOG(" field: %d\n", fmt.fmt.pix.field);
LOG(" bytesperline: %d\n", fmt.fmt.pix.bytesperline);
LOG(" sizeimage: %d,\n", fmt.fmt.pix.sizeimage);
LOG(" colorspace: %d\n", fmt.fmt.pix.colorspace);
LOG(" priv: %d\n", fmt.fmt.pix.priv);
LOG(" raw_date: %s\n", fmt.fmt.raw_data);
// Request buffers