Visual Servoing Platform  version 3.6.1 under development (2024-12-06)
vpMoment Class Referenceabstract

#include <visp3/core/vpMoment.h>

+ Inheritance diagram for vpMoment:

Public Member Functions

 vpMoment ()
 
virtual ~vpMoment ()
 

Protected Member Functions

vpMomentDatabasegetMoments () const
 

Protected Attributes

std::vector< double > values
 

Inherited functionalities from vpMoment

virtual void compute ()=0
 
const vpMomentObjectgetObject () const
 
const std::vector< double > & get () const
 
void linkTo (vpMomentDatabase &moments)
 
virtual const std::string name () const =0
 
virtual void printDependencies (std::ostream &os) const
 
void update (vpMomentObject &object)
 
VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpMoment &m)
 

Detailed Description

This class defines shared methods/attributes for 2D moments.

All moments or combination of moments in the moments module are based on this class. A moment uses a vpMomentObject object to access all useful information. Moment values are obtained by a 4-step process common for all moment types:

A moment may also be linked to a vpMomentDatabase. Moments linked to a database are able to access each others values. Some moments can be computed only if they are linked to a a database containing their dependencies. Linking to a database is done using the vpMoment::linkTo(...) method.

There are no constraints about format of the array returned by vpMoment::get(); any implementation is fine.

Each moment must have a string name by implementing the char* vpMoment::name() method which allows to identify the moment in the database. Each moment must also implement a compute method describing how to obtain its values from the object.

Attention
Order of moment computation DOES matter: when you compute a moment using vpMoment::compute(), all moment dependencies must be computed. We recall that implemented moments are:

Definition at line 105 of file vpMoment.h.

Constructor & Destructor Documentation

◆ vpMoment()

vpMoment::vpMoment ( )

Default constructor

Definition at line 61 of file vpMoment.cpp.

◆ ~vpMoment()

virtual vpMoment::~vpMoment ( )
inlinevirtual

Virtual destructor.

Definition at line 140 of file vpMoment.h.

Member Function Documentation

◆ compute()

◆ get()

◆ getMoments()

◆ getObject()

◆ linkTo()

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.

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;
}
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...
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:468
void set_y(double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.cpp:470
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 name().

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

◆ name()

virtual const std::string vpMoment::name ( ) const
pure virtual

◆ printDependencies()

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

Prints values of all dependent moments required to calculate a specific vpMoment. Not made pure to maintain compatibility Recommended : Types inheriting from vpMoment should implement this function

Reimplemented in vpMomentGravityCenterNormalized, vpMomentGravityCenter, vpMomentCentered, vpMomentBasic, vpMomentAreaNormalized, vpMomentArea, and vpMomentAlpha.

Definition at line 134 of file vpMoment.cpp.

◆ update()

void vpMoment::update ( vpMomentObject moment_object)

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 vpMoment m 
)
friend

Prints the moment contents to a stream

Parameters
os: a std::stream.
m: a moment instance.

Definition at line 50 of file vpMoment.cpp.

Member Data Documentation

◆ values