Can optical flow farneback method work for a single frame?

4 次查看(过去 30 天)
Hi
The description of this function says it can estimate moving objects in a video. Does that mean it needs at least 2 frames? I tried with a single frame, still got some results. I'm not sure if that's correct or what that means. Any explanation would be helpful.

采纳的回答

Gayathri
Gayathri 2025-6-2
Your guess is right. Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera. So, by definition we need more than one frame. This concept only comes into picture for a video.
And the reason why the function works for a single frame is because when estimating the flow, we always have to pass the first frame before passing in the second frame (This can be seen in the code below). So, when passing in the first frame there is no previous frame it still records it for future frames. There it calculates the optical flow with an all zero frame.
while hasFrame(vidReader)
frameRGB = readFrame(vidReader);
frameGray = im2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',2,'Parent',hPlot);
hold off
pause(10^-3)
end
So, it does not make any sense of the output which we get once one single frame is passed. We always need multiple frames in a video. For one frame there is no motion of objects and hence, no concept of optical flow.
The above code which is provided is from the below documentation link.
Hope this answers your question.

更多回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by