FeatureDepth

class FeatureDepth(self)

Bases: BasicFeature

Class that defines a 3D point visual feature \(s\) which is composed by one parameters that is \(log( \frac{Z}{Z^*})\) that defines the current depth relative to the desired depth. Here \(Z\) represents the current depth and \(Z^*\) the desired depth.

In this class \(x\) and \(y\) are the 2D coordinates in the camera frame and are given in meter. \(x\) , \(y\) and \(Z\) are needed during the computation of the interaction matrix \(L\) .

The visual features can be set easily thanks to the build() method.

As the visual feature \(s\) represents the current depth relative to the desired depth, the desired visual feature \(s^*\) is set to zero. Once the value of the visual feature is set, the interaction() method allows to compute the interaction matrix \(L\) associated to the visual feature, while the error() method computes the error vector \((s - s^*)\) between the current visual feature and the desired one which is here set to zero.

The code below shows how to create a eye-in hand visual servoing task using a 3D depth feature \(log( \frac{Z}{Z^*})\) that corresponds to the current depth relative to the desired depth. To control six degrees of freedom, at least five other features must be considered. First we create a current ( \(s\) ) 3D depth feature. Then we set the task to use the interaction matrix associated to the current feature \(L_s\) . And finally we compute the camera velocity \(v=-\lambda \; L_s^+ \; (s-s^*)\) . The current feature \(s\) is updated in the while() loop.

#include <visp3/visual_features/vpFeatureDepth.h>
#include <visp3/vs/vpServo.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpServo task; // Visual servoing task

  vpFeatureDepth s; //The current point feature.
  //Set the current parameters x, y, Z and the desired depth Zs
  double x;   // You have to compute the value of x.
  double y;   // You have to compute the value of y.
  double Z;   // You have to compute the value of Z.
  double Zs;  // You have to define the desired depth Zs.
  //Set the point feature thanks to the current parameters.
  s.buildFrom(x, y, Z, log(Z/Zs));

  // Set eye-in-hand control law.
  // The computed velocities will be expressed in the camera frame
  task.setServo(vpServo::EYEINHAND_CAMERA);
  // Interaction matrix is computed with the desired visual features sd
  task.setInteractionMatrixType(vpServo::CURRENT);

  // Add the 3D depth feature to the task
  task.addFeature(s); // s* is here considered as zero

  // Control loop
  for ( ; ; ) {
    // The new parameters x, y and Z must be computed here.

    // Update the current point visual feature
    s.buildFrom(x, y, Z, log(Z/Zs));

    // compute the control law
    vpColVector v = task.computeControlLaw(); // camera velocity
  }
  return 0;
}

If you want to build your own control law, this other example shows how to create a current ( \(s\) ) and desired ( \(s^*\) ) 2D point visual feature, compute the corresponding error vector \((s-s^*)\) and finally build the interaction matrix \(L_s\) .

#include <visp3/core/vpColVector.h>
#include <visp3/core/vpMatrix.h>
#include <visp3/visual_features/vpFeatureDepth.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpFeatureDepth s; //The current point feature.
  //Set the current parameters x, y, Z and the desired depth Zs
  double x;   // You have to compute the value of x.
  double y;   // You have to compute the value of y.
  double Z;   // You have to compute the value of Z.
  double Zs;  // You have to define the desired depth Zs.
  //Set the point feature thanks to the current parameters.
  s.buildFrom(x, y, Z, log(Z/Zs));

  // Compute the interaction matrix L_s for the current point feature
  vpMatrix L = s.interaction();

  // Compute the error vector (s-s*) for the point feature with s* considered as 0.
  vpColVector s_star(1); // The dimension is 1.
  s_star(1) = 0; // The value of s* is 0.
  s.error(s_star);
}

Default constructor that build a visual feature.

Methods

__init__

Default constructor that build a visual feature.

buildFrom

Build a 3D depth visual feature from the point coordinates \(x\) and \(y\) given in the camera frame, \(Z\) which describes the depth and \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

display

Overloaded function.

error

Overloaded function.

get_LogZoverZstar

Get the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

get_Z

Get the value of \(Z\) which represents the depth in the 3D camera frame.

get_x

Get the value of \(x\) which represents the x coordinate of the point in the camera frame.

get_y

Get the value of \(y\) which represents the y coordinate of the point in the camera frame.

init

Initialize the memory space requested for 3D depth visual feature.

interaction

Compute and return the interaction matrix \(L\) .

print

Print to stdout the values of the current visual feature \(s\) .

set_LogZoverZstar

Set the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

set_Z

Set the value of \(Z\) which represents the depth in the 3D camera frame.

set_x

Set the value of \(x\) which represents the x coordinate of the point in the camera frame.

set_xyZLogZoverZstar

Set the value of \(x\) , \(y\) , \(Z\) and \(log(\frac{Z}{Z^*})\) .

set_y

Set the value of \(y\) which represents the y coordinate of the point in the camera frame.

Inherited Methods

vpServo

BasicFeatureSelect

Indicates who should deallocate the feature.

deallocate

dimension_s

Return the dimension of the feature vector \(\bf s\) .

s

user

getDeallocate

nbParameters

BasicFeatureDeallocatorType

Indicates who should deallocate the feature.

selectAll

Select all the features.

setDeallocate

dim_s

get_s

Get the feature vector \(\bf s\) .

FEATURE_ALL

setFlags

Set feature flags to true to prevent warning when re-computing the interaction matrix without having updated the feature.

getDimension

Get the feature vector dimension.

Operators

__doc__

__init__

Default constructor that build a visual feature.

__module__

Attributes

FEATURE_ALL

__annotations__

deallocate

dim_s

nbParameters

s

user

vpServo

