【问题标题】:Calculate object's velocity in video frames - Optical Flow (Matlab)计算视频帧中物体的速度 - 光流(Matlab)
【发布时间】:2016-05-05 14:15:36
【问题描述】:

我无法理解 Matlab 如何使用 当前帧通过光流计算视频帧的速度矩阵。速度不会是不同的像素位置随时间而变化什么会包括每次分析两帧或更多帧?

http://www.mathworks.com/help/imaq/examples/live-motion-detection-using-optical-flow.html?requestedDomain=www.mathworks.com

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

【问题讨论】:

  • 我想这取决于step 函数的作用。但只是看看代码,它看起来像是得到了下一帧?因为要获得rgbdata,代码使用step,而在下一行它再次使用step,所以我的猜测是该行捕获下一帧并一起计算光流

标签: matlab computer-vision matlab-cvst opticalflow


【解决方案1】:

vision.OpticalFlow 是一个类。当您创建一个vision.OpticalFlow 对象并调用它的step 方法时,它会记住您传递给它的帧。然后在每次对step 的后续调用中,它都会计算上次调用的存储帧与当前帧之间的光流。

顺便说一句,vision.OpticalFlow 已被弃用。如果您有最新版本的 MATLAB,则可以使用一系列光流函数:opticalFlowFarnebackopticalFlowHSopticalFlowLKopticalFlowLKDoG

【讨论】:

  • 非常感谢您的帮助!我一定会尝试这两种方法来检查它在我的实际项目中是如何工作的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-25
  • 1970-01-01
  • 2013-03-25
  • 2013-04-15
  • 1970-01-01
相关资源
最近更新 更多