Visual Servoing Platform  version 3.3.0
vpMomentArea Class Reference

#include <vpMomentArea.h>

+ Inheritance diagram for vpMomentArea:

Public Member Functions

 vpMomentArea ()
 
virtual ~vpMomentArea ()
 
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
 

Inherited functionalities from vpMomentArea

void compute ()
 
const char * name () const
 
void printDependencies (std::ostream &os) const
 
VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpMomentArea &m)
 

Detailed Description

Class handling the surface moment.

For a dense planar object, the area corresponds to the zero-order moment:

\[ a = m_{00} = \mu_{00} \]

When considering a discrete set of points, the moment $ m_{00} $ simply corresponds to the number of points. Since this is of no use in a servoing scheme, this class uses in this case $ a = \mu_{20} + \mu_{02} $, which is invariant to planar translation and rotation.

Definition at line 61 of file vpMomentArea.h.

Constructor & Destructor Documentation

◆ vpMomentArea()

vpMomentArea::vpMomentArea ( )

Default constructor.

Definition at line 72 of file vpMomentArea.cpp.

◆ ~vpMomentArea()

virtual vpMomentArea::~vpMomentArea ( )
inlinevirtual

Definition at line 65 of file vpMomentArea.h.

Member Function Documentation

◆ compute()

void vpMomentArea::compute ( )
virtual

Has the area $ a = m_{00} = \mu_{00} $ for dense objects, $ \mu_{20}+\mu_{02} $ for a discrete set of points. Gets the value of $ m_{00} $ from vpMomentCentered.

Implements vpMoment.

Definition at line 48 of file vpMomentArea.cpp.

◆ get()

const std::vector<double>& vpMoment::get ( ) const
inlineinherited

Returns all values computed by the moment.

Returns
vector of values

Definition at line 154 of file vpMoment.h.

◆ getMoments()

vpMomentDatabase& vpMoment::getMoments ( ) const
inlineprotectedinherited

Returns the linked moment database.

Returns
the moment database

Definition at line 122 of file vpMoment.h.

◆ getObject()

const vpMomentObject& vpMoment::getObject ( ) const
inlineinherited

Definition at line 149 of file vpMoment.h.

◆ 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>
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.
Examples
mbot-apriltag-ibvs.cpp, servoBebop2.cpp, and testMomentAlpha.cpp.

Definition at line 97 of file vpMoment.cpp.

◆ name()

const char* vpMomentArea::name ( ) const
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 71 of file vpMomentArea.h.

◆ printDependencies()

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

If the vpMomentObject type is

  1. DISCRETE(set of discrete points), uses mu20+mu02
  2. DENSE_FULL_OBJECT(from image) used mu00

Reimplemented from vpMoment.

Definition at line 89 of file vpMomentArea.cpp.

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

Friends And Related Function Documentation

◆ operator<<

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
const vpMomentArea m 
)
friend

Outputs the moment's values to a stream.

Definition at line 77 of file vpMomentArea.cpp.

Member Data Documentation

◆ values

std::vector<double> vpMoment::values
protectedinherited

Definition at line 117 of file vpMoment.h.

vpMoment::linkTo
void linkTo(vpMomentDatabase &moments)
Definition: vpMoment.cpp:97
vpMomentCentered
This class defines the double-indexed centered moment descriptor .
Definition: vpMomentCentered.h:78
vpMomentGravityCenter::compute
void compute()
Definition: vpMomentGravityCenter.cpp:44
vpMomentDatabase
This class allows to register all vpMoments so they can access each other according to their dependen...
Definition: vpMomentDatabase.h:130
vpMomentObject::DISCRETE
Definition: vpMomentObject.h:230
vpMoment::update
void update(vpMomentObject &object)
Definition: vpMoment.cpp:114
vpPoint::set_y
void set_y(double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.cpp:473
vpMomentObject
Class for generic objects.
Definition: vpMomentObject.h:218
vpMomentCentered::compute
void compute()
Definition: vpMomentCentered.cpp:64
vpPoint
Class that defines what is a point.
Definition: vpPoint.h:57
vpPoint::set_x
void set_x(double x)
Set the point x coordinate in the image plane.
Definition: vpPoint.cpp:471
vpMomentGravityCenter
Class describing 2D gravity center moment.
Definition: vpMomentGravityCenter.h:112