Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OpticalFlow Class Reference

This CameraSensor calculates the optical flow at few points of the image based on a box matching technique. More...

#include <opticalflow.h>

Inheritance diagram for OpticalFlow:
Collaboration diagram for OpticalFlow:

Classes

struct  Vec2i
 

Public Types

typedef std::list< std::pair
< Vec2i, int > > 
FlowDelList
 
- Public Types inherited from Sensor
enum  Dimensions {
  X = 1, Y = 2, Z = 4, XY = X | Y,
  XZ = X | Z, YZ = Y | Z, XYZ = X | Y | Z
}
 defines which dimensions should be sensed. The meaning is sensor specific. More...
 
- Public Types inherited from SensorMotorInfoAble
typedef std::function
< std::string(int)> 
NamingFunction
 function that returns the name given the index More...
 

Public Member Functions

 OpticalFlow (OpticalFlowConf conf=getDefaultConf())
 
virtual ~OpticalFlow ()
 
virtual void intern_init ()
 overload this function to initialized you data structures. More...
 
virtual bool sense (const GlobalData &globaldata)
 Performs the calculations. More...
 
virtual int getSensorNumber () const
 overload this function and return the number of sensor values More...
 
virtual int get (sensor *sensors, int length) const
 overload this function and return the sensor values More...
 
- Public Member Functions inherited from CameraSensor
 CameraSensor ()
 Creates a camera sensor. More...
 
virtual ~CameraSensor ()
 
virtual void setInitData (Camera *camera, const OdeHandle &odeHandle, const OsgHandle &osgHandle, const osg::Matrix &pose)
 sets the initial data structures like the camera. More...
 
virtual void setPose (const osg::Matrix &pose)
 changes the relative pose of the camera More...
 
virtual osg::Matrix getPose ()
 relative pose of the camera More...
 
virtual void init (Primitive *own, Joint *joint=0)
 this function initialized the camera (no need to overload) (Sensor interface) More...
 
virtual void update ()
 we update the camera's visual appearance More...
 
virtual std::list< sensorgetList () const
 this is implemented based on get(sensor*,int) More...
 
- Public Member Functions inherited from Sensor
 Sensor ()
 
virtual ~Sensor ()
 
virtual std::list
< SensorMotorInfo
getSensorInfos () const
 returns a list of sensor infos ( More...
 
std::list< sensorgetListOfArray () const
 helper function for performance implementation of list<> get() based on array-get More...
 
- Public Member Functions inherited from SensorMotorInfoAble
 SensorMotorInfoAble ()
 
void setBaseName (const std::string &basename)
 
void setBaseInfo (const SensorMotorInfo &baseinfo)
 
SensorMotorInfo getBaseInfo ()
 
void setNamingFunc (const NamingFunction &func)
 
NamingFunction getNamingFunc () const
 
void setNames (const std::vector< std::string > &names)
 set names explicitly (basename is anyway suffixed) More...
 
std::string getName (int index) const
 returns the name of a single item. Typically called from within Sensor and Motor class. More...
 
std::list< SensorMotorInfogetInfos (int number) const
 get all infos. More...
 

Static Public Member Functions

static std::list< PosgetDefaultPoints (int num)
 calculates default positions for optical flow detection. More...
 
static OpticalFlowConf getDefaultConf ()
 the default config has 2 points in and calculates the flow in X and Y More...
 
- Static Public Member Functions inherited from Sensor
static std::list< sensorselectrows (const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static int selectrows (sensor *sensors, int length, const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static Dimensions parseSensorDimension (char *str)
 
static std::string dimensions2String (short dimensions)
 
- Static Public Member Functions inherited from SensorMotorInfoAble
static std::string defaultNameing (int index)
 the default implementation is for index==0: basename, otherwise basename + (index+1) More...
 

Protected Member Functions

Vec2i calcFieldTransRGB (const Vec2i &field, const osg::Image *current, const osg::Image *last, double &minerror) const
 calculates the optimal transformation for one field in RGB using all three color channels More...
 

Static Protected Member Functions

static double compareSubImg (const unsigned char *const I1, const unsigned char *const I2, const Vec2i &field, int size, int width, int height, int bytesPerPixel, int d_x, int d_y)
 compares a small part of two given images and returns the average absolute difference. More...
 

Protected Attributes

OpticalFlowConf conf
 
int num
 
std::list< Vec2ifields
 
sensordata
 
osg::Image * lasts [4]
 
std::vector< Vec2ioldFlows
 
int maxShiftX
 
int maxShiftY
 
int width
 
int height
 
int cnt
 
double avgerror
 
- Protected Attributes inherited from CameraSensor
Cameracamera
 
OdeHandle odeHandle
 
OsgHandle osgHandle
 
osg::Matrix pose
 
bool isInitDataSet
 
- Protected Attributes inherited from SensorMotorInfoAble
NamingFunction func
 
SensorMotorInfo baseinfo
 

Detailed Description

This CameraSensor calculates the optical flow at few points of the image based on a box matching technique.

This can be applied directly to the camera image.

Member Typedef Documentation

typedef std::list< std::pair<Vec2i,int> > FlowDelList

Constructor & Destructor Documentation

See Also
CameraSensor for further parameter explanation.
~OpticalFlow ( )
virtual

Member Function Documentation

OpticalFlow::Vec2i calcFieldTransRGB ( const Vec2i field,
const osg::Image *  current,
const osg::Image *  last,
double &  minerror 
) const
protected

calculates the optimal transformation for one field in RGB using all three color channels

Parameters
minerror(is to return the minimum error achieved during the matching)
double compareSubImg ( const unsigned char *const  I1,
const unsigned char *const  I2,
const Vec2i field,
int  size,
int  width,
int  height,
int  bytesPerPixel,
int  d_x,
int  d_y 
)
staticprotected

compares a small part of two given images and returns the average absolute difference.

Field center, size and shift have to be choosen, so that no clipping is required!

Parameters
fieldspecifies position(center) of subimage to use for comparison
sizespecifies the size of the field edged in pixels
d_xshift in x direction
d_yshift in y direction
int get ( sensor sensors,
int  length 
) const
virtual

overload this function and return the sensor values

Implements CameraSensor.

static OpticalFlowConf getDefaultConf ( )
inlinestatic

the default config has 2 points in and calculates the flow in X and Y

list< Pos > getDefaultPoints ( int  num)
static

calculates default positions for optical flow detection.

The points are in aranged horizontally in a line at the vertical center. For num 2 the points are at the border, 3 points there is additioanlly one is the center and so on.

virtual int getSensorNumber ( ) const
inlinevirtual

overload this function and return the number of sensor values

Implements CameraSensor.

void intern_init ( )
virtual

overload this function to initialized you data structures.

Use camera->getImage() to get the image from the camera

Implements CameraSensor.

bool sense ( const GlobalData globaldata)
virtual

Performs the calculations.

Implements CameraSensor.

Member Data Documentation

double avgerror
protected
int cnt
protected
OpticalFlowConf conf
protected
sensor* data
protected
std::list<Vec2i> fields
protected
int height
protected
osg::Image* lasts[4]
protected
int maxShiftX
protected
int maxShiftY
protected
int num
protected
std::vector<Vec2i> oldFlows
protected
int width
protected

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