Visual Servoing Platform  version 3.6.1 under development (2024-04-26)
vpFeatureMomentDatabase Class Reference

#include <visp3/visual_features/vpFeatureMomentDatabase.h>

+ Inheritance diagram for vpFeatureMomentDatabase:

Public Member Functions

 vpFeatureMomentDatabase ()
 
virtual ~vpFeatureMomentDatabase ()
 
virtual void updateAll (double A=0.0, double B=0.0, double C=1.0)
 
vpFeatureMomentget (const std::string &feature_name, bool &found)
 

Friends

class vpFeatureMoment
 

Detailed Description

This class allows to register all feature moments (implemented in vpFeatureMoment... classes) so they can access each other according to their dependencies.

Like moments (implemented in vpMoment... classes), a vpFeatureMoment needs to have access to other vpFeatureMoment's values to be computed. In most cases, a vpFeatureMoment needs both: vpMoments and vpFeatureMoments which explains the two databases (see vpFeatureMoment::vpFeatureMoment). For example vpFeatureMomentAlpha needs additional information about centered moments vpMomentCentered AND their interaction matrices obtained by vpFeatureMomentCentered in order to compute the moment's value from a vpMomentObject. Like the vpMomentCentered is stored in a vpMomentDatabase, the vpFeatureMomentCentered should be stored in a vpFeatureMomentDatabase.

All moment features in a database can access each other freely at any time. They can also verify if a moment feature is present in the database or not. This code illustrates the use of both databases to handle dependencies between moment primitives and moment features:

#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMomentBasic.h>
#include <visp3/core/vpMomentCInvariant.h>
#include <visp3/core/vpMomentCentered.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentObject.h>
#include <iostream>
#include <vector>
#include <visp3/visual_features/vpFeatureMomentBasic.h>
#include <visp3/visual_features/vpFeatureMomentCInvariant.h>
#include <visp3/visual_features/vpFeatureMomentCentered.h>
#include <visp3/visual_features/vpFeatureMomentDatabase.h>
int main()
{
try {
std::vector<vpPoint> vec_p; // vector that contains the vertices
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);
vpMomentObject obj(6); // Init object of order 6 because we are
// computing C-invariants
obj.setType(vpMomentObject::DISCRETE); // Discrete mode for object
obj.fromVector(vec_p);
vpMomentDatabase mdb; // database for moment primitives. This will
// only contain the basic moment.
vpMomentCentered mc; // Centered moment
vpMomentBasic bm; // Basic moment
vpMomentGravityCenter gc; // gravity center
vpMomentCInvariant ci; // C-type invariant
bm.linkTo(mdb); //add basic moment to moment database
mc.linkTo(mdb); //add centered moment to moment database
gc.linkTo(mdb); //add gravity center to moment database
ci.linkTo(mdb); //add C-invariant to moment database
vpFeatureMomentDatabase fmdb; // feature moment database to store
// feature dependencies
// Declare and link moments to database
vpFeatureMomentBasic fmb(mdb,0.,0.,1.,&fmdb); fmb.linkTo(fmdb);
vpFeatureMomentCentered fmc(mdb,0.,0.,1.,&fmdb); fmc.linkTo(fmdb);
vpFeatureMomentCInvariant fci(mdb,0.,0.,1.,&fmdb); fci.linkTo(fmdb);
// update the whole moment database
mdb.updateAll(obj);
// Compute moments in the correct order with the object
bm.compute();
gc.compute();
mc.compute();
ci.compute();
// update the whole feature moment database with a plane
fmb.update(0.,0.,1.);
fmc.update(0.,0.,1.);
fci.update(0.,0.,1.);
std::cout << fci.interaction(vpFeatureMomentCInvariant::selectC1()) << std::endl;
}
catch(const vpException &e){
std::cout << e.getMessage() << std::endl;
}
return 0;
}
error that can be emitted by ViSP classes.
Definition: vpException.h:59
const char * getMessage() const
Definition: vpException.cpp:64
Functionality computation for basic moment feature. Computes the interaction matrix associated with v...
Functionality computation for 2D rotation/translation/scale non-symmetric invariant moment feature....
Functionality computation for centered moment feature. Computes the interaction matrix associated wit...
This class allows to register all feature moments (implemented in vpFeatureMoment....
This class defines the 2D basic moment . This class is a wrapper for vpMomentObject wich allows to us...
Definition: vpMomentBasic.h:70
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:95
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:77
void set_x(double x)
Set the point x coordinate in the image plane.
Definition: vpPoint.cpp:504
void set_y(double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.cpp:506

Definition at line 153 of file vpFeatureMomentDatabase.h.

Constructor & Destructor Documentation

◆ vpFeatureMomentDatabase()

vpFeatureMomentDatabase::vpFeatureMomentDatabase ( )
inline

Default constructor.

Definition at line 168 of file vpFeatureMomentDatabase.h.

◆ ~vpFeatureMomentDatabase()

virtual vpFeatureMomentDatabase::~vpFeatureMomentDatabase ( )
inlinevirtual

Virtual destructor that does nothing.

Definition at line 173 of file vpFeatureMomentDatabase.h.

Member Function Documentation

◆ get()

vpFeatureMoment & vpFeatureMomentDatabase::get ( const std::string &  feature_name,
bool &  found 
)

Retrieves a moment feature from the database

Parameters
feature_name: The name of the feature, the one specified when using add
found: true if the type string is found inside the database, false otherwise
Returns
the moment feature corresponding to the type string

Definition at line 59 of file vpFeatureMomentDatabase.cpp.

Referenced by vpFeatureMomentArea::compute_interaction(), vpFeatureMomentCentered::compute_interaction(), and vpFeatureMomentCInvariant::compute_interaction().

◆ updateAll()

void vpFeatureMomentDatabase::updateAll ( double  A = 0.0,
double  B = 0.0,
double  C = 1.0 
)
virtual

Update all moment features in the database with plane coefficients

Parameters
A: first plane coefficient for a plane equation of the following type Ax+By+C=1/Z
B: second plane coefficient for a plane equation of the following type Ax+By+C=1/Z
C: third plane coefficient for a plane equation of the following type Ax+By+C=1/Z

Reimplemented in vpFeatureMomentCommon.

Definition at line 74 of file vpFeatureMomentDatabase.cpp.

Friends And Related Function Documentation

◆ vpFeatureMoment

friend class vpFeatureMoment
friend

Definition at line 181 of file vpFeatureMomentDatabase.h.