Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

opticalFlowLKDoG class

Estimate optical flow using Lucas-Kanade derivative of Gaussian method

Description

Estimate the direction and speed of a moving object from one image or video frame to another using the Lucas-Kanade derivative of Gaussian (DoG) method.

Construction

opticFlow = opticalFlowLKDoG returns an optical flow object that is used to estimate the direction and speed of an object’s motion. opticalFlowLKDoG uses the Lucas-Kanade method and a derivative of Gaussian (DoG) filter for temporal smoothing.

opticFlow = opticalFlowLKDoG(Name,Value) includes additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'NumFrames',3

expand all

Number of buffered frames for temporal smoothing, specified as the comma-separated pair consisting of 'NumFrames' and a positive integer-valued scalar. The more you increase this number, the less an object’s abrupt movement affects the optical flow calculation. The amount of delay in flow estimation depends on the value of NumFrames. The output flow corresponds to the image at tflow=(tcurrent(NumFrames1)/2), where tcurrent is the time of the current image.

Standard deviation for image smoothing filter, specified as the comma-separated pair consisting of 'ImageFilterSigma' and a positive scalar.

Standard deviation for gradient smoothing filter, specified as the comma-separated pair consisting of 'GradientFilterSigma' and a positive scalar.

Threshold for noise reduction, specified as the comma-separated pair consisting of 'NoiseThreshold' and a positive scalar. As you increase this number, the less an object’s movement impacts the optical flow calculation.

Methods

estimateFlowEstimate optical flow
resetReset the internal state of the object

Examples

expand all

Read in a video file.

vidReader = VideoReader('viptraffic.avi');

Create optical flow object.

opticFlow = opticalFlowLKDoG('NumFrames',3);

Estimate the optical flow of the objects and display the flow vectors.

   while hasFrame(vidReader)
     frameRGB = readFrame(vidReader);
     frameGray = rgb2gray(frameRGB);
     
     flow = estimateFlow(opticFlow,frameGray); 
     
     imshow(frameRGB); 
     hold on;
     plot(flow,'DecimationFactor',[5 5],'ScaleFactor',25);
     hold off; 
   end

Algorithms

expand all

To compute the optical flow between two images, you must solve the following optical flow constraint equation:

Ixu+Iyv+It=0

.

  • Ix, Iy, and It are the spatiotemporal image brightness derivatives.

  • u is the horizontal optical flow.

  • v is the vertical optical flow.

References

[1] Barron, J.L., D.J. Fleet, S.S. Beauchemin, and T.A. Burkitt. Performance of optical flow techniques. CVPR, 1992.

Extended Capabilities

Introduced in R2015a