ViSP  2.7.0
vpMomentCInvariant Class Reference

#include <vpMomentCInvariant.h>

+ Inheritance diagram for vpMomentCInvariant:

Public Member Functions

 vpMomentCInvariant ()
 
double C1 ()
 
double C2 ()
 
double C3 ()
 
double C4 ()
 
double C5 ()
 
double C6 ()
 
double C7 ()
 
double C8 ()
 
double C9 ()
 
double C10 ()
 
void compute ()
 
double get (unsigned int i)
 
double getC (unsigned int i)
 
double getI (unsigned int index)
 
double getII (unsigned int i)
 
double getK ()
 
double getS (unsigned int i)
 
const char * name ()
 
void printI (unsigned int index)
 
double Px ()
 
double Py ()
 
double Sx ()
 
double Sy ()
 
vpMomentObjectgetObject ()
 
std::vector< double > & get ()
 
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 vpMomentCInvariant &v)
 

Detailed Description

This class defines several 2D (translation+rotation+scale) invariants for both symmetric and non-symmetric objects. These moment-based invariants are described in the following papers:

  • [1] "Point-based and region-based image moments for visual servoing of planar objects" by Omar Tahri and François Chaumette
  • [2] "Image moments: a general and useful set of features for visual servoing" by François Chaumette

The descriptions for the invariants $C_1$ to $C_{10}$ can be found in [1] and for invariants $P_x$, $P_y$, $S_x$, $S_y$ in [2].

These invariants are classicaly used in visual servoing to control the out-of-plane rotations. The C-type or P-type invariants are used for non-symmetric objects whereas the S-type invariants are used for symmetric objects.

For most cases of non-symmetric objects, ( $C_4$, $C_6$) or ( $P_x$, $P_y$) couples are widely used to control x and y rotations. For symmetric objects $S_x$ and $S_y$ are the only choice.

There are 14 translation+rotation+scale invariants (10 C-type, 2 P-type and 2 S-type) that can be accessed from by vpMomentCInvariant::get or any of the get shortcuts.

The example below shows how to retrieve the $C_2$ invariant:

#include <visp/vpMomentObject.h>
#include <visp/vpPoint.h>
#include <visp/vpMomentCInvariant.h>
#include <visp/vpMomentCommon.h>
#include <iostream>
int main()
{
std::vector<vpPoint> vec_p;
p.set_x(6); 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(3); // coordinates in meters in the image plane (vertex 2)
vec_p.push_back(p);
p.set_x(0); p.set_y(1.2); // coordinates in meters in the image plane (vertex 1)
vec_p.push_back(p);
p.set_x(-7); p.set_y(-4); // coordinates in meters in the image plane (vertex 2)
vec_p.push_back(p);
vpMomentObject obj(5); // Create an image moment object with 5 as maximum order
obj.setType(vpMomentObject::DISCRETE); // Discrete mode for object
obj.fromVector(vec_p);
//initialisation with default values
bool success;
db.updateAll(obj); // Update AND compute all moments
//get C-invariant
vpMomentCInvariant& C = static_cast<vpMomentCInvariant&>(db.get("vpMomentCInvariant",success));
if(success)
std::cout << C.get(1) << std:: endl; // print C2 invariant
else
std::cout << "vpMomentCInvariant not found." << std::endl;
return 0;
}

vpMomentCInvariant depends on vpMomentCentered (see vpMomentDatabase and vpMomentCommon).

Definition at line 120 of file vpMomentCInvariant.h.

Constructor & Destructor Documentation

vpMomentCInvariant::vpMomentCInvariant ( )

Default constructor.

Definition at line 49 of file vpMomentCInvariant.cpp.

References vpMoment::values.

Member Function Documentation

double vpMomentCInvariant::C1 ( )
inline

Shorcut for getting the value of $C_1$.

Definition at line 136 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C10 ( )
inline

Shorcut for getting the value of $C_{10}$.

Definition at line 172 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C2 ( )
inline

Shorcut for getting the value of $C_2$.

Definition at line 140 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C3 ( )
inline

Shorcut for getting the value of $C_3$.

Definition at line 144 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C4 ( )
inline

Shorcut for getting the value of $C_4$.

