ViSP  2.9.0
vpMomentBasic Class Reference

#include <vpMomentBasic.h>

+ Inheritance diagram for vpMomentBasic:

Public Member Functions

 vpMomentBasic ()
 
void compute ()
 
const std::vector< double > & get () const
 
double get (unsigned int i, unsigned int j) const
 
const char * name () const
 
const vpMomentObjectgetObject () const
 
void linkTo (vpMomentDatabase &moments)
 
void update (vpMomentObject &object)
 

Protected Member Functions

vpMomentDatabasegetMoments ()
 

Protected Attributes

std::vector< double > values
 

Detailed Description

This class defines the 2D basic moment $m_{ij}$. This class is a wrapper for vpMomentObject wich allows to use it as a moment. This enables all common operations such as adding to a vpMomentDatabase.

In the case of a dense object O, 2D basic moments are defined by:

\[m_{ij} = \int \int_{O} x^j y^j dx dy\]

In the case of a discrete set of n points, the basic moments are defined by

\[m_{ij} = \sum_{k=1}^{n} x_k^j y_k^j \]

The selection of a dense or discrete object is done in vpMomentObject. The maximum order of vpMomentBasic is the same as that of vpMomentObject (ie: $i+j \leq $ vpMomentObject::getOrder).

Note that in the continuous case, the basic moment $m_{00}$ corresponds to the surface $a$ of the object. In the discrete case, it is the number of discrete points $n$.

Definition at line 74 of file vpMomentBasic.h.

Constructor & Destructor Documentation

vpMomentBasic::vpMomentBasic ( )

Default constructor.

Definition at line 47 of file vpMomentBasic.cpp.

Member Function Documentation

void vpMomentBasic::compute ( )
virtual

Dummy function. Everything is already done in object.

Implements vpMoment.

Definition at line 76 of file vpMomentBasic.cpp.

const std::vector< double > & vpMomentBasic::get ( ) const

Retrieve all moments of all orders computed. vpMomentBasic::get()[j*order+i] refers to moment $m_{ij}$.

Returns
all computed moments.

Same behaviour as vpMomentObject.

Definition at line 57 of file vpMomentBasic.cpp.

References vpMomentObject::get(), and vpMoment::getObject().

double vpMomentBasic::get ( unsigned int  i,
unsigned int  j 
) const

Gets the desired moment using indexes.

Parameters
i: first index of the 2D moment.
j: second index of the 2D moment.
Returns
$m_{ij}$ moment.

Same behaviour as vpMomentObject.

Definition at line 69 of file vpMomentBasic.cpp.

References vpMomentObject::get(), and vpMoment::getObject().

vpMomentDatabase& vpMoment::getMoments ( )
inlineprotectedinherited
void vpMoment::linkTo ( vpMomentDatabase data_base)
inherited

Links the moment to a database of moment primitives. If the moment depends on other moments, these moments must be linked to the same database.

Attention
Two moments of the same class cannot be stored in the same database
#include <visp/vpMomentObject.h>
#include <visp/vpPoint.h>
#include <visp/vpMomentGravityCenter.h>
#include <visp/vpMomentDatabase.h>
#include <visp/vpMomentCentered.h>
int main()
{
std::vector<vpPoint> vec_p;
p.set_x(1); p.set_y(1); // coordinates in meters in the image plane (vertex 1)
vec_p.push_back(p);
p.set_x(2); p.set_y(2); // coordinates in meters in the image plane (vertex 2)
obj.setType(vpMomentObject::DISCRETE); // Discrete mode.
obj.fromVector(vec_p); // Init the dense object with the polygon
vpMomentGravityCenter G; // declaration of gravity center
vpMomentCentered mc; // mc containts centered moments
G.linkTo(db); //add gravity center to database
mc.linkTo(db); //centered moments depend on gravity, add them to the
//database to grant access
G.update(obj); // specify the object for gravity center
mc.update(obj); // and for centered moments
G.compute(); // compute the moment
mc.compute(); //compute centered moments AFTER gravity center
return 0;
}
Parameters
data_base: database of moment primitives.

Definition at line 103 of file vpMoment.cpp.

References vpException::memoryAllocationError, and vpMoment::name().

Referenced by vpMomentCommon::getAlpha(), vpMomentCommon::getMu3(), vpMomentCommon::getSurface(), and vpMomentCommon::vpMomentCommon().

const char* vpMomentBasic::name ( ) const
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 84 of file vpMomentBasic.h.

void vpMoment::update ( vpMomentObject moment_object)
inherited

Updates the moment with the current object. This does not compute any values.

Parameters
moment_object: object descriptor of the current camera vision.

Definition at line 120 of file vpMoment.cpp.

Member Data Documentation