Visual Servoing Platform  version 3.2.0 under development (2018-10-21)
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 (const double A, const double B, const double C, const double X0, const double Y0, const double Z0, const double R)
 
virtual ~vpCylinder ()
 
void changeFrame (const vpHomogeneousMatrix &cMo, vpColVector &cP)
 
void changeFrame (const vpHomogeneousMatrix &cMo)
 
double computeZ (const double x, const double y) const
 
void display (const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, const unsigned int thickness=1)
 
void display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color=vpColor::green, const 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 (const double A, const double B, const double C, const double X0, const double Y0, const double Z0, const 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

Used for memory issue especially in the vpServo class.

Enumerator
user 
vpDisplayForwardProjection 

Definition at line 211 of file vpForwardProjection.h.

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::vpCylinder ( )

Default constructor.

Definition at line 96 of file vpCylinder.cpp.

References init().

Referenced by duplicate().

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 119 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

vpCylinder::vpCylinder ( const double  A,
const double  B,
const double  C,
const double  X0,
const double  Y0,
const double  Z0,
const 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 135 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

vpCylinder::~vpCylinder ( )
virtual

Default constructor.

Definition at line 145 of file vpCylinder.cpp.

Member Function Documentation

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 272 of file vpCylinder.cpp.

References vpForwardProjection::oP.

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

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 259 of file vpCylinder.cpp.

References changeFrame(), and vpTracker::cP.

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

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

Definition at line 365 of file vpCylinder.cpp.

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

Referenced by vpMbtDistanceKltCylinder::display().

void vpCylinder::display ( const vpImage< unsigned char > &  I,
const vpCameraParameters cam,
const vpColor color = vpColor::green,
const 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 397 of file vpCylinder.cpp.

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

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

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

Implements vpForwardProjection.

Definition at line 384 of file vpCylinder.cpp.

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

vpCylinder * vpCylinder::duplicate ( ) const
virtual

for memory issue (used by the vpServo class only)

Implements vpForwardProjection.

Definition at line 375 of file vpCylinder.cpp.

References vpCylinder().

double vpCylinder::getA ( ) const
inline

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

Definition at line 151 of file vpCylinder.h.

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

double vpCylinder::getB ( ) const
inline

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

Definition at line 155 of file vpCylinder.h.

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

double vpCylinder::getC ( ) const
inline

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

Definition at line 159 of file vpCylinder.h.

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

vpForwardProjectionDeallocatorType vpForwardProjection::getDeallocate ( )
inlineinherited

Definition at line 220 of file vpForwardProjection.h.

double vpCylinder::getR ( ) const
inline

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

Definition at line 175 of file vpCylinder.h.

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

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

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 127 of file vpCylinder.h.

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

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 140 of file vpCylinder.h.

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

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 133 of file vpCylinder.h.

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

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 146 of file vpCylinder.h.

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

double vpCylinder::getX ( ) const
inline

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

Definition at line 163 of file vpCylinder.h.

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

double vpCylinder::getY ( ) const
inline

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

Definition at line 167 of file vpCylinder.h.

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

double vpCylinder::getZ ( ) const
inline

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

Definition at line 171 of file vpCylinder.h.

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

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().

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().

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.

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 167 of file vpCylinder.cpp.

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

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

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 197 of file vpCylinder.cpp.

References vpException::fatalError.

void vpForwardProjection::setDeallocate ( vpForwardProjectionDeallocatorType  d)
inlineinherited

Definition at line 219 of file vpForwardProjection.h.

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().

void vpCylinder::setWorldCoordinates ( const double  A,
const double  B,
const double  C,
const double  X0,
const double  Y0,
const double  Z0,
const 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.

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, 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(), vpPose::poseVirtualVS(), vpPose::poseVirtualVSrobust(), vpWireFrameSimulator::projectCameraTrajectory(), vpSimulatorAfma6::updateArticularPosition(), and vpSimulatorViper850::updateArticularPosition().

Member Data Documentation

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(), vpTracker::operator=(), and vpPoint::operator=().