Visual Servoing Platform  version 3.3.1 under development (2020-12-02)
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 oA, double oB, double oC, double oX, double oY, double oZ, double R)
 
virtual ~vpCylinder ()
 
void changeFrame (const vpHomogeneousMatrix &cMo, vpColVector &cP) const
 
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) const
 
void setWorldCoordinates (const vpColVector &oP)
 
void setWorldCoordinates (double oA, double oB, double oC, double oX, double oY, double oZ, double R)
 
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
 

Detailed Description

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

A 3D cylinder of radius R is defined by the set of circles of radius R whose center belongs to a straight line perpendicular to the plane of the circles.

A 3D cylinder has the followings parameters:

  • in the object frame: the cylinder is represented by the equation: $ (X - oX)^2 + (Y - oY)^2 + (Z - oZ)^2 - (oA \; X + oB \; Y + oC \; Z)^2 - R^2 = 0 $ with

    \[ \left\{ \begin{array}{l} oA^2 + oB^2 + oC^2 = 1 \\ oA \; oX + oB \; oY + oC \; oZ = 0 \end{array} \right. \]

    where R is the radius of the cylinder, oA, oB, oC are the coordinates of its direction vector and oX, oY, oZ are the coordinates of the nearest point belonging to the cylinder axis from the projection center. The corresponding parameters are located in vpForwardProjection::oP 7-dim internal vector. They correspond to oP = (oA, oB, oC, oX, oY, oZ, R). Setting the cylinder parameters is achieved through the constructors with parameters or setWorldCoordinates() methods. To get theses parameters use get_oP().
  • in the camera frame: parameters are saved in vpTracker::cP 7-dim internal vector with cP =(cA, cB, cC, cX, cY, cZ, R). Considering the set of parameters oP expressed in the object frame, cylinder coordinates expressed in the camera frame are obtained using changeFrame(). To get these parameters use get_cP().
  • in the 2D image plane: parameters are saved in vpTracker::p 4-dim vector. They correspond to p = ( $\rho_1$, $\theta_1$, $\rho_2$, $\theta_2$), noting that for non-degenerated cases, the perspective projection of a cylinder on the image plane is 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. \]

    Perspective projection is achieved using projection() methods. The methods get_p(), 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 102 of file vpCylinder.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.

◆ vpLineCylinderType

Enumerator
line1 

First limb of the cylinder.

line2 

Second limb of the cylinder.

Definition at line 105 of file vpCylinder.h.

Constructor & Destructor Documentation

◆ vpCylinder() [1/3]

vpCylinder::vpCylinder ( )

Default constructor.

Definition at line 88 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 oP = (oA, oB, oC, oX, oY, oZ, R) expressed in the object frame.

Parameters
o_P: 7-dim vector of parameters.
vpCylinder cylinder;
double oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});
vpCylinder cylinder(oP);
See also
setWorldCoordinates(const vpColVector&)

Definition at line 105 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

◆ vpCylinder() [3/3]

vpCylinder::vpCylinder ( double  oA,
double  oB,
double  oC,
double  oX,
double  oY,
double  oZ,
double  R 
)

Create and initialize a cylinder with parameters oP = (oA, oB, oC, oX, oY, oZ, R) expressed in the object frame.

Parameters
oA,oB,oC,oX,oY,oZ,R: Cylinder parameters expressed in the object frame.
See also
setWorldCoordinates(const double,const double,const double,const double,const double,const double,const double)

Definition at line 120 of file vpCylinder.cpp.

References init(), and setWorldCoordinates().

◆ ~vpCylinder()

vpCylinder::~vpCylinder ( )
virtual

Default constructor.

Definition at line 129 of file vpCylinder.cpp.

Member Function Documentation

◆ changeFrame() [1/2]

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

From the cylinder parameters oP expressed in the object frame, compute the cylinder parameters cP expressed in the camera frame.

Parameters
cMo: Camera to object frame transformation.
cP_[out] : Parameters cP expressed in the camera frame.
See also
changeFrame(const vpHomogeneousMatrix &)

Implements vpForwardProjection.

Definition at line 249 of file vpCylinder.cpp.

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

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 oP parameters expressed in the object frame, compute the cylinder internal parameters cP expressed in the camera frame.

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

Implements vpForwardProjection.

Definition at line 237 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 344 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 a 3D cylinder in image I as two lines corresponding to the limbs.

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

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp.

Definition at line 390 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 a 3D cylinder in image I as two lines corresponding to the limbs. This method is non destructive wrt. cP and p internal 3D point parameters.

Parameters
I: Image used as background.
cMo: Homogeneous transformation from camera frame to object frame. The point 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 372 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 354 of file vpCylinder.cpp.

References vpCylinder().

◆ 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_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.

◆ getA()

double vpCylinder::getA ( ) const
inline

Return cylinder cA parameter expressed in the camera frame.

Definition at line 156 of file vpCylinder.h.

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

◆ getB()

double vpCylinder::getB ( ) const
inline

Return cylinder cB parameter expressed in the camera frame.

Definition at line 160 of file vpCylinder.h.

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

◆ getC()

double vpCylinder::getC ( ) const
inline

Return cylinder cC parameter expressed in the camera frame.

Definition at line 164 of file vpCylinder.h.

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

◆ getDeallocate()

vpForwardProjectionDeallocatorType vpForwardProjection::getDeallocate ( )
inlineinherited

Definition at line 167 of file vpForwardProjection.h.

◆ getR()

double vpCylinder::getR ( ) const
inline

Return cylinder R parameter corresponding to the cylinder radius.

Definition at line 180 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 132 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 145 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 138 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 151 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 cX parameter expressed in the camera frame.

Definition at line 168 of file vpCylinder.h.

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

◆ getY()

double vpCylinder::getY ( ) const
inline

Return cylinder cY parameter expressed in the camera frame.

Definition at line 172 of file vpCylinder.h.

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

◆ getZ()

double vpCylinder::getZ ( ) const
inline

Return cylinder cZ parameter expressed in the camera frame.

Definition at line 176 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(), and vpForwardProjection::projection().

◆ 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;
double oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});
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 154 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_ 
) const
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 184 of file vpCylinder.cpp.

References vpException::fatalError, and vpColVector::resize().

◆ setDeallocate()

void vpForwardProjection::setDeallocate ( vpForwardProjectionDeallocatorType  d)
inlineinherited

Definition at line 196 of file vpForwardProjection.h.

References vpTracker::init().

◆ 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 oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});

Implements vpForwardProjection.

Examples:
manGeometricFeatures.cpp.

Definition at line 65 of file vpCylinder.cpp.

References vpForwardProjection::oP.

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

◆ setWorldCoordinates() [2/2]

void vpCylinder::setWorldCoordinates ( double  oA,
double  oB,
double  oC,
double  oX,
double  oY,
double  oZ,
double  R 
)

Set the cylinder parameters oP = (oA, oB, oC, oX, oY, oZ, R) expressed in the object frame.

Parameters
oA,oB,oC,oX,oY,oZ,R: Cylinder parameters in the object frame.

Definition at line 74 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, 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