Cylinder

class Cylinder(*args, **kwargs)

Bases: ForwardProjection

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

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

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:

    \[\begin{split}\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. \end{split}\]

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

Overloaded function.

  1. __init__(self: visp._visp.core.Cylinder) -> None

Default constructor.

  1. __init__(self: visp._visp.core.Cylinder, oP: visp._visp.core.ColVector) -> None

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

vpCylinder cylinder;
double oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});
vpCylinder cylinder(oP);

Note

See setWorldCoordinates(const vpColVector&)

  1. __init__(self: visp._visp.core.Cylinder, oA: float, oB: float, oC: float, oX: float, oY: float, oZ: float, R: float) -> None

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

Note

See setWorldCoordinates (const double,const double,const double,const double,const double,const double,const double)

Parameters:
oA

Cylinder parameters expressed in the object frame.

oB

Cylinder parameters expressed in the object frame.

oC

Cylinder parameters expressed in the object frame.

oX

Cylinder parameters expressed in the object frame.

oY

Cylinder parameters expressed in the object frame.

oZ

Cylinder parameters expressed in the object frame.

R

Cylinder parameters expressed in the object frame.

Methods

__init__

Overloaded function.

changeFrame

Overloaded function.

computeZ

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

display

Overloaded function.

getA

Return cylinder cA parameter expressed in the camera frame.

getB

Return cylinder cB parameter expressed in the camera frame.

getC

Return cylinder cC parameter expressed in the camera frame.

getR

Return cylinder R parameter corresponding to the cylinder radius.

getRho1

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

getRho2

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

getTheta1

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

getTheta2

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

getX

Return cylinder cX parameter expressed in the camera frame.

getY

Return cylinder cY parameter expressed in the camera frame.

getZ

Return cylinder cZ parameter expressed in the camera frame.

init

Default initialisation of the feature parameters:

projection

Overloaded function.

setWorldCoordinates

Overloaded function.

Inherited Methods

get_p

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

user

vpDisplayForwardProjection

get_cP

Return object parameters expressed in the 3D camera frame.

getDeallocate

cP

track

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

get_oP

Return object parameters expressed in the 3D object frame.

setDeallocate

p

project

Overloaded function.

cPAvailable

ForwardProjectionDeallocatorType

Used for memory issue especially in the vpServo class.

print

Print to stdout the feature parameters in:

oP

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

cP

cPAvailable

line1

line2

oP

p

user

vpDisplayForwardProjection

class ForwardProjectionDeallocatorType(self, value: int)

Bases: pybind11_object

Used for memory issue especially in the vpServo class.

Values:

  • user

  • vpDisplayForwardProjection

__and__(self, other: object) object
__eq__(self, other: object) bool
__ge__(self, other: object) bool
__getstate__(self) int
__gt__(self, other: object) bool
__hash__(self) int
__index__(self) int
__init__(self, value: int)
__int__(self) int
__invert__(self) object
__le__(self, other: object) bool
__lt__(self, other: object) bool
__ne__(self, other: object) bool
__or__(self, other: object) object
__rand__(self, other: object) object
__ror__(self, other: object) object
__rxor__(self, other: object) object
__setstate__(self, state: int) None
__xor__(self, other: object) object
property name : str
class LineCylinderType(self, value: int)

Bases: pybind11_object

Values:

  • line1: First limb of the cylinder.

  • line2: Second limb of the cylinder.

__and__(self, other: object) object
__eq__(self, other: object) bool
__ge__(self, other: object) bool
__getstate__(self) int
__gt__(self, other: object) bool
__hash__(self) int
__index__(self) int
__init__(self, value: int)
__int__(self) int
__invert__(self) object
__le__(self, other: object) bool
__lt__(self, other: object) bool
__ne__(self, other: object) bool
__or__(self, other: object) object
__rand__(self, other: object) object
__ror__(self, other: object) object
__rxor__(self, other: object) object
__setstate__(self, state: int) None
__xor__(self, other: object) object
property name : str
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.core.Cylinder) -> None

Default constructor.

  1. __init__(self: visp._visp.core.Cylinder, oP: visp._visp.core.ColVector) -> None

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

vpCylinder cylinder;
double oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});
vpCylinder cylinder(oP);

Note

See setWorldCoordinates(const vpColVector&)

  1. __init__(self: visp._visp.core.Cylinder, oA: float, oB: float, oC: float, oX: float, oY: float, oZ: float, R: float) -> None

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

Note

See setWorldCoordinates (const double,const double,const double,const double,const double,const double,const double)

Parameters:
oA

Cylinder parameters expressed in the object frame.

oB

Cylinder parameters expressed in the object frame.

oC

Cylinder parameters expressed in the object frame.

oX

Cylinder parameters expressed in the object frame.

oY

Cylinder parameters expressed in the object frame.

oZ

Cylinder parameters expressed in the object frame.

R

Cylinder parameters expressed in the object frame.

changeFrame(*args, **kwargs)

