title: OpenCV: Filter multiple frames in real time
body: <p>I'm trying to filter the same point through multiple frames. Basically, I want to take a single pixel (say at position (0,0)) and run a filter at that position across multiple frames. </p>
  
  <p>I'm getting a frame (type Mat) from the webcam. I want to buffer about 30 frames from the camera, and make vectors that represent the same position for those 30 frames. For example, if the input is 640x480 @ 30fps. I want to have 640x480=307,200 vectors that are 30 points long. In MATLAB, this would basically be a matrix of vectors (3D matrix), where each vector is 30 elements long. I want this so that I can apply temporal filters for each pixel.</p>
  
  <p>I think I need to make a 3D Mat (CvMatND) with 30 dimensions. Then I will put each new frame into the a new dimension until my matrix is 640x480x30. Then I can filter the vectors</p>
  
  <p>(0, 0, :)</p>
  
  <p>(0, 1, :)</p>
  
  <p>(0, 2, :)</p>
  
  <p>...</p>
  
  <p>(640, 480, :)</p>
  
  <p>Once I've applied the filter to each vector, I will have 30 frames of video to output.</p>
  
  <p>My question is what is the best way to buffer 30 frames? Once I have the 30 frames, what is the best way to apply a filter (say a low pass filter) to each pixel?</p>
  
  <p>Thanks for your help.</p>