Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpSphere Class Reference

#include <visp3/core/vpSphere.h>

+ Inheritance diagram for vpSphere:

Public Types

enum  vpForwardProjectionDeallocatorType { user, vpDisplayForwardProjection }
 

Public Member Functions

 vpSphere ()
 
 vpSphere (const vpColVector &oP)
 
 vpSphere (double oX, double oY, double oZ, double R)
 
virtual ~vpSphere ()
 
void changeFrame (const vpHomogeneousMatrix &cMo, vpColVector &cP) const
 
void changeFrame (const vpHomogeneousMatrix &cMo)
 
void display (const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
void display (const vpImage< vpRGBa > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
void display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
void display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
vpSphereduplicate () const
 
double get_x () const
 
double get_y () const
 
double get_n20 () const
 
double get_n11 () const
 
double get_n02 () const
 
double getX () const
 
double getY () const
 
double getZ () const
 
double getR () const
 
void projection ()
 
void projection (const vpColVector &cP, vpColVector &p) const
 
void setWorldCoordinates (const vpColVector &oP)
 
void setWorldCoordinates (double oX, double oY, double oZ, double R)
 
Deprecated functions
vp_deprecated double get_mu20 () const
 
vp_deprecated double get_mu11 () const
 
vp_deprecated double get_mu02 () const
 
Public Member Functions Inherited from vpForwardProjection
vpColVector get_oP () const
 
vpForwardProjectionDeallocatorType getDeallocate ()
 
virtual void print () const
 
void project ()
 
void project (const vpHomogeneousMatrix &cMo)
 
void setDeallocate (vpForwardProjectionDeallocatorType d)
 
void track (const vpHomogeneousMatrix &cMo)
 
Public Member Functions Inherited from vpTracker
vpColVector get_p () const
 
vpColVector get_cP () const
 

Public Attributes

Public Attributes Inherited from vpForwardProjection
vpColVector oP
 
Public Attributes Inherited from vpTracker
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

Protected Member Functions

void init ()
 

Detailed Description

Class that defines a 3D sphere in the object frame and allows forward projection of a 3D sphere in the camera frame and in the 2D image plane by perspective projection. All the parameters must be set in meter.

A sphere has the followings parameters:

Examples:
manGeometricFeatures.cpp, servoSimuSphere.cpp, servoSimuSphere2DCamVelocity.cpp, servoSimuSphere2DCamVelocityDisplay.cpp, and servoSimuSphere2DCamVelocityDisplaySecondaryTask.cpp.

Definition at line 82 of file vpSphere.h.

Member Enumeration Documentation

◆ vpForwardProjectionDeallocatorType

Used for memory issue especially in the vpServo class.

Enumerator
user 
vpDisplayForwardProjection 

Definition at line 73 of file vpForwardProjection.h.

Constructor & Destructor Documentation

◆ vpSphere() [1/3]

vpSphere::vpSphere ( )

Default constructor.

Definition at line 84 of file vpSphere.cpp.

References init().

Referenced by duplicate().

◆ vpSphere() [2/3]

vpSphere::vpSphere ( const vpColVector oP_)
explicit

Create a sphere from a 4-dim vector that contains 3D coordinates of its center and its radius. The 3D coordinates of the center are defined in the sphere frame.

Parameters
oP_: 4-dim vector that contains [oX oY oZ R]^T where oX, oY, oZ are the 3D coordinates of the sphere center in [m] expressed in the sphere frame, and R is the sphere radius in [m].

Definition at line 94 of file vpSphere.cpp.

References init(), and setWorldCoordinates().

◆ vpSphere() [3/3]

vpSphere::vpSphere ( double  oX,
double  oY,
double  oZ,
double  R 
)

Create a sphere from the 3D coordinates of its center and its radius. The 3D coordinates of the center are defined in the sphere frame.

Parameters
oX: 3D coordinate of the sphere center along X axis in [m].
oY: 3D coordinate of the sphere center along X axis in [m].
oZ: 3D coordinate of the sphere center along X axis in [m].
R: Sphere radius in [m].

Definition at line 109 of file vpSphere.cpp.

References init(), and setWorldCoordinates().

◆ ~vpSphere()

vpSphere::~vpSphere ( )
virtual

Destructor that does nothing.

Definition at line 118 of file vpSphere.cpp.

Member Function Documentation

◆ changeFrame() [1/2]

void vpSphere::changeFrame ( const vpHomogeneousMatrix cMo,
vpColVector cP_ 
) const
virtual

Perspective projection of the sphere. This method doesn't modify internal sphere parameters cP.

Parameters
cMo: Homogeneous transformation from camera frame to sphere frame.
cP_: Parameters of the sphere in the camera frame (cX, cY, cZ, R).

Implements vpForwardProjection.

Definition at line 215 of file vpSphere.cpp.

References vpForwardProjection::oP, and vpColVector::resize().

Referenced by changeFrame(), and display().

◆ changeFrame() [2/2]

void vpSphere::changeFrame ( const vpHomogeneousMatrix cMo)
virtual

Perspective projection of the sphere. Internal sphere parameters are modified in cP.

Parameters
cMo: Homogeneous transformation from camera frame to object frame.

Implements vpForwardProjection.

Definition at line 206 of file vpSphere.cpp.

References changeFrame(), and vpTracker::cP.

◆ display() [1/4]

void vpSphere::display ( const vpImage< unsigned char > &  I,
const vpCameraParameters cam,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
virtual

Display the projection of a 3D sphere in image I.

Parameters
I: Image used as background.
cam: Camera parameters.
color: Color used to draw the sphere.
thickness: Thickness used to draw the sphere.

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp.

Definition at line 287 of file vpSphere.cpp.

References vpFeatureDisplay::displayEllipse(), and vpTracker::p.

◆ display() [2/4]

void vpSphere::display ( const vpImage< vpRGBa > &  I,
const vpCameraParameters cam,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)

Display the projection of a 3D sphere in image I.

Parameters
I: Image used as background.
cam: Camera parameters.
color: Color used to draw the sphere.
thickness: Thickness used to draw the sphere.

Definition at line 301 of file vpSphere.cpp.

References vpFeatureDisplay::displayEllipse(), and vpTracker::p.

◆ display() [3/4]

void vpSphere::display ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
virtual

Display the projection of a 3D sphere in image I. This method is non destructive wrt. cP and p internal sphere parameters.

Parameters
I: Image used as background.
cMo: Homogeneous transformation from camera frame to object frame. The sphere is considered as viewed from this camera position.
cam: Camera parameters.
color: Color used to draw the sphere.
thickness: Thickness used to draw the sphere.

Implements vpForwardProjection.

Definition at line 250 of file vpSphere.cpp.

References changeFrame(), vpFeatureDisplay::displayEllipse(), and projection().

◆ display() [4/4]

void vpSphere::display ( const vpImage< vpRGBa > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)

Display the projection of a 3D sphere in image I. This method is non destructive wrt. cP and p internal sphere parameters.

Parameters
I: Image used as background.
cMo: Homogeneous transformation from camera frame to object frame. The sphere is considered as viewed from this camera position.
cam: Camera parameters.
color: Color used to draw the sphere.
thickness: Thickness used to draw the sphere.

Definition at line 270 of file vpSphere.cpp.

References changeFrame(), vpFeatureDisplay::displayEllipse(), and projection().

◆ duplicate()

vpSphere * vpSphere::duplicate ( ) const
virtual

For memory issue (used by the vpServo class only).

Implements vpForwardProjection.

Definition at line 233 of file vpSphere.cpp.

References vpSphere().

◆ get_cP()

vpColVector vpTracker::get_cP ( ) const
inlineinherited

Return object parameters expressed in the 3D camera frame.

Definition at line 99 of file vpTracker.h.

◆ get_mu02()

vp_deprecated double vpSphere::get_mu02 ( ) const
inline
Deprecated:
You should rather use get_n02(). This function is incorrectly named and is confusing since it returns second order centered moments of the ellipse normalized by its area that corresponds to $n_02 = mu_02/a$.

Definition at line 151 of file vpSphere.h.

◆ get_mu11()

vp_deprecated double vpSphere::get_mu11 ( ) const
inline
Deprecated:
You should rather use get_n11(). This function is incorrectly named and is confusing since it returns second order centered moments of the ellipse normalized by its area that corresponds to $n_11 = mu_11/a$.

Definition at line 144 of file vpSphere.h.

◆ get_mu20()

vp_deprecated double vpSphere::get_mu20 ( ) const
inline
Deprecated:
You should rather use get_n20(). This function is incorrectly named and is confusing since it returns second order centered moments of the ellipse normalized by its area that corresponds to $n_20 = mu_20/a$.

Definition at line 137 of file vpSphere.h.

◆ get_n02()

double vpSphere::get_n02 ( ) const
inline
Examples:
servoSimuSphere.cpp.

Definition at line 109 of file vpSphere.h.

◆ get_n11()

double vpSphere::get_n11 ( ) const
inline
Examples:
servoSimuSphere.cpp.

Definition at line 108 of file vpSphere.h.

◆ get_n20()

double vpSphere::get_n20 ( ) const
inline
Examples:
servoSimuSphere.cpp.

Definition at line 107 of file vpSphere.h.

◆ get_oP()

vpColVector vpForwardProjection::get_oP ( ) const
inlineinherited

Return object parameters expressed in the 3D object frame.

Definition at line 165 of file vpForwardProjection.h.

◆ get_p()

vpColVector vpTracker::get_p ( ) const
inlineinherited

Return object parameters expressed in the 2D image plane computed by perspective projection.

Definition at line 97 of file vpTracker.h.

◆ get_x()

double vpSphere::get_x ( ) const
inline
Examples:
servoSimuSphere.cpp.

Definition at line 104 of file vpSphere.h.

◆ get_y()

double vpSphere::get_y ( ) const
inline
Examples:
servoSimuSphere.cpp.

Definition at line 105 of file vpSphere.h.

◆ getDeallocate()

vpForwardProjectionDeallocatorType vpForwardProjection::getDeallocate ( )
inlineinherited

Definition at line 167 of file vpForwardProjection.h.

◆ getR()

double vpSphere::getR ( ) const
inline

◆ getX()

double vpSphere::getX ( ) const
inline

Definition at line 111 of file vpSphere.h.

◆ getY()

double vpSphere::getY ( ) const
inline

Definition at line 112 of file vpSphere.h.

◆ getZ()

double vpSphere::getZ ( ) const
inline

Definition at line 113 of file vpSphere.h.

◆ init()

void vpSphere::init ( )
protectedvirtual

Initialize internal sphere parameters.

Implements vpForwardProjection.

Definition at line 45 of file vpSphere.cpp.

References vpTracker::cP, vpForwardProjection::oP, vpTracker::p, and vpColVector::resize().

Referenced by vpSphere().

◆ print()

void vpForwardProjection::print ( ) const
virtualinherited

Print to stdout the feature parameters in:

  • the object frame
  • the camera frame
  • the image plane.
Examples:
servoSimuCircle2DCamVelocityDisplay.cpp, servoSimuLine2DCamVelocityDisplay.cpp, and servoSimuSquareLine2DCamVelocityDisplay.cpp.

Definition at line 53 of file vpForwardProjection.cpp.

References vpTracker::cP, vpForwardProjection::oP, vpTracker::p, and vpColVector::t().

◆ project() [1/2]

◆ project() [2/2]

void vpForwardProjection::project ( const vpHomogeneousMatrix cMo)
inherited

Compute the feature parameters in the camera frame (vpTracker::cP) and than compute the projection of these parameters in the image plane (vpTracker::p).

Warning
The feature parameters in the object frame (vpForwardProjection:oP) need to be set prior the use of this method. To initialize these parameters see setWorldCoordinates().
Parameters
cMo: The homogeneous matrix corresponding to the pose between the camera frame and the object frame.

Definition at line 84 of file vpForwardProjection.cpp.

References vpForwardProjection::changeFrame(), and vpForwardProjection::projection().

◆ projection() [1/2]

void vpSphere::projection ( )
virtual

Perspective projection of the sphere. This method updates internal parameters (cP and p).

See vpSphere::projection(const vpColVector &, vpColVector &) const for a more detailed description of the parameters.

Implements vpForwardProjection.

Definition at line 127 of file vpSphere.cpp.

References vpTracker::cP, and vpTracker::p.

Referenced by display().

◆ projection() [2/2]

void vpSphere::projection ( const vpColVector cP_,
vpColVector p_ 
) const
virtual

Perspective projection of the sphere. Internal parameters (cP and p) are not modified.

Parameters
[in]cP_: 4-dim vector corresponding to the sphere parameters in the camera frame.
[out]p_: 5-dim vector corresponding to the sphere parameters in the image plane. It contains the following parameters: x, y, n20, n11, n02 where:
  • x, y are the normalized coordinates of the ellipse centroid (ie the perspective projection of a 3D circle becomes a 2D ellipse in the image) in the image plane.
  • n20, n11, n02 which are the second order centered moments of the ellipse normalized by its area (i.e., such that $n_{ij} = \mu_{ij}/a$ where $\mu_{ij}$ are the centered moments and a the area).

Implements vpForwardProjection.

Definition at line 143 of file vpSphere.cpp.

References vpColVector::resize(), vpMath::sqr(), and vpERROR_TRACE.

◆ setDeallocate()

void vpForwardProjection::setDeallocate ( vpForwardProjectionDeallocatorType  d)
inlineinherited

Definition at line 196 of file vpForwardProjection.h.

References vpTracker::init().

◆ setWorldCoordinates() [1/2]

void vpSphere::setWorldCoordinates ( const vpColVector oP_)
virtual

Set sphere 3D parameters from a 4-dim vector that contains 3D coordinates of its center and its radius. The 3D coordinates of the center are defined in the sphere frame.

Parameters
oP_: 4-dim vector that contains [oX oY oZ R]^T where oX, oY, oZ are the 3D coordinates of the sphere center in [m] expressed in the object frame, and R is the sphere radius in [m].

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp, servoSimuSphere2DCamVelocity.cpp, servoSimuSphere2DCamVelocityDisplay.cpp, and servoSimuSphere2DCamVelocityDisplaySecondaryTask.cpp.

Definition at line 62 of file vpSphere.cpp.

References vpForwardProjection::oP.

Referenced by vpSphere().

◆ setWorldCoordinates() [2/2]

void vpSphere::setWorldCoordinates ( double  oX,
double  oY,
double  oZ,
double  R 
)

Set sphere 3D parameters from the 3D coordinates of its center and its radius. The 3D coordinates of the center are defined in the sphere frame.

Parameters
oX: 3D coordinate of the sphere center along X axis in [m].
oY: 3D coordinate of the sphere center along X axis in [m].
oZ: 3D coordinate of the sphere center along X axis in [m].
R: Sphere radius in [m].

Definition at line 73 of file vpSphere.cpp.

References vpForwardProjection::oP.

◆ track()

void vpForwardProjection::track ( const vpHomogeneousMatrix cMo)
inherited

Track the feature parameters in the camera frame (vpTracker::cP) and than compute the projection of these parameters in the image plane (vpTracker::p).

This method is similar to project(const vpHomogeneousMatrix &).

Warning
The feature parameters in the object frame (vpForwardProjection:oP) need to be set prior the use of this method. To initialize these parameters see setWorldCoordinates().
Parameters
cMo: The homogeneous matrix corresponding to the pose between the camera frame and the object frame.
Examples:
mbot-apriltag-ibvs.cpp, servoBebop2.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCircle2DCamVelocity.cpp, servoSimuCircle2DCamVelocityDisplay.cpp, servoSimuCylinder.cpp, servoSimuFourPoints2DCamVelocity.cpp, servoSimuFourPoints2DCamVelocityDisplay.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoSimuLine2DCamVelocityDisplay.cpp, servoSimuSphere.cpp, servoSimuSphere2DCamVelocity.cpp, servoSimuSphere2DCamVelocityDisplay.cpp, servoSimuSphere2DCamVelocityDisplaySecondaryTask.cpp, servoSimuSquareLine2DCamVelocityDisplay.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, tutorial-ibvs-4pts-ogre.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-ibvs-4pts.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, tutorial-simu-pioneer-pan.cpp, and tutorial-simu-pioneer.cpp.

Definition at line 106 of file vpForwardProjection.cpp.

References vpForwardProjection::project().

Referenced by vpPoseFeatures::addFeatureSegment(), vpPose::computeResidual(), vpProjectionDisplay::displayCamera(), vpImageDraw::drawFrame(), vpPose::poseVirtualVS(), vpPose::poseVirtualVSrobust(), vpWireFrameSimulator::projectCameraTrajectory(), vpSimulatorAfma6::updateArticularPosition(), and vpSimulatorViper850::updateArticularPosition().

Member Data Documentation

◆ cP

◆ cPAvailable

bool vpTracker::cPAvailable
inherited

Flag used to indicate if the feature parameters cP expressed in the camera frame are available.

Definition at line 83 of file vpTracker.h.

Referenced by vpTracker::init(), and vpTracker::operator=().

◆ oP

◆ p