V4L2 and Aptina sensor with external trigger - discard old footage

I am using Aptina MT9V024 sensor connected via LVDS to CSI i.MX6 Quad interface. I run the sensor in snapshot mode i.e. Using an external signal to trigger / trigger image capture.

On the software side, I am running Yocto Linux and an application written in C that needs to fetch the captured image data.

It works like this (part of the code, executed in a loop):

// wait until camers is triggered
ret = select(video_fd + 1, &fds, NULL, NULL, &tv);

// dq buffer / read image data and save to disk
ret = xioctl(video_fd, VIDIOC_DQBUF, &v4l2buf);
img->imageData = buffers[v4l2buf.index].start;
cvSaveImage(filename, img, 0);

// enqueue another buffer to capture next frame
ret = xioctl(video_fd, VIDIOC_QBUF, &v4l2buf);

      

The call is select(...)

blocked until a new frame is available, i.e. the camera was called.

My problem: The resulting image is one from a previous capture. During init, I ask for two buffers because the sensor doesn't start with less. But after selecting select (...), I cannot DQBUF more than one buffer. So, I am always stuck with the old frame.

What works is not the buffer I receive DQBUF, but the "other" buffer, i.e. instead of buffers[v4l2buf.index]

instead buffers[v4l2buf.index]

use buffers[v4l2buf.index]

in the above line. But I suppose this is not a very reliable way, as I am accessing a buffer which, according to the v4l2 API, is not readable (but it actually contains the data I want).

+3


source to share





All Articles