ViSP  2.6.2
vpMomentCentered Class Reference

#include <vpMomentCentered.h>

+ Inheritance diagram for vpMomentCentered:

Public Member Functions

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

Protected Member Functions

vpMomentDatabasegetMoments ()

Protected Attributes

std::vector< double > values


VISP_EXPORT std::ostream & operator<< (std::ostream &os, vpMomentCentered &v)

Detailed Description

This class defines the double-indexed centered moment descriptor $\mu_{ij}$.

In the case of a dense object O, centered moments are defined by:

\[\mu_{ij}= \int \int_{O} (x_k-x_g)^j (y_k-y_g)^j\]

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

\[\mu_{ij}= \sum_{k=1}^{n} (x_k-x_g)^j (y_k-y_g)^j\]

where $(x_g,y_g)$ are the coordinates of the center of gravity.

The centered moments are computed from the object at the highest possible order. For example if the vpMomentObject is defined up to order 5, vpMomentCentered will be too.

Values of vpMomentCentered may be accessed by one of the two vpMomentCentered::get methods. When using vpMomentCentered::get (), the format of the return vector is the following: $ \mu_{ij} $ is stored at vpMomentCentered::get ()[j* (vpMomentObject::getOrder () +1)+i]

vpMomentCentered depends on vpMomentGravityCenter.

Definition at line 79 of file vpMomentCentered.h.

Constructor & Destructor Documentation

vpMomentCentered::vpMomentCentered ( )

Default constructor.

Definition at line 80 of file vpMomentCentered.cpp.

Member Function Documentation

std::vector<double>& vpMomentCentered::get ( )

Returns all centered moment values $\mu_{ij}$ with $i+j \leq order$ where order is the object's order.

Vector of moment values. To access $\mu_{ij}$, you have to read vpMomentObject::get()[j*order+i].

For example, if the maximal order is 3, the following values are provided:

u00 u10 u20 u01 u11 u21 u02 u12 u12 u30 u03

To have a better reading of the moments you can picture them as a triangular matrix:

u00 u10 u20 u30
u01 u11 u21 x
u02 u12 x x
u30 x x x

The moments of the same order are on each of the matrix reverse diagonals. To access for example to the centered moment $\mu_{12}$, you should use this kind of code:

double mu12;
mu12 = mc.get()[2*(obj.getOrder()+1)+1]; // i=1 and j=2
mu12 = mc.get(1,2); // the same

Definition at line 115 of file vpMomentCentered.h.

References vpMoment::get().

vpMomentDatabase& vpMoment::getMoments ( )

Returns the linked moment database.

the moment database

Definition at line 115 of file vpMoment.h.

Referenced by vpMomentArea::compute(), vpMomentGravityCenterNormalized::compute(), compute(), vpMomentAreaNormalized::compute(), vpMomentCInvariant::compute(), and vpMomentAlpha::compute().

void vpMoment::linkTo ( vpMomentDatabase moments)

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.

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)
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;
moments: database of moment primitives.

Definition at line 104 of file vpMoment.cpp.

References vpMoment::name().

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

const char* vpMomentCentered::name ( )

Moment name.

Implements vpMoment.

Definition at line 119 of file vpMomentCentered.h.

void vpMoment::update ( vpMomentObject object)

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

object: object descriptor of the current camera vision.

Definition at line 117 of file vpMoment.cpp.

Friends And Related Function Documentation

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
vpMomentCentered v 

Outputs the centered moment's values $\mu_{ij}$ to a stream presented as a matrix. The first line corresponds to $\mu_{0[0:order]}$, the second one to $\mu_{1[0:order]}$ Values in table corresponding to a higher order are marked with an "x" and not computed.

For example, if the maximal order is 3, the following values are provided:

u00 u10 u20 u30
u01 u11 u21 x
u02 u12 x x
u30 x x x

Definition at line 112 of file vpMomentCentered.cpp.

Member Data Documentation