Overloaded function.

  1. changeFrame(self: visp._visp.core.Cylinder, cMo: visp._visp.core.HomogeneousMatrix, cP: visp._visp.core.ColVector) -> None

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

Note

See changeFrame(const vpHomogeneousMatrix &)

Parameters:
cMo

Camera to object frame transformation.

  1. changeFrame(self: visp._visp.core.Cylinder, cMo: visp._visp.core.HomogeneousMatrix) -> None

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

Note

See changeFrame(const vpHomogeneousMatrix &, vpColVector &) const

Parameters:
cMo

Camera to object frame transformation.

computeZ(self, x: float, y: float) float

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

display(*args, **kwargs)

Overloaded function.

  1. display(self: visp._visp.core.Cylinder, I: visp._visp.core.ImageGray, cam: visp._visp.core.CameraParameters, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None

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.

  1. display(self: visp._visp.core.Cylinder, I: visp._visp.core.ImageRGBa, cam: visp._visp.core.CameraParameters, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None

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.

  1. display(self: visp._visp.core.Cylinder, I: visp._visp.core.ImageGray, cMo: visp._visp.core.HomogeneousMatrix, cam: visp._visp.core.CameraParameters, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None

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.

  1. display(self: visp._visp.core.Cylinder, I: visp._visp.core.ImageRGBa, cMo: visp._visp.core.HomogeneousMatrix, cam: visp._visp.core.CameraParameters, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None

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.

getA(self) float

Return cylinder cA parameter expressed in the camera frame.

getB(self) float

Return cylinder cB parameter expressed in the camera frame.

getC(self) float

Return cylinder cC parameter expressed in the camera frame.

getDeallocate(self) visp._visp.core.ForwardProjection.ForwardProjectionDeallocatorType
getR(self) float

Return cylinder R parameter corresponding to the cylinder radius.

getRho1(self) float

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

Note

See getTheta1()

getRho2(self) float

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

Note

See getTheta2()

getTheta1(self) float

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

Note

See getRho1()

getTheta2(self) float

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

Note

See getRho2()

getX(self) float

Return cylinder cX parameter expressed in the camera frame.

getY(self) float

Return cylinder cY parameter expressed in the camera frame.

getZ(self) float

Return cylinder cZ parameter expressed in the camera frame.

get_cP(self) visp._visp.core.ColVector

Return object parameters expressed in the 3D camera frame.

get_oP(self) visp._visp.core.ColVector

Return object parameters expressed in the 3D object frame.

get_p(self) visp._visp.core.ColVector

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

init(self) None

Default initialisation of the feature parameters:

  • in the object frame: oP

  • in the camera frame: cP

  • in the image plane: p .

print(self) None

Print to stdout the feature parameters in:

  • the object frame

  • the camera frame

  • the image plane.

project(*args, **kwargs)

Overloaded function.

  1. project(self: visp._visp.core.ForwardProjection) -> None

Compute the feature parameters in the image plane ( vpTracker::p ) from the parameters in the camera frame ( vpTracker::cP ).

Warning

Be careful to update vpTracker::p and vpTracker::cP public attributes before the call of this method.

  1. project(self: visp._visp.core.ForwardProjection, cMo: visp._visp.core.HomogeneousMatrix) -> None

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.

projection(*args, **kwargs)

Overloaded function.

  1. projection(self: visp._visp.core.Cylinder) -> None

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;
vpColVector oP(7);
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

Note

See projection(const vpColVector &, vpColVector &)

  1. projection(self: visp._visp.core.Cylinder, cP: visp._visp.core.ColVector, p: visp._visp.core.ColVector) -> None

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.

vpCylinder cylinder;
vpColVector oP(7);
// 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 

Note

See projection()

setDeallocate(self, d: visp._visp.core.ForwardProjection.ForwardProjectionDeallocatorType) None
setWorldCoordinates(*args, **kwargs)

Overloaded function.

  1. setWorldCoordinates(self: visp._visp.core.Cylinder, oP: visp._visp.core.ColVector) -> None

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.

vpCylinder cylinder;
double oA, oB, oC, oX, oY, oZ, R;
...
vpColVector oP({oA, oB, oC, oX, oY, oZ, R});
cylinder.setWorldCoordinates(oP);
  1. setWorldCoordinates(self: visp._visp.core.Cylinder, oA: float, oB: float, oC: float, oX: float, oY: float, oZ: float, R: float) -> None

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

Parameters:
oA

Cylinder parameters in the object frame.

oB

Cylinder parameters in the object frame.

oC

Cylinder parameters in the object frame.

oX

Cylinder parameters in the object frame.

oY

Cylinder parameters in the object frame.

oZ

Cylinder parameters in the object frame.

R

Cylinder parameters in the object frame.

track(self, cMo: visp._visp.core.HomogeneousMatrix) None

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: visp._visp.core.HomogeneousMatrix

The homogeneous matrix corresponding to the pose between the camera frame and the object frame.