public abstract class DenseOpticalFlowBlockPyramid<T extends boofcv.struct.image.ImageGray>
extends java.lang.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.
| Modifier and Type | Class and Description |
|---|---|
static class |
DenseOpticalFlowBlockPyramid.F32
Implementation for
GrayF32 |
static class |
DenseOpticalFlowBlockPyramid.U8
Implementation for
GrayU8 |
| Modifier and Type | Field and Description |
|---|---|
protected ImageFlow |
flowCurrLayer |
protected ImageFlow |
flowPrevLayer |
protected int |
maxError |
protected int |
regionRadius |
protected float[] |
scores |
protected int |
searchRadius |
protected T |
template |
protected ImageFlow.D |
tmp |
| Constructor and Description |
|---|
DenseOpticalFlowBlockPyramid(int searchRadius,
int regionRadius,
int maxPerPixelError,
java.lang.Class<T> imageType)
Configures the search.
|
| Modifier and Type | Method and Description |
|---|---|
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'
|
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
|
protected abstract void |
extractTemplate(int cx,
int cy,
T prev)
Extracts a square template from the image 'prev' center at cx and cy
|
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.
|
ImageFlow |
getOpticalFlow()
Returns the found optical flow
|
int |
getRegionRadius() |
int |
getSearchRadius() |
void |
process(boofcv.struct.pyramid.ImagePyramid<T> pyramidPrev,
boofcv.struct.pyramid.ImagePyramid<T> pyramidCurr)
Computes the optical flow form 'prev' to 'curr' and stores the output into output
|
protected int searchRadius
protected int regionRadius
protected T extends boofcv.struct.image.ImageGray template
protected int maxError
protected ImageFlow flowPrevLayer
protected ImageFlow flowCurrLayer
protected ImageFlow.D tmp
protected float[] scores
public DenseOpticalFlowBlockPyramid(int searchRadius,
int regionRadius,
int maxPerPixelError,
java.lang.Class<T> imageType)
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.public void process(boofcv.struct.pyramid.ImagePyramid<T> pyramidPrev, boofcv.struct.pyramid.ImagePyramid<T> pyramidCurr)
pyramidPrev - Previous imagepyramidCurr - Current imageprotected float findFlow(int cx,
int cy,
T curr,
ImageFlow.D flow)
protected void checkNeighbors(int cx,
int cy,
ImageFlow.D flow,
ImageFlow image,
float score)
protected abstract void extractTemplate(int cx,
int cy,
T prev)
protected abstract float computeError(int cx,
int cy,
T curr)
public ImageFlow getOpticalFlow()
public int getSearchRadius()
public int getRegionRadius()