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

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;
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.