Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpCylinder Class Reference

#include <visp3/core/vpCylinder.h>

+ Inheritance diagram for vpCylinder:

Public Types

enum  vpLineCylinderType { line1, line2 }
 
enum  vpForwardProjectionDeallocatorType { user, vpDisplayForwardProjection }
 

Public Member Functions

 vpCylinder ()
 
 vpCylinder (const vpColVector &oP)
 
 vpCylinder (double A, double B, double C, double X0, double Y0, double Z0, double R)
 
virtual ~vpCylinder ()
 
void changeFrame (const vpHomogeneousMatrix &cMo, vpColVector &cP)
 
void changeFrame (const vpHomogeneousMatrix &cMo)
 
double computeZ (double x, double y) const
 
void display (const vpImage< unsigned char > &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)
 
vpCylinderduplicate () const
 
double getRho1 () const
 
double getTheta1 () const
 
double getRho2 () const
 
double getTheta2 () const
 
double getA () const
 
double getB () const
 
double getC () const
 
double getX () const
 
double getY () const
 
double getZ () const
 
double getR () const
 
void init ()
 
void projection ()
 
void projection (const vpColVector &cP, vpColVector &p)
 
void setWorldCoordinates (const vpColVector &oP)
 
void setWorldCoordinates (double A, double B, double C, double X0, double Y0, double Z0, double R)
 
void project ()
 
void project (const vpHomogeneousMatrix &cMo)
 
void track (const vpHomogeneousMatrix &cMo)
 
virtual void print () const
 
void setDeallocate (vpForwardProjectionDeallocatorType d)
 
vpForwardProjectionDeallocatorType getDeallocate ()
 

Public Attributes

vpColVector oP
 
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

Detailed Description

Class that defines what is a cylinder.

A cylinder may be represented by the equation: $ (X - X_0)^2 + (Y - Y_0)^2 + (Z - Z_0)^2 - (A \; X + B \; Y + C \; Z)^2 - R^2 = 0 $ with

$ \left\{ \begin{array}{l} A^2 + B^2 + C^2 = 1 \\ A \; X_0 + B \; Y_0 + C \; Z_0 = 0 \end{array} \right. $

where $R$ is the radius of the cylinder, $A, B, C$ are the coordinates of its direction vector and $X_0, Y_0, Z_0$ are the coordinates of the nearest point belonging to the cylinder axis from the projection center.

Setting the cylinder parameters is achieved throw the constructors with parameters or the setWorldCoordinates() methods.

Considering the set of parameters $^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)$ expressed in the world frame, cylinder coordinates expressed in the camera frame are obtained using changeFrame().

The projection of a cylinder on the image plane is (for non-degenerated cases) a set of two straight lines with equation:

$ \left\{ \begin{array}{lll} x \;\cos\theta_1 + x \;\sin\theta_1 - \rho_1 = 0 \\ y \;\cos\theta_2 + y \;\sin\theta_2 - \rho_2 = 0 \end{array} \right. $

The projection is achieved using projection() methods. The methods getRho1(), getTheta1() and getRho2(), getTheta2() allow to access to the projected line parameters.

Examples:
manGeometricFeatures.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoSimuCylinder.cpp, servoSimuCylinder2DCamVelocityDisplay.cpp, and servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp.

Definition at line 96 of file vpCylinder.h.

Member Enumeration Documentation

◆ vpForwardProjectionDeallocatorType

Used for memory issue especially in the vpServo class.

Enumerator
user 
vpDisplayForwardProjection 

Definition at line 211 of file vpForwardProjection.h.

◆ vpLineCylinderType

Enumerator
line1 

First limb of the cylinder.

line2 

Second limb of the cylinder.

Definition at line 99 of file vpCylinder.h.

Constructor & Destructor Documentation

◆ vpCylinder() [1/3]

vpCylinder::vpCylinder ( )

Default constructor.

Definition at line 95 of file vpCylinder.cpp.

References init().

Referenced by duplicate().

◆ vpCylinder() [2/3]

vpCylinder::vpCylinder ( const vpColVector o_P)
explicit

Create and initialize a cylinder with parameters $^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)$ expressed in the world frame.

Parameters
o_P: Vector of parameters $^{o}{\bf P}$.
vpCylinder cylinder;
double A, B, C, X0, Y0, Z0, R;
...
oP[0] = A;
...
oP[3] = X0;
...
oP[6] = R;
vpCylinder cylinder(oP);
See also
setWorldCoordinates(const vpColVector&)

Definition at line 118 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

◆ vpCylinder() [3/3]

vpCylinder::vpCylinder ( double  A,
double  B,
double  C,
double  X0,
double  Y0,
double  Z0,
double  R 
)

