OpticalFlowPyrLK
The OpticalFlowPyrLK operator is used to calculate the changes of specific pixel points in consecutive multi-frame images, which is commonly used in scenarios such as target feature point tracking and improving BOX stability.
Operator Effect
Principle
The sparse optical flow algorithm, known as the Lucas-Kanade algorithm, is a motion estimation method commonly used in computer vision to estimate the direction and speed of motion of pixels in an image sequence. The Lucas-Kanade algorithm is based on two assumptions:
-
Brightness constancy assumption: the brightness of pixels of the same object remains constant over a short period of time.
Assuming that the object located at pixel position at time is located at position at time , based on the assumption of brightness invariance we have.
A first-order Taylor expansion of the right-hand side of the equation yields:
It can be obtained from the above two equations:
The collation can be expressed as:
Among them, and are the partial derivatives of the image luminance in the direction and the direction at the pixel point, respectively, the gradient of the image in the and directions. is the Brightness difference of the coordinate positions.
-
Neighborhood optical flow similarity assumption: the direction and size of pixel movement in a small image region is essentially the same.
With the help of this assumption, all pixels in the field of pixel point have the following equation.
The above equation, which is of the form , leads to a least squares solution for the optical flow vector:
One of the requirements is that is invertible, and in order to fulfill this requirement, the Lucas-Kanade method selects corner points as feature points. In addition to being based on the luminance invariance assumption and the neighborhood optical flow similarity assumption, the Lucas-Kanade algorithm solves for the case of large image offsets with the help of image pyramids, where large offsets become small offsets on high-level low-resolution images, thus solving for the optical flow.
Therefore, the OpticalFlowPyrLK operator requires the pyramid layers of the previous and current frames, as well as the feature points of the previous frame as input, where the feature points are usually chosen to be corner points.
API Interface
For detailed interface information, please refer to hbVPOpticalFlowPyrLK.


