Visual Servoing Platform  version 3.6.1 under development (2024-06-12)
vpMomentBasic Class Reference

#include <visp3/core/vpMomentBasic.h>

+ Inheritance diagram for vpMomentBasic:

Public Member Functions

 vpMomentBasic ()
void compute ()
const std::vector< double > & get () const
double get (unsigned int i, unsigned int j) const
const std::string name () const
void printDependencies (std::ostream &os) const
Inherited functionalities from vpMoment
const vpMomentObjectgetObject () 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 vpMomentBasic &v)

Detailed Description

This class defines the 2D basic moment $m_{ij}$. This class is a wrapper for vpMomentObject wich allows to use it as a moment. This enables all common operations such as adding to a vpMomentDatabase.

In the case of a dense object O, 2D basic moments are defined by:

\[m_{ij} = \int \int_{O} x^j y^j dx dy\]

In the case of a discrete set of n points, the basic moments are defined by

\[m_{ij} = \sum_{k=1}^{n} x_k^j y_k^j \]

The selection of a dense or discrete object is done in vpMomentObject. The maximum order of vpMomentBasic is the same as that of vpMomentObject (ie: $i+j \leq $ vpMomentObject::getOrder).

Note that in the continuous case, the basic moment $m_{00}$ corresponds to the surface $a$ of the object. In the discrete case, it is the number of discrete points $n$.

mbot-apriltag-ibvs.cpp, servoBebop2.cpp, and servoPixhawkDroneIBVS.cpp.

Definition at line 72 of file vpMomentBasic.h.

Constructor & Destructor Documentation

◆ vpMomentBasic()

BEGIN_VISP_NAMESPACE vpMomentBasic::vpMomentBasic ( )

Default constructor.

Definition at line 46 of file vpMomentBasic.cpp.

Member Function Documentation

◆ compute()

void vpMomentBasic::compute ( )

Dummy function. Everything is already done in object.

Implements vpMoment.

Definition at line 69 of file vpMomentBasic.cpp.

◆ get() [1/2]

const std::vector< double > & vpMomentBasic::get ( ) const

Retrieve all moments of all orders computed. vpMomentBasic::get()[j*order+i] refers to moment $m_{ij}$.

all computed moments.

Same behaviour as vpMomentObject.

mbot-apriltag-ibvs.cpp, servoBebop2.cpp, and servoPixhawkDroneIBVS.cpp.

Definition at line 54 of file vpMomentBasic.cpp.

References vpMomentObject::get(), and vpMoment::getObject().

Referenced by vpFeatureMomentCentered::compute_Lmu_pq().

◆ get() [2/2]

double vpMomentBasic::get ( unsigned int  i,
unsigned int  j 
) const

Gets the desired moment using indexes.

i: first index of the 2D moment.
j: second index of the 2D moment.
$m_{ij}$ moment.

Same behaviour as vpMomentObject.

Definition at line 64 of file vpMomentBasic.cpp.

References vpMomentObject::get(), and vpMoment::getObject().

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

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)
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 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:110
void update(vpMomentObject &object)
Definition: vpMoment.cpp:123
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:503
void set_y(double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.cpp:505
data_base: database of moment primitives.
mbot-apriltag-ibvs.cpp, servoBebop2.cpp, servoPixhawkDroneIBVS.cpp, and testMomentAlpha.cpp.

Definition at line 110 of file vpMoment.cpp.

References vpMoment::name().

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

◆ name()

const std::string vpMomentBasic::name ( ) const

Moment name.

Implements vpMoment.

Definition at line 83 of file vpMomentBasic.h.

◆ printDependencies()

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

No dependencies on other vpMoments, since basic moments are computed in vpMomentObject Just prints the basic moments in vpMomentObject with indices

Reimplemented from vpMoment.

Definition at line 75 of file vpMomentBasic.cpp.

References vpMoment::getObject(), and vpMomentObject::printWithIndices().

◆ update()

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

Friends And Related Function Documentation

◆ operator<<

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
const vpMomentBasic v 

Outputs the moment's values to a stream. Same output as in vpMomentObject.

Definition at line 88 of file vpMomentBasic.cpp.

Member Data Documentation

◆ values