public abstract class HornSchunck<T extends boofcv.struct.image.ImageBase,D extends boofcv.struct.image.ImageBase>
extends java.lang.Object
This is Horn-Schunck's well known work [1] for dense optical flow estimation. It is based off the following equation Ex*u + Ey*v + Et = 0, where (u,v) is the estimated flow for a single pixel, and (Ex,Ey) is the pixel's gradient and Et is the grave in intensity value. It is assumed that each pixel maintains a constant intensity and that changes in flow are smooth. This implementation is faithful to the original work and does not make any effort to improve its performance using more modern techniques.
[1] Horn, Berthold K., and Brian G. Schunck. "Determining optical flow." 1981 Technical Symposium East. International Society for Optics and Photonics, 1981.
| Modifier and Type | Field and Description |
|---|---|
protected float |
alpha2 |
protected ImageFlow |
averageFlow |
protected D |
derivT |
protected D |
derivX |
protected D |
derivY |
protected int |
numIterations |
protected boolean |
resetOutput |
| Constructor and Description |
|---|
HornSchunck(float alpha,
int numIterations,
boofcv.struct.image.ImageType<D> derivType)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
borderAverageFlow(ImageFlow flow,
ImageFlow averageFlow)
Computes average flow using an 8-connect neighborhood for the image border
|
protected static void |
computeBorder(ImageFlow flow,
ImageFlow averageFlow,
int x,
int y) |
protected abstract void |
computeDerivT(T image1,
T image2,
D derivT) |
protected abstract void |
computeDerivX(T image1,
T image2,
D derivX) |
protected abstract void |
computeDerivY(T image1,
T image2,
D derivY) |
protected abstract void |
findFlow(D derivX,
D derivY,
D derivT,
ImageFlow output)
Inner function for computing optical flow
|
protected static ImageFlow.D |
getExtend(ImageFlow flow,
int x,
int y) |
protected static void |
innerAverageFlow(ImageFlow flow,
ImageFlow averageFlow)
Computes average flow using an 8-connect neighborhood for the inner image
|
void |
process(T image1,
T image2,
ImageFlow output)
Computes dense optical flow from the first image's gradient and the difference between
the second and the first image.
|
void |
setNumIterations(int numIterations)
changes the maximum number of iterations
|
protected float alpha2
protected int numIterations
protected ImageFlow averageFlow
protected boolean resetOutput
protected D extends boofcv.struct.image.ImageBase derivX
protected D extends boofcv.struct.image.ImageBase derivY
protected D extends boofcv.struct.image.ImageBase derivT
public HornSchunck(float alpha,
int numIterations,
boofcv.struct.image.ImageType<D> derivType)
alpha - Larger values place more importance on flow smoothness consistency over brightness consistency. Try 20numIterations - Number of iterations. Try 1000public void setNumIterations(int numIterations)
numIterations - maximum number of iterationspublic void process(T image1, T image2, ImageFlow output)
image1 - First imageimage2 - Second imageoutput - Found dense optical flowprotected abstract void findFlow(D derivX, D derivY, D derivT, ImageFlow output)
protected static void innerAverageFlow(ImageFlow flow, ImageFlow averageFlow)
protected static void borderAverageFlow(ImageFlow flow, ImageFlow averageFlow)
protected static void computeBorder(ImageFlow flow, ImageFlow averageFlow, int x, int y)
protected static ImageFlow.D getExtend(ImageFlow flow, int x, int y)