Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMomentAreaNormalized Class Reference

#include <visp3/core/vpMomentAreaNormalized.h>

+ Inheritance diagram for vpMomentAreaNormalized:

Public Member Functions

 vpMomentAreaNormalized (double desiredSurface, double desiredDepth)
virtual ~vpMomentAreaNormalized ()
void compute ()
double getDesiredDepth () const
double getDesiredSurface () const
const char * name () const
void printDependencies (std::ostream &os) const
Inherited functionalities from vpMoment
const vpMomentObjectgetObject () const
const std::vector< double > & get () const
void linkTo (vpMomentDatabase &moments)
void update (vpMomentObject &object)

Protected Member Functions

vpMomentDatabasegetMoments () const

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 [30].

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 <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentCentered.h>
#include <visp3/core/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 128 of file vpMomentAreaNormalized.h.

Constructor & Destructor Documentation

vpMomentAreaNormalized::vpMomentAreaNormalized ( double  desired_surface,
double  desired_depth 

Default constructor.

desired_surface: desired area a* when the visual servoing converges.
desired_depth: desired depth Z* when the visual servoing converges.

Definition at line 73 of file vpMomentAreaNormalized.cpp.

References vpMoment::values.

virtual vpMomentAreaNormalized::~vpMomentAreaNormalized ( )

Definition at line 134 of file vpMomentAreaNormalized.h.

Member Function Documentation

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

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

Definition at line 139 of file vpMomentAreaNormalized.h.

double vpMomentAreaNormalized::getDesiredSurface ( ) const

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

Definition at line 143 of file vpMomentAreaNormalized.h.

void vpMoment::linkTo ( vpMomentDatabase data_base)

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 <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/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;
data_base: database of moment primitives.

Definition at line 99 of file vpMoment.cpp.

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

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

const char* vpMomentAreaNormalized::name ( ) const

Moment name.

Implements vpMoment.

Definition at line 148 of file vpMomentAreaNormalized.h.

void vpMomentAreaNormalized::printDependencies ( std::ostream &  os) const

Prints dependencies namely,

  1. Depth at desired pose Z*
  2. Area moment at desired pose m00* if DENSE moment object, (mu20* + mu02*) if DISCRETE moment object
  3. Area moment at current pose m00 if DENSE moment object, (mu20 + mu02) if DISCRETE moment object

Reimplemented from vpMoment.

Definition at line 96 of file vpMomentAreaNormalized.cpp.

References vpMomentObject::DISCRETE, vpMomentCentered::get(), vpMomentDatabase::get(), vpMomentObject::get(), vpMoment::getMoments(), vpMoment::getObject(), and vpException::notInitialized.

void vpMoment::update ( vpMomentObject moment_object)

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

moment_object: object descriptor of the current camera vision.

Definition at line 116 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 82 of file vpMomentAreaNormalized.cpp.

Member Data Documentation