Create and initialize a cylinder with parameters $^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)$ expressed in the world frame.

Parameters
A,B,C,X0,Y0,Z0,R: Cylinder parameters $^{o}{\bf P}$.
See also
setWorldCoordinates(const double,const double,const double,const double,const double,const double,const double)

Definition at line 134 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

◆ ~vpCylinder()

vpCylinder::~vpCylinder ( )
virtual

Default constructor.

Definition at line 143 of file vpCylinder.cpp.

Member Function Documentation

◆ changeFrame() [1/2]

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

From the cylinder parameters $^{o}{\bf P}$ expressed in the world frame, compute the cylinder parameters $^{c}{\bf P}$ expressed in the camera frame.

Parameters
cMo: Camera to world frame transformation.
cP_[out] : Parameters $^{c}{\bf P}$ expressed in the camera frame.
See also
changeFrame(const vpHomogeneousMatrix &)

Implements vpForwardProjection.

Definition at line 270 of file vpCylinder.cpp.

References vpForwardProjection::oP.

Referenced by changeFrame(), vpMbtDistanceKltCylinder::computeInteractionMatrixAndResidu(), vpMbtDistanceCylinder::computeInteractionMatrixError(), display(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceKltCylinder::init(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ changeFrame() [2/2]

void vpCylinder::changeFrame ( const vpHomogeneousMatrix cMo)
virtual

From the cylinder parameters $^{o}{\bf P}$ expressed in the world frame, compute the cylinder internal parameters $^{c}{\bf P}$ expressed in the camera frame.

Parameters
cMo: Camera to world frame transformation.
See also
changeFrame(const vpHomogeneousMatrix &, vpColVector &)

Implements vpForwardProjection.

Definition at line 257 of file vpCylinder.cpp.

References changeFrame(), and vpTracker::cP.

◆ computeZ()

double vpCylinder::computeZ ( double  x,
double  y 
) const

Compute the Z coordinate for the given normalized coordinate in the camera frame.

Definition at line 363 of file vpCylinder.cpp.

References getA(), getB(), getC(), getR(), getX(), getY(), and getZ().

Referenced by vpMbtDistanceKltCylinder::getModelForDisplay().

◆ display() [1/2]

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

Display the projection of the cylinder in the image as two lines.

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp.

Definition at line 395 of file vpCylinder.cpp.

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

◆ display() [2/2]

void vpCylinder::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 the cylinder in the image as two lines.

Implements vpForwardProjection.

Definition at line 382 of file vpCylinder.cpp.

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

◆ duplicate()

vpCylinder * vpCylinder::duplicate ( ) const
virtual

for memory issue (used by the vpServo class only)

Implements vpForwardProjection.

Definition at line 373 of file vpCylinder.cpp.

References vpCylinder().

◆ getA()

double vpCylinder::getA ( ) const
inline

Return cylinder $A$ parameter expressed in the camera frame.

Definition at line 150 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getB()

double vpCylinder::getB ( ) const
inline

Return cylinder $B$ parameter expressed in the camera frame.

Definition at line 154 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getC()

double vpCylinder::getC ( ) const
inline

Return cylinder $C$ parameter expressed in the camera frame.

Definition at line 158 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getDeallocate()

vpForwardProjectionDeallocatorType vpForwardProjection::getDeallocate ( )
inlineinherited

Definition at line 220 of file vpForwardProjection.h.

◆ getR()

double vpCylinder::getR ( ) const
inline

Return cylinder $R$ parameter corresponding to the cylinder radius.

Definition at line 174 of file vpCylinder.h.

References vpForwardProjection::init(), vpForwardProjection::projection(), and vpForwardProjection::setWorldCoordinates().

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getRho1()

double vpCylinder::getRho1 ( ) const
inline

Return the $\rho_1$ parameter of the line corresponding to the projection of the cylinder in the image plane.

See also
getTheta1()

Definition at line 126 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ getRho2()

double vpCylinder::getRho2 ( ) const
inline

Return the $\rho_2$ parameter of the line corresponding to the projection of the cylinder in the image plane.

See also
getTheta2()

Definition at line 139 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ getTheta1()

double vpCylinder::getTheta1 ( ) const
inline

Return the $\theta_1$ parameter of the line corresponding to the projection of the cylinder in the image plane.

See also
getRho1()

Definition at line 132 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ getTheta2()

double vpCylinder::getTheta2 ( ) const
inline

Return the $\theta_2$ parameter of the line corresponding to the projection of the cylinder in the image plane.

See also
getRho2()

Definition at line 145 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ getX()

double vpCylinder::getX ( ) const
inline

Return cylinder $X_0$ parameter expressed in the camera frame.

Definition at line 162 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getY()

double vpCylinder::getY ( ) const
inline

Return cylinder $Y_0$ parameter expressed in the camera frame.

Definition at line 166 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ getZ()

double vpCylinder::getZ ( ) const
inline

Return cylinder $Z_0$ parameter expressed in the camera frame.

Definition at line 170 of file vpCylinder.h.

Referenced by computeZ(), and vpFeatureBuilder::create().

◆ init()

void vpCylinder::init ( )
virtual

Default initialisation of the feature parameters:

  • in the object frame: oP
  • in the camera frame: cP
  • in the image plane: p.

Implements vpForwardProjection.

Definition at line 42 of file vpCylinder.cpp.

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

Referenced by vpCylinder().

◆ 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(), vpForwardProjection::projection(), and vpERROR_TRACE.

◆ projection() [1/2]

void vpCylinder::projection ( )
virtual

Perspective projection of the cylinder.

From the parameters of the cylinder in the camera frame, compute the perspective projection of the cylinder in the image plane.

vpCylinder cylinder;
// Initialize oP[] with A,B,C,X0,X0,Z0,R parameters
cylinder.setWorldCoordinates(oP); // Set the cylinder world frame parameters
vpHomogeneousMatrix cMo; // Camera to world frame transformation
cylinder.changeFrame(cMo); // Update internal cP parameters
cylinder.projection(); // Compute the perspective projection
See also
projection(const vpColVector &, vpColVector &)

Implements vpForwardProjection.

Definition at line 165 of file vpCylinder.cpp.

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

Referenced by vpMbtDistanceCylinder::computeInteractionMatrixError(), display(), vpMbtDistanceKltCylinder::getModelForDisplay(), vpMbtDistanceCylinder::getModelForDisplay(), vpMbtDistanceCylinder::initMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

◆ projection() [2/2]

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

Perspective projection of the cylinder.

From the parameters of the cylinder in the camera frame $c{\bf P}$, compute the perspective projection of the cylinder in the image plane.

Parameters
cP_[in] : Cylinder parameters in the camera frame.
p_[out] : Parameters of the cylinder in the image plane obtained by perspective projection.
Exceptions
vpException::fatalError: The camera is inside the cylinder.
vpCylinder cylinder;
// Initialize oP[] with A,B,C,X0,X0,Z0,R parameters
cylinder.setWorldCoordinates(oP); // Set the cylinder world frame parameters
vpHomogeneousMatrix cMo; // Camera to world frame transformation
vpColVector cP(7); // Parameters of the cylinder in the
camera frame cylinder.changeFrame(cMo, cP); // Update cP parameters
vpColVector p(4); // Parameters of the cylinder in the image
plane cylinder.projection(cP, p); // Compute the perspective
projection and update p
See also
projection()

Implements vpForwardProjection.

Definition at line 195 of file vpCylinder.cpp.

References vpException::fatalError.

◆ setDeallocate()

void vpForwardProjection::setDeallocate ( vpForwardProjectionDeallocatorType  d)
inlineinherited

Definition at line 219 of file vpForwardProjection.h.

◆ setWorldCoordinates() [1/2]

void vpCylinder::setWorldCoordinates ( const vpColVector o_P)
virtual

Set the cylinder parameters $^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)$ expressed in the world frame.

Parameters
o_P: Vector of parameters $^{o}{\bf P}$.
vpCylinder cylinder;
double A, B, C, X0, Y0, Z0, R;
...
vpColVector oP(7);
oP[0] = A;
...
oP[3] = X0;
...
oP[6] = R;

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp.

Definition at line 71 of file vpCylinder.cpp.

References vpForwardProjection::oP.

Referenced by vpMbtDistanceKltCylinder::buildFrom(), vpMbtDistanceCylinder::buildFrom(), and vpCylinder().

◆ setWorldCoordinates() [2/2]

void vpCylinder::setWorldCoordinates ( double  A,
double  B,
double  C,
double  X0,
double  Y0,
double  Z0,
double  R 
)

Set the cylinder parameters $^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)$ expressed in the world frame.

Parameters
A,B,C,X0,Y0,Z0,R: Cylinder parameters $^{o}{\bf P}$.

Definition at line 81 of file vpCylinder.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, 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 111 of file vpForwardProjection.cpp.

References vpForwardProjection::project(), and vpERROR_TRACE.

Referenced by vpPoseFeatures::addFeatureSegment(), vpPose::computeResidual(), vpProjectionDisplay::displayCamera(), ImageDisplay(withContext)::displayFrameWithContext:::::, 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 81 of file vpTracker.h.

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

◆ oP

◆ p