class BasicFeatureDeallocatorType(self, value: int)

Bases: pybind11_object

Indicates who should deallocate the feature.

Values:

  • user

  • vpServo

__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 BasicFeatureSelect(self, value: int)

Bases: pybind11_object

Indicates who should deallocate the feature.

Values:

  • user

  • vpServo

__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__(self)

Default constructor that build a visual feature.

buildFrom(self, x: float, y: float, Z: float, LogZoverZstar: float) visp._visp.visual_features.FeatureDepth

Build a 3D depth visual feature from the point coordinates \(x\) and \(y\) given in the camera frame, \(Z\) which describes the depth and \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

Parameters:
LogZoverZstar: float

The \(log(\frac{Z}{Z^*})\) parameter.

dimension_s(self) int

Return the dimension of the feature vector \(\bf s\) .

display(*args, **kwargs)

Overloaded function.

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

Not implemented.

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

Not implemented.

error(*args, **kwargs)

Overloaded function.

  1. error(self: visp._visp.visual_features.FeatureDepth, s_star: visp._visp.visual_features.BasicFeature, select: int = FEATURE_ALL) -> visp._visp.core.ColVector

Compute the error \((s-s^*)\) between the current and the desired visual features from a subset of the possible features.

Since this visual feature \(s\) represent the current depth relative to the desired depth, the desired visual feature \(s^*\) should be zero. Thus, the error is here equal to the current visual feature \(s\) .

The code below shows how to use this method:

// Creation of the current feature s
vpFeatureDepth s;

// Creation of the desired feature s^*. By default this feature is
// initialized to zero
vpFeatureDepth s_star;
s_star.setLogZoverZstar(0)

// Compute the interaction matrix for the ThetaU_z feature
vpMatrix L_z = s.interaction();

// Compute the error vector (s-s*) for the ThetaU_z feature
s.error(s_star);
Parameters:
s_star

Desired visual visual feature that should be equal to zero.

select

unuseful in the case of vpFeatureDepth . Always set to FEATURE_ALL.

Returns:

The error \((s-s^*)\) between the current and the desired visual feature.

  1. error(self: visp._visp.visual_features.BasicFeature, s_star: visp._visp.visual_features.BasicFeature, select: int = FEATURE_ALL) -> visp._visp.core.ColVector

Compute the error between two visual features from a subset of the possible features.

getDeallocate(self) visp._visp.visual_features.BasicFeature.BasicFeatureDeallocatorType
getDimension(self, select: int = FEATURE_ALL) int

Get the feature vector dimension.

get_LogZoverZstar(self) float

Get the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

Returns:

The value of \(log(\frac{Z}{Z^*})\) .

get_Z(self) float

Get the value of \(Z\) which represents the depth in the 3D camera frame.

Returns:

The value of \(Z\) .

get_s(self, select: int = FEATURE_ALL) visp._visp.core.ColVector

Get the feature vector \(\bf s\) .

get_x(self) float

Get the value of \(x\) which represents the x coordinate of the point in the camera frame.

Returns:

The value of \(x\) .

get_y(self) float

Get the value of \(y\) which represents the y coordinate of the point in the camera frame.

Returns:

The value of \(y\) .

init(self) None

Initialize the memory space requested for 3D depth visual feature.

interaction(self, select: int = FEATURE_ALL) visp._visp.core.Matrix

Compute and return the interaction matrix \(L\) . The computation is made thanks to the values of the point coordinates \(x\) and \(y\) and the depth \(Z\) .

\[L = \left[\begin{array}{cccccc} 0 & 0 & -1/Z & -y & x & 0 \end{array}\right]\]

The code below shows how to compute the interaction matrix associated to the visual feature \(s = log(\frac{Z}{Z^*})\) .

// Creation of the current feature s
vpFeatureDepth s;
s.buildFrom(0, 0, 5, log(5/1)); // The current depth is 5 meters and the desired is 1 meter.

vpMatrix L_x = s.interaction();
Parameters:
select: int = FEATURE_ALL

unuseful in the case of vpFeatureDepth . Always set to FEATURE_ALL.

Returns:

The interaction matrix computed from the point feature.

print(self, select: int = FEATURE_ALL) None

Print to stdout the values of the current visual feature \(s\) .

vpFeatureDepth s; // Current visual feature s

// Creation of the current feature s
s.buildFrom(0, 0, 5, log(5/1));

s.print(); // print all the 2 components of the feature
Parameters:
select: int = FEATURE_ALL

unuseful in the case of vpFeatureDepth . Always set to FEATURE_ALL.

static selectAll() int

Select all the features.

setDeallocate(self, d: visp._visp.visual_features.BasicFeature.BasicFeatureDeallocatorType) None
setFlags(self) None

Set feature flags to true to prevent warning when re-computing the interaction matrix without having updated the feature.

set_LogZoverZstar(self, LogZoverZstar: float) None

Set the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.

Parameters:
LogZoverZstar: float

math:log(frac{Z}{Z^*}) value to set.

set_Z(self, Z: float) None

Set the value of \(Z\) which represents the depth in the 3D camera frame.

set_x(self, x: float) None

Set the value of \(x\) which represents the x coordinate of the point in the camera frame.

set_xyZLogZoverZstar(self, x: float, y: float, Z: float, logZZs: float) None

Set the value of \(x\) , \(y\) , \(Z\) and \(log(\frac{Z}{Z^*})\) . \(x\) and \(y\) represent the coordinates of the point in the camera frame. \(Z\) is the 3D coordinate representing the depth. \(log(\frac{Z}{Z^*})\) represents the logarithm of the current depth relative to the desired depth.

set_y(self, y: float) None

Set the value of \(y\) which represents the y coordinate of the point in the camera frame.