How come opticalFlowLK works on 1 frame?

조회 수: 17 (최근 30일)
kuku hello
kuku hello 2022년 3월 27일
편집: Aishwarya 2023년 10월 30일
I wanted to try and calculate for two frames the built in optical flow using Lucas Kanade algorithm and compare it to my simple implementation of the LK algorithm. So I used the opticalFlowLK function like so:
opticFlow = opticalFlowLK("NoiseThreshold",0.009);
flow = estimateFlow(opticFlow,img1);
Then I plotted the flow variable on the image as explained in the documentray and it worked amazingly well. But here is the thing, what I wrote above is the whole code.
Variable img1 consist of one gray image matrix and nothing else. Lucas Kanade algorithm suppose to work on 2 consecutive frames at least in order to calculate the time derivative! It is also says that in the documentray. HOW DID IT WORK? How does the algorithm can tell if there is any movement at all based on 1 frame?! I don't understand. Can someone help me please?

답변 (1개)

Aishwarya
Aishwarya 2023년 10월 30일
편집: Aishwarya 2023년 10월 30일
Hi,
As per my understanding, you wish to understand on why “estimateFlow” function only requires one image to calculate optical flow, when the algorithm requires two consecutive frames.
In the provided example code, an optical flow object named "opticFlow" is created using the "opticalFlowLK" function before using the "estimateFlow" method.
opticFlow = opticalFlowLK("NoiseThreshold",0.009);
flow = estimateFlow(opticFlow,img1);
This optical flow object, "opticFlow," stores the information of the previous image that is passed through the "estimateFlow" function. When the "img1" image is passed through the "estimateFlow" function, the resulting "flow" output provides the optical flow between the previous frame passed through the "estimateFlow" function and the current frame "img1."
When the optical flow object is used for first time, the previous frame is initialized with uniform image having intensity value 0.
Please refer to MathWorks documentations below for more information about the functions:
I hope this helps!

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by