title: How to disable Buffer in OpenCV Camera?
body: <p>I have this situation where I use OpenCV to detect faces in front of the camera and do some ML on those faces. The issue that I have is that once I do all the processing, and go to grab the next frame I get the past, not the present. Meaning, I'll read whats inside the buffer, and not what is actually in front of the camera. Since I don't care which faces came in front of the camera while processing, I care what is now in front of the camera.</p>
  
  <p>I did try to set the buffer size to <code>1</code>, and that did help quite a lot, but I still will get at least 3 buffer reads. Setting the FPS to 1, also dose not help remove this situation 100%. Bellow is the flow that I have.</p>
  
  
  
  <pre><code>let cv = require('opencv4nodejs');
  
  let camera = new cv.VideoCapture(camera_port);
  
  camera.set(cv.CAP_PROP_BUFFERSIZE, 1);
  camera.set(cv.CAP_PROP_FPS, 2);
  camera.set(cv.CAP_PROP_POS_FRAMES , 1);
  
  function loop()
  {
      //
      //  &lt;&gt;&gt; Grab one frame from the Camera buffer.
      //
      let rgb_mat = camera.read();
  
      //  Do to gray scale
  
      //  Do face detection
  
      //  Crop the image
  
      //  Do some ML stuff
  
      //  Do whats needs to be done after the results are in.
  
      //
      //  &lt;&gt;&gt; Release data from memory
      //
      rgb_mat.release();
  
      //
      //  &lt;&gt;&gt; Restart the loop
      //
      loop();
  }
  </code></pre>
  
  <h1>My question is:</h1>
  
  <p>Is it possible to remove the buffer all-together? And if so, how. If not, a <code>why</code> would be much appreciated.</p>