All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel Glöckner" <daniel-gl@gmx.net>
To: Elvis Chen <chene77@hotmail.com>
Cc: video4linux-list@redhat.com
Subject: Re: newbie programming help:  grabbing image(s) from /dev/video0, example code?
Date: Sun, 2 Mar 2008 00:48:21 +0100	[thread overview]
Message-ID: <20080301234821.GA1691@daniel.bse> (raw)
In-Reply-To: <BAY122-W46E61F0928F2E422B22355AA150@phx.gbl>

On Sat, Mar 01, 2008 at 09:33:08PM +0000, Elvis Chen wrote:
> We have 2 Hauppauge WInTV PVR-150 installed on a ubuntu 7.10 x86_64 machine.
> They appear to the linux as /dev/video0 and /dev/video1, respectively.

On this card video0 and video1 are for MPEG captures.
Use video32 and video33 for YUV captures.

The only possible YUV format is 4:2:0 with rearranged bytes.
Read Documentation/video4linux/cx2341x/README.hm12.

> My first attempt was to find a small/simple API to access the linux/video device.

No need to find another API, V4L2 is small enough:

#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>

static unsigned char image[720*480*3/2];

int main()
{
  struct v4l2_format vf;
  int i=1,fd=open("/dev/video32",O_RDWR);
  ioctl(fd,VIDIOC_S_INPUT,&i);
  memset(&vf,0,sizeof(vf));
  vf.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
  vf.fmt.pix.width=720;
  vf.fmt.pix.height=480;
  vf.fmt.pix.pixelformat=V4L2_PIX_FMT_HM12;
  vf.fmt.pix.field=V4L2_FIELD_INTERLACED;
  vf.fmt.pix.bytesperline=vf.fmt.pix.width;
  ioctl(fd,VIDIOC_S_FMT,&vf);
  write(1,image,read(fd,image,sizeof(image)));
  return 0;
}

You may want to insert some error checks :-)
And if you want better performance, use memory mapped I/O.

  Daniel

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  parent reply	other threads:[~2008-03-01 23:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-01 21:33 newbie programming help: grabbing image(s) from /dev/video0, example code? Elvis Chen
2008-03-01 22:21 ` Carl Karsten
2008-03-01 22:49 ` question Michael Williamson
2008-03-02  0:24   ` question Daniel Glöckner
2008-03-01 23:48 ` Daniel Glöckner [this message]
2008-03-03 20:09   ` newbie programming help: grabbing image(s) from /dev/video0, example code? Elvis Chen
2008-09-29 20:58   ` Elvis Chen
2008-09-30 12:45     ` Daniel Glöckner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080301234821.GA1691@daniel.bse \
    --to=daniel-gl@gmx.net \
    --cc=chene77@hotmail.com \
    --cc=video4linux-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.