<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic With sensor in snapshot mode, V4L2 does not allow me to retrieve &amp;quot;fresh&amp;quot; frames in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/With-sensor-in-snapshot-mode-V4L2-does-not-allow-me-to-retrieve/m-p/686743#M106288</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Camera:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Aptina MT9V024&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BSP / OS:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;root@phyboard-mira-imx6-3:~# lsb_release -a&lt;BR /&gt;Distributor ID: Yogurt&lt;BR /&gt;Description: Yogurt GNU/Linux i.MX6-PD15.3.0 (fido)&lt;BR /&gt;Release: i.MX6-PD15.3.0&lt;BR /&gt;Codename: fido&lt;BR /&gt;root@phyboard-mira-imx6-3:~# uname -a&lt;BR /&gt;Linux phyboard-mira-imx6-3 4.1.18-i.MX6-PD15.3.0 #1 SMP Thu Mar 31 19:45:37 CEST 2016 armv7l GNU/Linux&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setup:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm using the external Trigger input on the Sensor (snapshot mode), so it is not&amp;nbsp;continuously capturing frames but only when requested to do. I'm using V4L2 to retrieve the frames (this is part of the code that is executed in a loop):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = select(video_fd + 1, &amp;amp;fds, NULL, NULL, &amp;amp;tv);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = xioctl(video_fd, VIDIOC_DQBUF, &amp;amp;v4l2buf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;img-&amp;gt;imageData = buffers[v4l2buf.index].start;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;cvSaveImage(filename, img, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = xioctl(video_fd, VIDIOC_QBUF, &amp;amp;v4l2buf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm retrieving the frames with one frame delay. So triggering the camera at some point A, DQBUF gives me the buffer from the &lt;EM&gt;previous&lt;/EM&gt; capture. But I would like to get it "instant", i.e. select() blocks until the camera is triggered and right then I receive the image data associated with that capture (not the previous one).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I tried:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- I'm allocating 2 buffers during setup, because I cannot allocates less buffers (only more).&lt;/P&gt;&lt;P&gt;- Using&amp;nbsp;&lt;SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;buffers[(v4l2buf.index + 1) % 2].start&lt;/SPAN&gt; instead of&amp;nbsp;&lt;SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;buffers[v4l2buf.index].start&lt;/SPAN&gt; works but it does not look like a reliable solution.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;- I found another question about the same topic[1], but the suggested method does not work for me. Everytime select() returns, I can only DQBUF a single buffer. Trying to DQ a second buffer results in an error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;[1]&amp;nbsp;&lt;A href="https://community.nxp.com/thread/324649"&gt;V4L2 How to capture fresh frame? (i.MX mxc capture , select() with timeout = 0)&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 May 2017 12:19:04 GMT</pubDate>
    <dc:creator>mober</dc:creator>
    <dc:date>2017-05-19T12:19:04Z</dc:date>
    <item>
      <title>With sensor in snapshot mode, V4L2 does not allow me to retrieve "fresh" frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/With-sensor-in-snapshot-mode-V4L2-does-not-allow-me-to-retrieve/m-p/686743#M106288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Camera:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Aptina MT9V024&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BSP / OS:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;root@phyboard-mira-imx6-3:~# lsb_release -a&lt;BR /&gt;Distributor ID: Yogurt&lt;BR /&gt;Description: Yogurt GNU/Linux i.MX6-PD15.3.0 (fido)&lt;BR /&gt;Release: i.MX6-PD15.3.0&lt;BR /&gt;Codename: fido&lt;BR /&gt;root@phyboard-mira-imx6-3:~# uname -a&lt;BR /&gt;Linux phyboard-mira-imx6-3 4.1.18-i.MX6-PD15.3.0 #1 SMP Thu Mar 31 19:45:37 CEST 2016 armv7l GNU/Linux&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setup:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm using the external Trigger input on the Sensor (snapshot mode), so it is not&amp;nbsp;continuously capturing frames but only when requested to do. I'm using V4L2 to retrieve the frames (this is part of the code that is executed in a loop):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = select(video_fd + 1, &amp;amp;fds, NULL, NULL, &amp;amp;tv);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = xioctl(video_fd, VIDIOC_DQBUF, &amp;amp;v4l2buf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;img-&amp;gt;imageData = buffers[v4l2buf.index].start;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;cvSaveImage(filename, img, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ret = xioctl(video_fd, VIDIOC_QBUF, &amp;amp;v4l2buf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm retrieving the frames with one frame delay. So triggering the camera at some point A, DQBUF gives me the buffer from the &lt;EM&gt;previous&lt;/EM&gt; capture. But I would like to get it "instant", i.e. select() blocks until the camera is triggered and right then I receive the image data associated with that capture (not the previous one).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I tried:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- I'm allocating 2 buffers during setup, because I cannot allocates less buffers (only more).&lt;/P&gt;&lt;P&gt;- Using&amp;nbsp;&lt;SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;buffers[(v4l2buf.index + 1) % 2].start&lt;/SPAN&gt; instead of&amp;nbsp;&lt;SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;buffers[v4l2buf.index].start&lt;/SPAN&gt; works but it does not look like a reliable solution.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;- I found another question about the same topic[1], but the suggested method does not work for me. Everytime select() returns, I can only DQBUF a single buffer. Trying to DQ a second buffer results in an error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;[1]&amp;nbsp;&lt;A href="https://community.nxp.com/thread/324649"&gt;V4L2 How to capture fresh frame? (i.MX mxc capture , select() with timeout = 0)&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 May 2017 12:19:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/With-sensor-in-snapshot-mode-V4L2-does-not-allow-me-to-retrieve/m-p/686743#M106288</guid>
      <dc:creator>mober</dc:creator>
      <dc:date>2017-05-19T12:19:04Z</dc:date>
    </item>
  </channel>
</rss>

