v4l2 very simple example

Alex Ivasyuv picture Alex Ivasyuv · Oct 24, 2010 · Viewed 40.1k times · Source

I'm looking for a simple example for camera access in Linux using V4L2. Where I can find it? As simple, as possible.

Thanks,

Answer

Raulp picture Raulp · May 17, 2012

Try the uvccapture code here -> http://staticwave.ca/source/uvccapture/ It is very small yet very concrete example which makes use of all the V4l2 concepts (open,set format, allocate memory, Request Buffer, Dqbuffer and Query-buffer - all intems of ioclts).

uvcgrab() function is the one to look for which makes use of Dqbuffer and Query-buffer.

ioctl (vd->fd, VIDIOC_DQBUF, &vd->buf);

ioctl (vd->fd, VIDIOC_QBUF, &vd->buf)

While Studying it you can keep looking for the ioctl definition in this link which will ease your understanding.