Definition at line 148 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C5 ( )
inline

Shorcut for getting the value of $C_5$.

Definition at line 152 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C6 ( )
inline

Shorcut for getting the value of $C_6$.

Definition at line 156 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C7 ( )
inline

Shorcut for getting the value of $C_7$.

Definition at line 160 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C8 ( )
inline

Shorcut for getting the value of $C_8$.

Definition at line 164 of file vpMomentCInvariant.h.

double vpMomentCInvariant::C9 ( )
inline

Shorcut for getting the value of $C_9$.

Definition at line 168 of file vpMomentCInvariant.h.

void vpMomentCInvariant::compute ( )
virtual

Computes translation-plane-rotation-scale invariants. Depends on vpMomentCentered. All possible invariants are computed here. The selection of the invariant is done afterwards.

Implements vpMoment.

Definition at line 162 of file vpMomentCInvariant.cpp.

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

Referenced by vpMomentCommon::updateAll().

double vpMomentCInvariant::get ( unsigned int  i)
inline

Gets the desired invariant.

Parameters
igiven index. For invariants from C1 to C10 the corresponding index is from 0 to 9. For $S_x$, $S_y$ the indexes are 10,11 and for $P_x$, $P_y$ they are 12,13.

Definition at line 180 of file vpMomentCInvariant.h.

double vpMomentCInvariant::getC ( unsigned int  i)
inline

Access to partial invariant c (see [2]).

Definition at line 185 of file vpMomentCInvariant.h.

Referenced by vpFeatureMomentCInvariant::compute_interaction().

double vpMomentCInvariant::getI ( unsigned int  index)
inline

Access to partial invariants. The index convention is the same as in [1].

Definition at line 189 of file vpMomentCInvariant.h.

Referenced by vpFeatureMomentCInvariant::compute_interaction().

double vpMomentCInvariant::getII ( unsigned int  i)
inline

Access to partial invariant I (see [2]).

Definition at line 194 of file vpMomentCInvariant.h.

Referenced by vpFeatureMomentCInvariant::compute_interaction().

double vpMomentCInvariant::getK ( )
inline

Access to partial invariant K (see [2]).

Definition at line 198 of file vpMomentCInvariant.h.

vpMomentDatabase& vpMoment::getMoments ( )
inlineprotectedinherited

Returns the linked moment database.

Returns
the moment database

Definition at line 115 of file vpMoment.h.

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

double vpMomentCInvariant::getS ( unsigned int  i)
inline

Access to partial invariant S (see [2]).

Definition at line 203 of file vpMomentCInvariant.h.

Referenced by vpFeatureMomentCInvariant::compute_interaction().

void vpMoment::linkTo ( vpMomentDatabase moments)
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
moments: database of moment primitives.

Definition at line 104 of file vpMoment.cpp.

References vpMoment::name().

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

const char* vpMomentCInvariant::name ( )
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 208 of file vpMomentCInvariant.h.

void vpMomentCInvariant::printI ( unsigned int  index)

Print partial invariant.

Prints the temporary invariants. Used for debug purposes only

Parameters
index: index of the temporary invariant

Definition at line 209 of file vpMomentCInvariant.cpp.

double vpMomentCInvariant::Px ( )
inline

Shorcut for getting the value of $P_x$.

Definition at line 218 of file vpMomentCInvariant.h.

double vpMomentCInvariant::Py ( )
inline

Shorcut for getting the value of $P_y$.

Definition at line 222 of file vpMomentCInvariant.h.

double vpMomentCInvariant::Sx ( )
inline

Shorcut for getting the value of $S_x$.

Definition at line 227 of file vpMomentCInvariant.h.

double vpMomentCInvariant::Sy ( )
inline

Shorcut for getting the value of $S_y$.

Definition at line 231 of file vpMomentCInvariant.h.

void vpMoment::update ( vpMomentObject object)
inherited

Updates the moment with the current object. This does not compute any values.

Parameters
object: object descriptor of the current camera vision.

Definition at line 117 of file vpMoment.cpp.

Friends And Related Function Documentation

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

Outputs the moment's values to a stream.

Definition at line 216 of file vpMomentCInvariant.cpp.

Member Data Documentation