Class DenseOpticalFlowBlockPyramid<T extends ImageGray<T>>
- Direct Known Subclasses:
DenseOpticalFlowBlockPyramid.F32
,DenseOpticalFlowBlockPyramid.U8
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.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected ImageFlow
protected ImageFlow
protected int
protected int
protected float[]
protected int
protected T
protected ImageFlow.D
-
Constructor Summary
ModifierConstructorDescriptionprotected
DenseOpticalFlowBlockPyramid
(int searchRadius, int regionRadius, int maxPerPixelError, Class<T> imageType) Configures the search. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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'protected abstract float
computeError
(int cx, int cy, T curr) Computes the error between the template and a region in 'curr' centered at cx,cyprotected abstract void
extractTemplate
(int cx, int cy, T prev) Extracts a square template from the image 'prev' center at cx and cyprotected 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.Returns the found optical flowint
int
void
process
(ImagePyramid<T> pyramidPrev, ImagePyramid<T> pyramidCurr) Computes the optical flow form 'prev' to 'curr' and stores the output into output
-
Field Details
-
searchRadius
protected int searchRadius -
regionRadius
protected int regionRadius -
template
-
maxError
protected int maxError -
flowPrevLayer
-
flowCurrLayer
-
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)^2regionRadius
- Radius of the square regionmaxPerPixelError
- Maximum error allowed per pixel.imageType
- Type of image which is being processed.
-
-
Method Details
-
process
Computes the optical flow form 'prev' to 'curr' and stores the output into output- Parameters:
pyramidPrev
- Previous imagepyramidCurr
- Current image
-
findFlow
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
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
Extracts a square template from the image 'prev' center at cx and cy -
computeError
Computes the error between the template and a region in 'curr' centered at cx,cy -
getOpticalFlow
Returns the found optical flow -
getSearchRadius
public int getSearchRadius() -
getRegionRadius
public int getRegionRadius()
-