ViSP  2.9.0
vpMomentAreaNormalized Class Reference

#include <vpMomentAreaNormalized.h>

+ Inheritance diagram for vpMomentAreaNormalized:

Public Member Functions

 vpMomentAreaNormalized (double desiredSurface, double desiredDepth)
 
void compute ()
 
double getDesiredDepth () const
 
double getDesiredSurface () const
 
const char * name () const
 
const vpMomentObjectgetObject () const
 
const std::vector< double > & get () const
 
void linkTo (vpMomentDatabase &moments)
 
void update (vpMomentObject &object)
 

Protected Member Functions

vpMomentDatabasegetMoments ()
 

Protected Attributes

std::vector< double > values
 

Friends

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

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*.

Warning
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
vec_p.push_back(p);
p.set_x(2); p.set_y(2); // coordinates in meters in the image plane of point 2
vec_p.push_back(p);
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:

An:1.41421

Definition at line 132 of file vpMomentAreaNormalized.h.

Constructor & Destructor Documentation

vpMomentAreaNormalized::vpMomentAreaNormalized ( double  desired_surface,
double  desired_depth 
)

Default constructor.

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

Definition at line 77 of file vpMomentAreaNormalized.cpp.

References vpMoment::values.

Member Function Documentation

void vpMomentAreaNormalized::compute ( )
virtual
const std::vector<double>& vpMoment::get ( ) const
inlineinherited
double vpMomentAreaNormalized::getDesiredDepth ( ) const
inline

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

Definition at line 142 of file vpMomentAreaNormalized.h.

double vpMomentAreaNormalized::getDesiredSurface ( ) const
inline

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

Definition at line 146 of file vpMomentAreaNormalized.h.

vpMomentDatabase& vpMoment::getMoments ( )
inlineprotectedinherited

Returns the linked moment database.

Returns
the moment database

Definition at line 119 of file vpMoment.h.

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

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* vpMomentAreaNormalized::name ( ) const
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 151 of file vpMomentAreaNormalized.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.

Friends And Related Function Documentation

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
const vpMomentAreaNormalized v 
)
friend

Outputs the moment's values to a stream.

Definition at line 86 of file vpMomentAreaNormalized.cpp.

Member Data Documentation