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
c embedded-linux v4l2 imx6


source to share


No one has answered this question yet

Check out similar questions:

nine
Capturing multiple webcams (uvcvideo) with OpenCV on Linux
4
v4l2 Python - streaming video - display buffers
4
Capturing camera image with v4l2 is very slow
3
Is v4l2 camera capture with MMAP ring buffer to track application
2
V4L2 systematic frame displacement
2
How to capture and process each frame of an image using the CImg library?
1
Reading an I2C register with regmap_read () but getting constant values
1
Setting frame rate on Logitech C210 webcam in C ++ on a raspberry pi using v4l2
1
How do you process individual footage in V4L2 live from the camera?
0
V4L2 Framerate Drops



All Articles
Loading...
X
Show
Funny
Dev
Pics