Class DisparityBlockMatchRowFormat<Input extends ImageBase<Input>,Disparity extends ImageGray<Disparity>>

java.lang.Object
boofcv.alg.disparity.DisparityBlockMatchRowFormat<Input,Disparity>
Direct Known Subclasses:
DisparityBlockMatch, DisparityBlockMatchBestFive

public abstract class DisparityBlockMatchRowFormat<Input extends ImageBase<Input>,Disparity extends ImageGray<Disparity>> extends Object

Base class for all dense stereo disparity score algorithms whose score's can be processed by DisparitySelect. The scores for all possible disparities at each pixel is computed for an entire row at once. Then DisparitySelect is called to process this score.

Score Format: The index of the score for column i ≥ radiusX + minDisparity at disparity d is:
index = imgWidth*(d-minDisparity-radiusX) + i - minDisparity-radiusX
Format Comment:
This ordering is a bit unnatural when searching for the best disparity, but reduces cache misses when writing. Performance boost is about 20%-30% depending on max disparity and image size.

  • Field Details

    • disparityMin

      protected int disparityMin
    • disparityMax

      protected int disparityMax
    • disparityRange

      protected int disparityRange
    • widthDisparityBlock

      protected int widthDisparityBlock
    • radiusX

      protected int radiusX
    • radiusY

      protected int radiusY
    • regionWidth

      protected int regionWidth
    • regionHeight

      protected int regionHeight
    • growBorderL

      protected GrowBorder<Input extends ImageBase<Input>,Object> growBorderL
    • growBorderR

      protected GrowBorder<Input extends ImageBase<Input>,Object> growBorderR
    • catastrophicReset

      public int catastrophicReset

      To speed up computations a rolling sum is performed where it subtracts the old row then adds the new row from the score sum. Every time you update the sum noise is added. When disparity values get small then this error becomes noticeable and can lead to drastically incorrect answers. This is known as catastrophic cancellation. To fix this issue, the sum is recomputed from scratch every N rows.

      NOTE: Under nominal situations this won't be noticeable. A specialized performance benchmark where a flat plane was moved away from the camera is where it was first noticed and only when very far away. How bad the errors are also depends on the error distribution. This only affects floating point scores. CENSUS has integer scores and is unaffected.

      The value below was determined empirically in a test scenario. Set to 1 to always run.

  • Constructor Details

    • DisparityBlockMatchRowFormat

      protected DisparityBlockMatchRowFormat(int regionRadiusX, int regionRadiusY, ImageType<Input> imageType)
      Configures disparity calculation.
      Parameters:
      regionRadiusX - Radius of the rectangular region along x-axis.
      regionRadiusY - Radius of the rectangular region along y-axis.
  • Method Details

    • setBorder

      public void setBorder(ImageBorder<Input> border)
    • configure

      public void configure(int disparityMin, int disparityRange)
      Configures the disparity search
      Parameters:
      disparityMin - Minimum disparity that it will check. Must be ≥ 0 and < maxDisparity
      disparityRange - Number of possible disparity values estimated. The max possible disparity is min+range-1.
    • process

      public void process(Input left, Input right, Disparity disparity, @Nullable @Nullable GrayF32 score)
      Computes disparity between two stereo images
      Parameters:
      left - Left rectified stereo image. Input
      right - Right rectified stereo image. Input
      disparity - Disparity between the two images. Output
      score - Optional storage for best fit score
    • _process

      public abstract void _process(Input left, Input right, Disparity disparity, @Nullable @Nullable GrayF32 score)
      Inner function that computes the disparity.
    • getInputType

      public abstract ImageType<Input> getInputType()
    • getDisparityType

      public abstract Class<Disparity> getDisparityType()
    • getBorderX

      public int getBorderX()
    • getBorderY

      public int getBorderY()
    • getMaxRegionError

      public int getMaxRegionError()
      The maximum possible error for the region
    • getMaxPerPixelError

      protected abstract int getMaxPerPixelError()