웹캠 캡쳐 영상이 까맣게 나오는 이유?

nobaem의 이미지

ov511+ 칩셋을 쓰는 omnieye 웹캠으로 실행했을 때는 잘 캡쳐되던 프로그램입니다.
하지만 로지텍 퀵캠 connect로 실행하면 화면이 까맣게 나온게 캡쳐 되네요.
소스 올리겠습니다.
혹시 아시는 분 있으면 가르쳐 주시면 진정 정말 감사드리겠습니다.

#include "takepic.h"

int main(int argc, char *argv[])
{
if((m_buf_size = v4l_init(VIDEOFILE)) <= 0)
{
return 0;
}
else
{
if(!v4l_capture())
{
return -1;
}
printf("v4l_capture success\n");
}

return 0;
}

// v4l initialize
int v4l_init(char *argv)
{
struct video_capability cap;
struct video_channel chan;
struct video_window win;
struct video_picture pic;
struct video_mbuf m_buf;

printf("v4l_init()\n");
printf("argv = %s\n", argv);

if(argv == NULL)
{
printf("please input video device");
return 0;
}

if((fd = open(argv,O_RDONLY)) < 0)
{
printf("Video device could not be opened");
return 0;
}
printf("fd = %d\n", fd);

if((result = ioctl(fd,VIDIOCGCAP,&cap)) < 0)
{
printf("ioctl on VIDIOCGCAP failed");
return 0;
}

chan.channel = 0;

if((result = ioctl(fd,VIDIOCGCHAN,&chan)) < 0)
{
printf("***ioctl on VIDICGCHAN failed***");
return 0;
}

chan.flags = 0;
chan.type = VIDEO_TYPE_CAMERA;
chan.norm = VIDEO_MODE_NTSC;

if((result = ioctl(fd,VIDIOCGCHAN,&chan)) < 0)
{
printf("===ioctl on VIDIOCGCHAN failed===");
return 0;
}

win.width = WIDTH;
win.height = HEIGHT;
win.x = win.y = win.chromakey = win.flags = 0;

if((result = ioctl(fd,VIDIOCGWIN,&win)) < 0)
{
printf("ioctl on VIDIOCGWIN failed");
return 0;
}

if((result = ioctl(fd,VIDIOCGPICT,&pic)) < 0)
{
printf("ioctl on VIDIOCGPICT failed");
return 0;
}

pic.brightness = pic.contrast = pic.hue = pic.colour = pic.whiteness = 32767;
pic.palette = VIDEO_PALETTE_YUV420P;
pic.depth = DEPTH;

if((result = ioctl(fd,VIDIOCSPICT,&pic)) < 0)
{
printf("Failed to set the image properities");
return 0;
}

if((result = ioctl(fd,VIDIOCGMBUF,&m_buf)) < 0)
{
printf("ioctl on VIDIOCGMBUF failed");
return 0;
}

image_buffer = (unsigned char*)mmap(0,m_buf.size,PROT_READ,MAP_SHARED,fd,0);

if(image_buffer == MAP_FAILED)
{
printf("mmap failed");
return 0;
}

v_map.frame = 0;
v_map.height = HEIGHT;
v_map.width = WIDTH;
v_map.format = VIDEO_PALETTE_YUV420P;

return m_buf.size;
}

int v4l_capture()
{
FILE *fp;
int fc;

printf("v4l_capture()\n");
printf("fd = %d\n", fd);

if((result = ioctl(fd,VIDIOCMCAPTURE,&v_map)) < 0)
{
printf("ioctl on VIDIOCMCAPTURE failed");
return 0;
}

if((result = ioctl(fd,VIDIOCSYNC,&v_map)) < 0)
{
printf("ioctl on VIDIOCSYNC failed");
return 0;
}

fp = fopen("file.ppm", "wb");
if(fp == NULL)
{
printf("fopen failed\n");
return 0;
}

fprintf(fp, "P5\n%d %d\n%d\n", WIDTH, HEIGHT, DEPTH);
fc = fwrite(image_buffer, sizeof(char), m_buf_size, fp);

fclose(fp);

return 1;
}