Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpMomentAreaNormalized Class Reference

#include <visp3/core/vpMomentAreaNormalized.h>

+ Inheritance diagram for vpMomentAreaNormalized:

Public Member Functions

 vpMomentAreaNormalized (double a_star, double Z_star)
 
void compute ()
 
double getDesiredArea () const
 
double getDesiredDepth () const
 
void setDesiredDepth (double Z_star)
 
void setDesiredArea (double a_star)
 
const std::string 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
 

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

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 (referred 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 continuous cases.

This example shows a computation in the discrete case.

#include <visp3/core/vpMomentAreaNormalized.h>
#include <visp3/core/vpMomentCentered.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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;
}
Class handling the normalized surface moment that is invariant in scale and used to estimate depth.
This class defines the double-indexed centered moment descriptor .
This class allows to register all vpMoments so they can access each other according to their dependen...
virtual void updateAll(vpMomentObject &object)
Class describing 2D gravity center moment.
Class for generic objects.
void linkTo(vpMomentDatabase &moments)
Definition: vpMoment.cpp:114
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:79
void set_x(double x)
Set the point x coordinate in the image plane.
Definition: vpPoint.cpp:464
void set_y(double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.cpp:466

This code produces the following output:

An:1.41421
Examples
mbot-apriltag-ibvs.cpp, and servoBebop2.cpp.

Definition at line 138 of file vpMomentAreaNormalized.h.

Constructor & Destructor Documentation

◆ vpMomentAreaNormalized()

vpMomentAreaNormalized::vpMomentAreaNormalized ( double  a_star,
double  Z_star 
)

Default constructor.

Parameters
a_star: desired area a* when the visual servoing converges.
Z_star: desired depth Z* when the visual servoing converges.

Definition at line 81 of file vpMomentAreaNormalized.cpp.

References vpMoment::values.

Member Function Documentation

◆ compute()

BEGIN_VISP_NAMESPACE void vpMomentAreaNormalized::compute ( )
virtual

◆ get()

◆ getDesiredArea()

double vpMomentAreaNormalized::getDesiredArea ( ) const
inline

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

Definition at line 151 of file vpMomentAreaNormalized.h.

◆ getDesiredDepth()

double vpMomentAreaNormalized::getDesiredDepth ( ) const
inline

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

Definition at line 156 of file vpMomentAreaNormalized.h.

◆ getMoments()

◆ getObject()

◆ linkTo()

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 <visp3/core/vpMomentCentered.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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)
vec_p.push_back(p);
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 contains 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;
}
void update(vpMomentObject &object)
Definition: vpMoment.cpp:127
Parameters
data_base: database of moment primitives.
Examples
mbot-apriltag-ibvs.cpp, servoBebop2.cpp, and testMomentAlpha.cpp.

Definition at line 114 of file vpMoment.cpp.

References vpMoment::name().

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

◆ name()

const std::string vpMomentAreaNormalized::name ( ) const
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 186 of file vpMomentAreaNormalized.h.

◆ printDependencies()

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

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 95 of file vpMomentAreaNormalized.cpp.

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

◆ setDesiredArea()

void vpMomentAreaNormalized::setDesiredArea ( double  a_star)
inline

Set the desired area a* to a new value than the one specified in the constructor. This value has to be set before calling compute().

Examples
mbot-apriltag-ibvs.cpp.

Definition at line 168 of file vpMomentAreaNormalized.h.

◆ setDesiredDepth()

void vpMomentAreaNormalized::setDesiredDepth ( double  Z_star)
inline

Set the desired depth Z* to a new value than the one specified in the constructor. This value has to be set before calling compute().

Definition at line 162 of file vpMomentAreaNormalized.h.

◆ update()

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 127 of file vpMoment.cpp.

Friends And Related Function Documentation

◆ operator<<

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

Outputs the moment's values to a stream.

Definition at line 118 of file vpMomentAreaNormalized.cpp.

Member Data Documentation

◆ values