ACT-CV - Machine Vision for Cognitive Modeling
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OpticalFlow Class Reference

calculate the optical flow for some points in the image More...

#include <OpticalFlow.h>

Inheritance diagram for OpticalFlow:
Inheritance graph
Collaboration diagram for OpticalFlow:
Collaboration graph

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< ImageHoldereigenBuf
 
GCPointer< ImageHoldertempBuf
 
CvMat * mask
 

Detailed Description

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.

Constructor & Destructor Documentation

OpticalFlow::OpticalFlow ( )
OpticalFlow::~OpticalFlow ( )
virtual

Member Function Documentation

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

Warning
No checking is done whether the image buffer is full and the size is set.

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().

void OpticalFlow::FocusNotify ( const CvPoint &  p)
virtual

Implements FocusObserver.

Definition at line 178 of file OpticalFlow.h.

References SetFocus().

Referenced by OFlowObs::FocusNotify().

void OpticalFlow::FreeStatusData ( )
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 ( )
int OpticalFlow::GetXMax ( )
protectedvirtual

Definition at line 502 of file OpticalFlow.cpp.

References IMG_MARGIN, and imgSize.

Referenced by MaskUseFullArea(), and MaskUseGridCell().

int OpticalFlow::GetXMin ( )
protectedvirtual

< mask for the selection of feature points

Definition at line 499 of file OpticalFlow.cpp.

References IMG_MARGIN.

Referenced by MaskUseFullArea(), and MaskUseGridCell().

int OpticalFlow::GetYMax ( )
protectedvirtual

Definition at line 511 of file OpticalFlow.cpp.

References IMG_MARGIN, and imgSize.

Referenced by MaskUseFullArea(), and MaskUseGridCell().

int OpticalFlow::GetYMin ( )
protectedvirtual

Definition at line 506 of file OpticalFlow.cpp.

References focus.

Referenced by MaskUseFullArea(), and MaskUseGridCell().

void OpticalFlow::MaskUseFullArea ( )
protected

Definition at line 516 of file OpticalFlow.cpp.

References GetXMax(), GetXMin(), GetYMax(), GetYMin(), and mask.

Referenced by SetFocus().

void OpticalFlow::MaskUseGridCell ( int  x,
int  y,
int  lenX,
int  lenY 
)
protected

Definition at line 525 of file OpticalFlow.cpp.

References GetXMax(), GetXMin(), GetYMax(), GetYMin(), and mask.

Referenced by SelectFeatures().

void OpticalFlow::PrintFlowField ( IplImage *  img)
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 ( )
void OpticalFlow::SelectFeatures ( )
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

Warning
This must be called before any call to Calc()! Internal structures needed by Calc() are created here.

(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().

Member Data Documentation

CvPoint2D32f* OpticalFlow::curFeatures
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().

GCPointer<ImageHolder> OpticalFlow::eigenBuf
protected

Definition at line 149 of file OpticalFlow.h.

Referenced by SelectFeatures(), SetSize(), and ~OpticalFlow().

char* OpticalFlow::featStatus
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().

CvPoint OpticalFlow::focus
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().

ExpGlaett<Pos<2,double> > OpticalFlow::focusOfExpansion
protected

the focus of expansion, exponentially smoothed

Definition at line 128 of file OpticalFlow.h.

Referenced by GetWinkel(), OpticalFlow(), and PrintFlowField().

RingBuf<GCPointer<ImageHolder>, 2> OpticalFlow::imgBuf
protected

the current image and its predecessor

Definition at line 78 of file OpticalFlow.h.

Referenced by AddImage(), Calc(), SelectFeatures(), and ~OpticalFlow().

CvSize OpticalFlow::imgSize
protected

the size of the image

Definition at line 135 of file OpticalFlow.h.

Referenced by GetXMax(), GetYMax(), SelectFeatures(), SetFocus(), and SetSize().

KalmanFilter<2> OpticalFlow::kalmanFOE
protected

kalman filter for the focus of expansion

Definition at line 131 of file OpticalFlow.h.

Referenced by OpticalFlow(), and PrintFlowField().

float OpticalFlow::kalmanState[4]
protected

Definition at line 132 of file OpticalFlow.h.

Referenced by GetWinkel(), and PrintFlowField().

CvMat* OpticalFlow::mask
protected

< temporary data for SelectFeatures()

Definition at line 151 of file OpticalFlow.h.

Referenced by MaskUseFullArea(), MaskUseGridCell(), SelectFeatures(), SetFocus(), SetSize(), and ~OpticalFlow().

int OpticalFlow::numCalls
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().

int OpticalFlow::numFeatures
protected

the number of features to track

Definition at line 84 of file OpticalFlow.h.

Referenced by Calc(), GetWinkel(), PrintFlowField(), PrintInfo(), and SelectFeatures().

std::vector<GCPointer<Particle> > OpticalFlow::particles
protected

all the particles

Definition at line 126 of file OpticalFlow.h.

Referenced by Calc(), PrintFlowField(), and SelectFeatures().

CvPoint2D32f* OpticalFlow::prevFeatures
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().

RingBuf<GCPointer<ImageHolder>, 2> OpticalFlow::pyrBuf
protected

the pyramids

Definition at line 81 of file OpticalFlow.h.

Referenced by Calc(), SetSize(), and ~OpticalFlow().

GCPointer<ImageHolder> OpticalFlow::tempBuf
protected

< temporary data for SelectFeatures()

Definition at line 150 of file OpticalFlow.h.

Referenced by SelectFeatures(), SetSize(), and ~OpticalFlow().


The documentation for this class was generated from the following files:


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)