如何获得光流场的速度和幅度向量?我正在使用 Lucas-Kande 光流法

How to obtain velocity and magnitude vectors of the optical flow field? I am using Lucas-Kande method of optical flow

我正在编写以下代码。

n=0;

folder = fileparts(which('viptraffic.avi'));

movieFullFileName = fullfile(folder, 'viptraffic.avi');

vidReader = VideoReader(movieFullFileName);

opticFlow = opticalFlowLK('NoiseThreshold',0.0039);

while hasFrame(vidReader)

   frameRGB = readFrame(vidReader);

   frameGray = rgb2gray(frameRGB);

   flow = estimateFlow(opticFlow,frameGray); 

   H=imag(flow)

   V=real(flow)

    frameWithFlow = getframe(gca);

    imshow(frameRGB);

    imshow(frameWithFlow.cdata)

    hold on

    plot(flow,'DecimationFactor',[5 5], 'ScaleFactor',10)

    hold off

    n=n+1;

end

有没有办法获得每幅图像中获得的每个光流场的速度和大小的光流估计值?

estimateFlow returns 一个 opticalFlow 对象,它具有大小、相位和速度的属性。所以,在你的例子中,flow 是一个 opticalFlow 对象,而不是一个复杂的数组,你不能将它传递给 realimag。相反,使用对象的属性:

flow.Vx          % x component of velocity
flow.Vy          % y component of velocity
flow.Orientation % Phase
flow.Magnitude   % Magnitude