I can't understand how Matlab calculates the velocity matrix of a video frame by Optical Flow using just the current frame. The velocity wouldn't be a relation of different pixels position varying in the time what would include the analysis of two frame or more per time?
http://www.mathworks.com/help/vision/ref/vision.opticalflow-class.html
% Set up for stream
nFrames = 0;
while (nFrames<100) % Process for the first 100 frames.
% Acquire single frame from imaging device.
rgbData = step(vidDevice);
% Compute the optical flow for that particular frame.
optFlow = step(optical,rgb2gray(rgbData)); %***HERE IS THE DOUBT! iT JUST USES ONE FRAME!!!***
% Downsample optical flow field.
optFlow_DS = optFlow(r, c);
H = imag(optFlow_DS)*50;
V = real(optFlow_DS)*50;
% Draw lines on top of image
lines = [Y(:)'; X(:)'; Y(:)'+V(:)'; X(:)'+H(:)'];
rgb_Out = step(shapes, rgbData, lines');
% Send image data to video player
% Display original video.
step(hVideoIn, rgbData);
% Display video along with motion vectors.
step(hVideoOut, rgb_Out);
% Increment frame count
nFrames = nFrames + 1;
end
stepfunction does. But just at lookign at the code, it looks like it gets the next frame? because to obtainrgbdatathe code usesstep, and in the next line it usesstepagain, so my guess is that that line captures the next frame and computes the optical flow together - Ander Biguri