ViSP  2.6.2
vpMomentAreaNormalized Class Reference

#include <vpMomentAreaNormalized.h>

+ Inheritance diagram for vpMomentAreaNormalized:

Public Member Functions

 vpMomentAreaNormalized (double desiredSurface, double desiredDepth)
void compute ()
double getDesiredDepth ()
double getDesiredSurface ()
const char * name ()
vpMomentObjectgetObject ()
std::vector< double > & get ()
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, const vpMomentAreaNormalized &v)

Detailed Description

Class handling the normalized surface moment that is invariant in scale and used to estimate depth.

This moment depends on vpMomentCentered.

The idea behind vpMomentAreaNormalized is described in:

[1] Point-based and region-based image moments for visual servoing of planar objects by Omar Tahri and Francois Chaumette.

During a visual servoing process, a vpMomentAreaNormalized will converge towards the desired depth when the current surface will converge to the destination surface. It is defined as follows: $ a_n=Z^* \sqrt{\frac{a^*}{a}} $ where a is the current surface and a* the destination surface. Consequently, the vpMomentAreaNormalized needs to have information about the desired depth Z* and the desired surface a*.

About the order of the object. The surface (refered to as a in the above paragraph) depends of the nature of the object.

Therefore, a vpMomentObject has to be of minimum order 2 in order to compute a vpMomentAreaNormalized moment in the discrete case and of minimum order 0 in continous cases.

This example shows a computation in the discrete case.

#include <visp/vpMomentObject.h>
#include <visp/vpPoint.h>
#include <visp/vpMomentGravityCenter.h>
#include <visp/vpMomentDatabase.h>
#include <visp/vpMomentCentered.h>
#include <visp/vpMomentAreaNormalized.h>
int main()
std::vector<vpPoint> vec_p; // vector that contains object points
p.set_x(1); p.set_y(1); // coordinates in meters in the image plane of point 1
p.set_x(2); p.set_y(2); // coordinates in meters in the image plane of point 2
vpMomentObject obj(2); // Object where all the moment defined with
// i+j <= 2 will be computed below. Order is
// 2 because in discrete mode, the surface
// computation is a=mu02+mu02
obj.setType(vpMomentObject::DISCRETE); // Discrete mode for object
obj.fromVector(vec_p); // initialize the object with the points coordinates
vpMomentDatabase db; //reference database
vpMomentGravityCenter g; // declaration of gravity center
vpMomentCentered mc; // centered moments
vpMomentAreaNormalized an(2,1); //declare normalized surface with
//destination depth of 1 meter and
//destination surface of 2 m2
g.linkTo(db); //add gravity center to database
mc.linkTo(db); //add centered moments
an.linkTo(db); //add alpha depending on centered moments
db.updateAll(obj); // All of the moments must be updated, not just an
g.compute(); // compute the moment
mc.compute(); //compute centered moments AFTER gravity center
an.compute(); //compute alpha AFTER centered moments.
std::cout << an << std::endl;
return 0;

This code produces the following output:


Definition at line 133 of file vpMomentAreaNormalized.h.

Constructor & Destructor Documentation

vpMomentAreaNormalized::vpMomentAreaNormalized ( double  desiredSurface,
double  desiredDepth 

Default constructor.

desiredSurface: desired area a* when the visual servoing converges.
desiredDepth: desired depth Z* when the visual servoing converges.

Definition at line 76 of file vpMomentAreaNormalized.cpp.

References vpMoment::values.

Member Function Documentation

void vpMomentAreaNormalized::compute ( )
double vpMomentAreaNormalized::getDesiredDepth ( )

Retrieves the desired depth Z* as specified in the constructor.

Definition at line 143 of file vpMomentAreaNormalized.h.

double vpMomentAreaNormalized::getDesiredSurface ( )

Retrieves the desired surface a* as specified in the constructor.

Definition at line 147 of file vpMomentAreaNormalized.h.

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(), vpMomentCentered::compute(), 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* vpMomentAreaNormalized::name ( )

Moment name.

Implements vpMoment.

Definition at line 152 of file vpMomentAreaNormalized.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,
const vpMomentAreaNormalized v 

Outputs the moment's values to a stream.

Definition at line 83 of file vpMomentAreaNormalized.cpp.

Member Data Documentation