title: OpenCV VideoCapture buffer and read time
body: <p>I am trying to read images from an USB camera 8Mp with <code>VideoCapture</code> in Python using <code>cap.read()</code>. Time is really critical.</p>
  
  <p>There is an internal buffer in openCV of 5 frames, so when an image is requested, I have to make 4 <code>cap.grab()</code> and then one <code>cap.read()</code> to reduce time to its minimum.</p>
  
  <p>In the file <em>cap_libv4l.cpp</em>, there is a variable <code>DEFAULT_V4L_BUFFERS (#define DEFAULT_V4L_BUFFERS 4)</code>. </p>
  
  <p>I changed it and have recompiled OpenCV.  </p>
  
  <p><code>#define DEFAULT_V4L_BUFFERS 0</code> is not allowed, it gives an error. </p>
  
  <p>If I change it to <code>#define DEFAULT_V4L_BUFFERS 1</code>, I just need to make one <code>cap.grab()</code> and one <code>cap.read()</code> but time doesn't reduce. </p>
  
  <p>When you reduce the value of <code>DEFAULT_V4L_BUFFERS</code> then time of <code>cap.read()</code> increase, being the same total time in both cases: buffer size 4 (4 grabs and 1 read) and buffer size 1 (1 grab and 1 read).</p>
  
  <p>Does someone know why this happens? Is there any way to reduce the capture time besides using threads? I tested threads but then I face the "select timeout" problem capturing images.</p>