ViSP  2.8.0

#include <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)
 
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 97 of file vpCylinder.h.

Member Enumeration Documentation

Used for memory issue especially in the vpServo class.

Enumerator
user 
vpDisplayForwardProjection 

Definition at line 219 of file vpForwardProjection.h.

Enumerator
line1 

First limb of the cylinder.

line2 

Second limb of the cylinder.

Definition at line 100 of file vpCylinder.h.

Constructor & Destructor Documentation

vpCylinder::vpCylinder ( )

Default constructor.

Definition at line 109 of file vpCylinder.cpp.

References init().

Referenced by duplicate().

vpCylinder::vpCylinder ( const vpColVector oP)

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
oP: 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 134 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 148 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

vpCylinder::~vpCylinder ( )
virtual

Default constructor.

Definition at line 163 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 302 of file vpCylinder.cpp.

References vpForwardProjection::oP.

Referenced by changeFrame(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpMbtDistanceCylinder::display(), display(), 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 287 of file vpCylinder.cpp.

References changeFrame(), and vpTracker::cP.

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 422 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 403 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 393 of file vpCylinder.cpp.

References vpCylinder().

double vpCylinder::getA ( ) const
inline

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

Definition at line 159 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create().

double vpCylinder::getB ( ) const
inline

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

Definition at line 163 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create().

double vpCylinder::getC ( ) const
inline

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

Definition at line 167 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create().

vpForwardProjectionDeallocatorType vpForwardProjection::getDeallocate ( )
inlineinherited

Definition at line 229 of file vpForwardProjection.h.

double vpCylinder::getR ( ) const
inline

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

Definition at line 183 of file vpCylinder.h.

Referenced by 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 135 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), 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 148 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), 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 141 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), 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 154 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create(), 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 171 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create().

double vpCylinder::getY ( ) const
inline

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

Definition at line 175 of file vpCylinder.h.

Referenced by vpFeatureBuilder::create().

double vpCylinder::getZ ( ) const
inline

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

Definition at line 179 of file vpCylinder.h.

Referenced by 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 48 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, servoSimuSquareLine2DCamVelocityDisplay.cpp, and testPoseRansac.cpp.

Definition at line 63 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 99 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 189 of file vpCylinder.cpp.

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

Referenced by vpMbtDistanceCylinder::computeInteractionMatrixError(), vpMbtDistanceCylinder::display(), 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 223 of file vpCylinder.cpp.

References vpException::fatalError.

void vpForwardProjection::setDeallocate ( vpForwardProjectionDeallocatorType  d)
inlineinherited

Definition at line 228 of file vpForwardProjection.h.

void vpCylinder::setWorldCoordinates ( const vpColVector oP)
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
oP: 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 77 of file vpCylinder.cpp.

References vpForwardProjection::oP.

Referenced by 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 90 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:
manServoMomentsSimple.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCircle2DCamVelocity.cpp, servoSimuCircle2DCamVelocityDisplay.cpp, servoSimuFourPoints2DCamVelocity.cpp, servoSimuFourPoints2DCamVelocityDisplay.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoSimuLine2DCamVelocityDisplay.cpp, servoSimuPoint2DCamVelocity1.cpp, servoSimuPoint2DCamVelocity2.cpp, servoSimuPoint2DCamVelocity3.cpp, servoSimuPoint2DhalfCamVelocity1.cpp, servoSimuPoint2DhalfCamVelocity2.cpp, servoSimuPoint2DhalfCamVelocity3.cpp, servoSimuPoint3DCamVelocity.cpp, servoSimuSphere.cpp, servoSimuSphere2DCamVelocity.cpp, servoSimuSphere2DCamVelocitySecondaryTask.cpp, servoSimuSquareLine2DCamVelocityDisplay.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, tutorial-ibvs-4pts-ogre.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-ibvs-4pts.cpp, tutorial-simu-pioneer-pan.cpp, and tutorial-simu-pioneer.cpp.

Definition at line 130 of file vpForwardProjection.cpp.

References vpForwardProjection::project(), and vpERROR_TRACE.

Referenced by vpPose::computeResidual(), vpProjectionDisplay::displayCamera(), vpDisplay::displayFrame(), vpPose::poseRansac(), vpPose::poseVirtualVS(), vpPose::poseVirtualVSrobust(), vpWireFrameSimulator::projectCameraTrajectory(), vpImageSimulator::setCameraPosition(), 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 88 of file vpTracker.h.

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