ACT-CV - Machine Vision for Cognitive Modeling
|
calculate the optical flow for some points in the image More...
#include <OpticalFlow.h>
Classes | |
class | Particle |
position of an edge in the image More... | |
Public Member Functions | |
OpticalFlow () | |
virtual | ~OpticalFlow () |
void | SetSize (const CvSize &size) |
set the size of images More... | |
void | SetFocus (const CvPoint &focus) |
set the current focus More... | |
void | FocusNotify (const CvPoint &p) |
void | AddImage (IplImage *img) |
add a new image More... | |
void | Calc () |
calculate the flow field More... | |
void | PrintInfo () |
debugging stuff More... | |
double | GetWinkel () |
get the overall angle of the flow field More... | |
void | PrintFlowField (IplImage *img) |
print arrows into img showing the flow More... | |
void | PrintFocus (IplImage *img) |
mark the focus point More... | |
Public Member Functions inherited from FocusObserver | |
virtual | ~FocusObserver () |
Public Member Functions inherited from ReferenceCount | |
ReferenceCount () | |
virtual | ~ReferenceCount () |
void | IncRefCount () |
void | DecRefCount () |
Protected Member Functions | |
void | FreeStatusData () |
free prevFeatures, curFeatures, and featStatus More... | |
virtual int | GetXMin () |
virtual int | GetXMax () |
virtual int | GetYMin () |
virtual int | GetYMax () |
void | MaskUseFullArea () |
void | MaskUseGridCell (int x, int y, int lenX, int lenY) |
void | SelectFeatures () |
use cvGoodFeaturesToTrack More... | |
Protected Attributes | |
RingBuf< GCPointer < ImageHolder >, 2 > | imgBuf |
the current image and its predecessor More... | |
RingBuf< GCPointer < ImageHolder >, 2 > | pyrBuf |
the pyramids More... | |
int | numFeatures |
the number of features to track More... | |
CvPoint2D32f * | prevFeatures |
Positions of the features in the last image. More... | |
CvPoint2D32f * | curFeatures |
Positions of the features in the current image. More... | |
char * | featStatus |
status is true when a feature has been found in the current image More... | |
std::vector< GCPointer < Particle > > | particles |
all the particles More... | |
ExpGlaett< Pos< 2, double > > | focusOfExpansion |
the focus of expansion, exponentially smoothed More... | |
KalmanFilter< 2 > | kalmanFOE |
kalman filter for the focus of expansion More... | |
float | kalmanState [4] |
CvSize | imgSize |
the size of the image More... | |
CvPoint | focus |
the current focus More... | |
int | numCalls |
number of calls to Calc More... | |
GCPointer< ImageHolder > | eigenBuf |
GCPointer< ImageHolder > | tempBuf |
CvMat * | mask |
calculate the optical flow for some points in the image
images must be 8 bit, one channel
Definition at line 74 of file OpticalFlow.h.
OpticalFlow::OpticalFlow | ( | ) |
Definition at line 44 of file OpticalFlow.cpp.
References focusOfExpansion, KalmanFilter< _dims >::InitRandom(), kalmanFOE, and ExpGlaett< _t >::setNeuAnteil().
|
virtual |
Definition at line 56 of file OpticalFlow.cpp.
References RingBuf< _t, len >::Add(), eigenBuf, FreeStatusData(), imgBuf, mask, MHDBGMSG, pyrBuf, and tempBuf.
void OpticalFlow::AddImage | ( | IplImage * | img) |
add a new image
Definition at line 183 of file OpticalFlow.h.
References RingBuf< _t, len >::Add(), and imgBuf.
Referenced by OFlowObs::FrameNotifyGray().
void OpticalFlow::Calc | ( | ) |
calculate the flow field
the actual calculation
Definition at line 365 of file OpticalFlow.cpp.
References curFeatures, featStatus, focus, RingBuf< _t, len >::GetCur(), ImageHolder::GetImage(), RingBuf< _t, len >::GetPrev(), imgBuf, RingBuf< _t, len >::IncIndex(), MHDBGMSG, numCalls, numFeatures, particles, prevFeatures, pyrBuf, and SelectFeatures().
Referenced by OFlowObs::FrameNotifyGray().
|
virtual |
Implements FocusObserver.
Definition at line 178 of file OpticalFlow.h.
References SetFocus().
Referenced by OFlowObs::FocusNotify().
|
protected |
free prevFeatures, curFeatures, and featStatus
The pointers are set to zero afterwards. Therefore this can always be called safely anytime
Definition at line 74 of file OpticalFlow.cpp.
References curFeatures, featStatus, and prevFeatures.
Referenced by SelectFeatures(), SetFocus(), and ~OpticalFlow().
double OpticalFlow::GetWinkel | ( | ) |
get the overall angle of the flow field
Definition at line 173 of file OpticalFlow.cpp.
References TrimmedMean::Add(), TrimmedMean::Compute(), curFeatures, featStatus, focus, focusOfExpansion, ExpGlaett< _t >::get(), Linie::GetLen(), TrimmedMean::GetMean(), TrimmedMean::GetNumCases(), TrimmedMean::GetStDev(), PolLinie::GetWinkel(), kalmanState, M_PI, numFeatures, prevFeatures, and VERSCHIEBUNG.
Referenced by OFlowObs::FrameNotifyGray(), and PrintFlowField().
|
protectedvirtual |
Definition at line 502 of file OpticalFlow.cpp.
References IMG_MARGIN, and imgSize.
Referenced by MaskUseFullArea(), and MaskUseGridCell().
|
protectedvirtual |
< mask for the selection of feature points
Definition at line 499 of file OpticalFlow.cpp.
References IMG_MARGIN.
Referenced by MaskUseFullArea(), and MaskUseGridCell().
|
protectedvirtual |
Definition at line 511 of file OpticalFlow.cpp.
References IMG_MARGIN, and imgSize.
Referenced by MaskUseFullArea(), and MaskUseGridCell().
|
protectedvirtual |
Definition at line 506 of file OpticalFlow.cpp.
References focus.
Referenced by MaskUseFullArea(), and MaskUseGridCell().
|
protected |
Definition at line 516 of file OpticalFlow.cpp.
References GetXMax(), GetXMin(), GetYMax(), GetYMin(), and mask.
Referenced by SetFocus().
|
protected |
Definition at line 525 of file OpticalFlow.cpp.
References GetXMax(), GetXMin(), GetYMax(), GetYMin(), and mask.
Referenced by SelectFeatures().
void OpticalFlow::PrintFlowField | ( | IplImage * | img) |
print arrows into img showing the flow
print lines to img
Definition at line 235 of file OpticalFlow.cpp.
References ExpGlaett< _t >::add(), Mean< _t >::add(), TrimmedMean::Add(), KalmanFilter< _dims >::AddMeasure(), TrimmedMean::Compute(), curFeatures, featStatus, focus, focusOfExpansion, ExpGlaett< _t >::get(), Mean< _t >::get_mean(), Linie::GetLen(), TrimmedMean::GetMean(), PolLinie::GetWinkel(), GetWinkel(), GetWinkelDiff(), kalmanFOE, kalmanState, M_PI, numCalls, numFeatures, particles, KalmanFilter< _dims >::Predict(), prevFeatures, PrintArrow(), and ExpGlaett< _t >::set().
Referenced by OFlowObs::FrameNotifyGray().
void OpticalFlow::PrintFocus | ( | IplImage * | img) |
mark the focus point
Definition at line 346 of file OpticalFlow.cpp.
References focus, and FOCUS_CROSS_LWIDTH.
void OpticalFlow::PrintInfo | ( | ) |
debugging stuff
calculate and print feature info
Definition at line 401 of file OpticalFlow.cpp.
References Mean< _t >::add(), curFeatures, featStatus, focus, Mean< _t >::get_mean(), Mean< _t >::get_num_cases(), M_PI, MHDBGMSG, MHDBGMSG_I, numCalls, numFeatures, prevFeatures, and TRMEAN_MARGIN.
|
protected |
use cvGoodFeaturesToTrack
find features, and writes them to prevFeatures
features from the last run could be re-used
Definition at line 92 of file OpticalFlow.cpp.
References curFeatures, eigenBuf, featStatus, focus, FreeStatusData(), ImageHolder::GetImage(), RingBuf< _t, len >::GetPrev(), IMG_MARGIN, imgBuf, imgSize, mask, MaskUseGridCell(), MHDBGMSG, numFeatures, OFFSET, particles, PIX_ABSTAND, prevFeatures, tempBuf, XGRID, and YGRID.
Referenced by Calc().
void OpticalFlow::SetFocus | ( | const CvPoint & | focus) |
set the current focus
Needed for the calculation of the overall angle of the flow field.
(re)create the feature mask
Definition at line 463 of file OpticalFlow.cpp.
References focus, FreeStatusData(), IMG_MARGIN, imgSize, mask, and MaskUseFullArea().
Referenced by FocusNotify(), and OFlowObs::FrameNotifyGray().
void OpticalFlow::SetSize | ( | const CvSize & | size) |
set the size of images
(re)create pyramid buffers and other internal data
Definition at line 543 of file OpticalFlow.cpp.
References RingBuf< _t, len >::Add(), eigenBuf, IMG_MARGIN, imgSize, mask, pyrBuf, and tempBuf.
Referenced by OFlowObs::FrameNotifyGray().
|
protected |
Positions of the features in the current image.
Definition at line 88 of file OpticalFlow.h.
Referenced by Calc(), FreeStatusData(), GetWinkel(), PrintFlowField(), PrintInfo(), and SelectFeatures().
|
protected |
Definition at line 149 of file OpticalFlow.h.
Referenced by SelectFeatures(), SetSize(), and ~OpticalFlow().
|
protected |
status is true when a feature has been found in the current image
Definition at line 90 of file OpticalFlow.h.
Referenced by Calc(), FreeStatusData(), GetWinkel(), PrintFlowField(), PrintInfo(), and SelectFeatures().
|
protected |
the current focus
needed to calculate the overall angle of the flow field
Definition at line 140 of file OpticalFlow.h.
Referenced by Calc(), GetWinkel(), GetYMin(), PrintFlowField(), PrintFocus(), PrintInfo(), SelectFeatures(), and SetFocus().
the focus of expansion, exponentially smoothed
Definition at line 128 of file OpticalFlow.h.
Referenced by GetWinkel(), OpticalFlow(), and PrintFlowField().
|
protected |
the current image and its predecessor
Definition at line 78 of file OpticalFlow.h.
Referenced by AddImage(), Calc(), SelectFeatures(), and ~OpticalFlow().
|
protected |
the size of the image
Definition at line 135 of file OpticalFlow.h.
Referenced by GetXMax(), GetYMax(), SelectFeatures(), SetFocus(), and SetSize().
|
protected |
kalman filter for the focus of expansion
Definition at line 131 of file OpticalFlow.h.
Referenced by OpticalFlow(), and PrintFlowField().
|
protected |
Definition at line 132 of file OpticalFlow.h.
Referenced by GetWinkel(), and PrintFlowField().
|
protected |
< temporary data for SelectFeatures()
Definition at line 151 of file OpticalFlow.h.
Referenced by MaskUseFullArea(), MaskUseGridCell(), SelectFeatures(), SetFocus(), SetSize(), and ~OpticalFlow().
|
protected |
number of calls to Calc
needed in order to know whether the pyramid for the previous image has already been calculated
Definition at line 147 of file OpticalFlow.h.
Referenced by Calc(), PrintFlowField(), and PrintInfo().
|
protected |
the number of features to track
Definition at line 84 of file OpticalFlow.h.
Referenced by Calc(), GetWinkel(), PrintFlowField(), PrintInfo(), and SelectFeatures().
all the particles
Definition at line 126 of file OpticalFlow.h.
Referenced by Calc(), PrintFlowField(), and SelectFeatures().
|
protected |
Positions of the features in the last image.
Definition at line 86 of file OpticalFlow.h.
Referenced by Calc(), FreeStatusData(), GetWinkel(), PrintFlowField(), PrintInfo(), and SelectFeatures().
|
protected |
the pyramids
Definition at line 81 of file OpticalFlow.h.
Referenced by Calc(), SetSize(), and ~OpticalFlow().
|
protected |
< temporary data for SelectFeatures()
Definition at line 150 of file OpticalFlow.h.
Referenced by SelectFeatures(), SetSize(), and ~OpticalFlow().