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

时间:2016-03-11 18:33:17

标签: matlab image-processing computer-vision matlab-cvst opticalflow

我正在处理以下代码。

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

是否有办法获得每张图像中获得的每个光流场的光流估计速度和幅度?

1 个答案:

答案 0 :(得分:3)

estimateFlow会返回opticalFlow个对象,该对象具有幅度,相位和速度属性。因此,在您的情况下,flowopticalFlow对象,而不是复杂数组,您无法将其传递给realimag。而是使用对象的属性:

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