Class DenseOpticalFlowBlockPyramid<T extends ImageGray<T>>

java.lang.Object
boofcv.alg.flow.DenseOpticalFlowBlockPyramid<T>
Direct Known Subclasses:
DenseOpticalFlowBlockPyramid.F32, DenseOpticalFlowBlockPyramid.U8

public abstract class DenseOpticalFlowBlockPyramid<T extends ImageGray<T>> extends Object

Computes dense optical flow optical using pyramidal approach with square regions and a locally exhaustive search. Flow estimates from higher layers in the pyramid are used to provide an initial estimate flow lower layers. For each pixel in the 'prev' image, a square region centered around it is compared against all other regions within the specified search radius of it in image 'curr'. For each candidate flow the error is computed. After the best score has been found each local pixel which contributed to that square region is checked. When a pixel is checked its current score compared to see if it's better than the score it was previously assigned (if any) then its flow and score will be set to the current. This improves the handled along object edges. If only the flow is considered when a pixel is the center then it almost always fails at edges.

When scoring hypotheses for optical flow and there is a tie, select the hypothesis with the least amount of motion. This only really comes into play when there is absolutely no texture in real-world data.

By checking all pixels associated with the score and not just the center one to see if it has a better score the edges of objects is handled better.

  • Field Details

    • searchRadius

      protected int searchRadius
    • regionRadius

      protected int regionRadius
    • template

      protected T extends ImageGray<T> template
    • maxError

      protected int maxError
    • flowPrevLayer

      protected ImageFlow flowPrevLayer
    • flowCurrLayer

      protected ImageFlow flowCurrLayer
    • tmp

      protected ImageFlow.D tmp
    • scores

      protected float[] scores
  • Constructor Details

    • DenseOpticalFlowBlockPyramid

      protected DenseOpticalFlowBlockPyramid(int searchRadius, int regionRadius, int maxPerPixelError, Class<T> imageType)
      Configures the search.
      Parameters:
      searchRadius - Determines the size of the area search for matches. area = (2*r + 1)^2
      regionRadius - Radius of the square region
      maxPerPixelError - Maximum error allowed per pixel.
      imageType - Type of image which is being processed.
  • Method Details

    • process

      public void process(ImagePyramid<T> pyramidPrev, ImagePyramid<T> pyramidCurr)
      Computes the optical flow form 'prev' to 'curr' and stores the output into output
      Parameters:
      pyramidPrev - Previous image
      pyramidCurr - Current image
    • findFlow

      protected float findFlow(int cx, int cy, T curr, ImageFlow.D flow)
      Performs an exhaustive search centered around (cx,cy) for the region in 'curr' which is the best match for the template. Results are written into 'flow'
    • checkNeighbors

      protected void checkNeighbors(int cx, int cy, ImageFlow.D flow, ImageFlow image, float score)
      Examines every pixel inside the region centered at (cx,cy) to see if their optical flow has a worse score the one specified in 'flow'
    • extractTemplate

      protected abstract void extractTemplate(int cx, int cy, T prev)
      Extracts a square template from the image 'prev' center at cx and cy
    • computeError

      protected abstract float computeError(int cx, int cy, T curr)
      Computes the error between the template and a region in 'curr' centered at cx,cy
    • getOpticalFlow

      public ImageFlow getOpticalFlow()
      Returns the found optical flow
    • getSearchRadius

      public int getSearchRadius()
    • getRegionRadius

      public int getRegionRadius()