MbTracker

class MbTracker

Bases: pybind11_object

Main methods for a model-based tracker.

This class provides the main methods for a model based tracker. This pure virtual class must be used in inheritance for a tracker that compute the interaction matrix and the residu vector using a defined information (edge, points of interest, patch, …)

This class intends to define a common basis for object tracking. This is realised by implementing the main functions:

  • init() : Initialisation of the tracker (it includes re-initialisation). This method is called at the end of the initClick() method.

  • initFaceFromCorners() : Initialisation of the lines that has to be tracked.

  • track() : Tracking on the current image

  • testTracking() : Test the tracking. This method throws exception if the tracking failed.

  • display() : Display the model and eventually other information.

Methods

__init__

computeCurrentProjectionError

Compute projection error given an input image and camera pose, parameters.

getAngleAppear

Return the angle used to test polygons appearance.

getAngleDisappear

Return the angle used to test polygons disappearance.

getCameraParameters

Get the camera parameters.

getClipping

Get the clipping used and defined in vpPolygon3D::vpMbtPolygonClippingType.

getCovarianceMatrix

Get the covariance matrix.

getEstimatedDoF

Get a 1x6 vpColVector representing the estimated degrees of freedom.

getFaces

Return a reference to the faces structure.

getFarClippingDistance

Get the far distance for clipping.

getInitialMu

Get the initial value of mu used in the Levenberg Marquardt optimization loop.

getLambda

Get the value of the gain used to compute the control law.

getMaxIter

Get the maximum number of iterations of the virtual visual servoing stage.

getNbPolygon

Get the number of polygons (faces) representing the object to track.

getNearClippingDistance

Get the near distance for clipping.

getOptimizationMethod

Get the optimization method used during the tracking.

getPolygonFaces

Get the list of polygons faces (a vpPolygon representing the projection of the face in the image and a list of face corners in 3D), with the possibility to order by distance to the camera or to use the visibility check to consider if the polygon face must be retrieved or not.

getPose

Overloaded function.

getProjectionError

Get the error angle between the gradient direction of the model features projected at the resulting pose and their normal.

getStopCriteriaEpsilon

initClick

Overloaded function.

initFromPoints

Overloaded function.

initFromPose

Overloaded function.

loadConfigFile

Load a config file to parameterise the behavior of the tracker.

loadModel

Load a 3D model from the file in parameter.

savePose

Save the pose in the given filename

setAngleAppear

Set the angle used to test polygons appearance.

setAngleDisappear

Set the angle used to test polygons disappearance.

setCameraParameters

Set the camera parameters.

setClipping

Specify which clipping to use.

setCovarianceComputation

Set if the covariance matrix has to be computed.

setDisplayFeatures

Enable to display the features.

setEstimatedDoF

Set a 6-dim column vector representing the degrees of freedom in the object frame that are estimated by the tracker.

setFarClippingDistance

Set the far distance for clipping.

setInitialMu

Set the initial value of mu for the Levenberg Marquardt optimization loop.

setLambda

Set the value of the gain used to compute the control law.

setLod

Set the flag to consider if the level of detail (LOD) is used.

setMask

setMaxIter

Set the maximum iteration of the virtual visual servoing stage.

setMinLineLengthThresh

Set the threshold for the minimum line length to be considered as visible in the LOD case.

setMinPolygonAreaThresh

Set the minimum polygon area to be considered as visible in the LOD case.

setNearClippingDistance

Set the near distance for clipping.

setOgreShowConfigDialog

Enable/Disable the appearance of Ogre config dialog on startup.

setOgreVisibilityTest

Use Ogre3D for visibility tests

setOptimizationMethod

setPoseSavingFilename

Set the filename used to save the initial pose computed using the initClick() method.

setProjectionErrorComputation

Set if the projection error criteria has to be computed.

setProjectionErrorDisplay

Display or not gradient and model orientation when computing the projection error.

setProjectionErrorDisplayArrowLength

Arrow length used to display gradient and model orientation for projection error computation.

setProjectionErrorDisplayArrowThickness

Arrow thickness used to display gradient and model orientation for projection error computation.

setProjectionErrorKernelSize

Set kernel size used for projection error computation.

setProjectionErrorMovingEdge

Set Moving-Edges parameters for projection error computation.

setScanLineVisibilityTest

setStopCriteriaEpsilon

Set the minimal error (previous / current estimation) to determine if there is convergence or not.

Inherited Methods

Operators

__annotations__

__doc__

__init__

__module__

Attributes

GAUSS_NEWTON_OPT

LEVENBERG_MARQUARDT_OPT

__annotations__

class MbtOptimizationMethod(self, value: int)

Bases: pybind11_object

Values:

  • GAUSS_NEWTON_OPT

  • LEVENBERG_MARQUARDT_OPT

__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)
computeCurrentProjectionError(self, I: visp._visp.core.ImageGray, _cMo: visp._visp.core.HomogeneousMatrix, _cam: visp._visp.core.CameraParameters) float

Compute projection error given an input image and camera pose, parameters. This projection error uses locations sampled exactly where the model is projected using the camera pose and intrinsic parameters. You may want to use

Note

See setProjectionErrorComputation

Note

See getProjectionError

to get a projection error computed at the ME locations after a call to track() . It works similarly to vpMbTracker::getProjectionError function:Get the error angle between the gradient direction of the model features projected at the resulting pose and their normal. The error is expressed in degree between 0 and 90.

Parameters:
I: visp._visp.core.ImageGray

Input grayscale image.

_cMo: visp._visp.core.HomogeneousMatrix

Camera pose.

_cam: visp._visp.core.CameraParameters

Camera parameters.

getAngleAppear(self) float

Return the angle used to test polygons appearance.

getAngleDisappear(self) float

Return the angle used to test polygons disappearance.

getCameraParameters(self, cam: visp._visp.core.CameraParameters) None

Get the camera parameters.

Parameters:
cam: visp._visp.core.CameraParameters

copy of the camera parameters used by the tracker.

getClipping(self) int

Get the clipping used and defined in vpPolygon3D::vpMbtPolygonClippingType.

Returns:

Clipping flags.

getCovarianceMatrix(self) visp._visp.core.Matrix

Get the covariance matrix. This matrix is only computed if setCovarianceComputation() is turned on.

Note

See setCovarianceComputation()

getEstimatedDoF(self) visp._visp.core.ColVector

Get a 1x6 vpColVector representing the estimated degrees of freedom. vpColVector [0] = 1 if translation on X is estimated, 0 otherwise; vpColVector [1] = 1 if translation on Y is estimated, 0 otherwise; vpColVector [2] = 1 if translation on Z is estimated, 0 otherwise; vpColVector [3] = 1 if rotation on X is estimated, 0 otherwise; vpColVector [4] = 1 if rotation on Y is estimated, 0 otherwise; vpColVector [5] = 1 if rotation on Z is estimated, 0 otherwise;

Returns:

1x6 vpColVector representing the estimated degrees of freedom.

getFaces(self) vpMbHiddenFaces<vpMbtPolygon>

Return a reference to the faces structure.

getFarClippingDistance(self) float

Get the far distance for clipping.

Returns:

Far clipping value.

getInitialMu(self) float

Get the initial value of mu used in the Levenberg Marquardt optimization loop.

Returns:

the initial mu value.

getLambda(self) float

Get the value of the gain used to compute the control law.

Returns:

the value for the gain.

getMaxIter(self) int

Get the maximum number of iterations of the virtual visual servoing stage.

Returns:

the number of iteration

getNbPolygon(self) int

Get the number of polygons (faces) representing the object to track.

Returns:

Number of polygons.

getNearClippingDistance(self) float

Get the near distance for clipping.

Returns:

Near clipping value.

getOptimizationMethod(self) visp._visp.mbt.MbTracker.MbtOptimizationMethod

Get the optimization method used during the tracking. 0 = Gauss-Newton approach. 1 = Levenberg-Marquardt approach.

Returns:

Optimization method.

getPolygonFaces(self, orderPolygons: bool = true, useVisibility: bool = true, clipPolygon: bool = false) tuple[list[visp._visp.core.Polygon], list[list[visp._visp.core.Point]]]

Get the list of polygons faces (a vpPolygon representing the projection of the face in the image and a list of face corners in 3D), with the possibility to order by distance to the camera or to use the visibility check to consider if the polygon face must be retrieved or not.

Parameters:
orderPolygons: bool = true

If true, the resulting list is ordered from the nearest polygon faces to the farther.

useVisibility: bool = true

If true, only visible faces will be retrieved.

clipPolygon: bool = false

If true, the polygons will be clipped according to the clipping flags set in vpMbTracker .

Returns:

A pair object containing the list of vpPolygon and the list of face corners.

getPose(*args, **kwargs)

Overloaded function.

  1. getPose(self: visp._visp.mbt.MbTracker, cMo: visp._visp.core.HomogeneousMatrix) -> None

Get the current pose between the object and the camera. cMo is the matrix which can be used to express coordinates from the object frame to camera frame.

Parameters:
cMo

the pose

  1. getPose(self: visp._visp.mbt.MbTracker) -> visp._visp.core.HomogeneousMatrix

Get the current pose between the object and the camera. cMo is the matrix which can be used to express coordinates from the object frame to camera frame.

Returns:

the current pose

getProjectionError(self) float

Get the error angle between the gradient direction of the model features projected at the resulting pose and their normal. The error is expressed in degree between 0 and 90. This value is computed if setProjectionErrorComputation() is turned on.

Note

See setProjectionErrorComputation()

Returns:

the value for the error.

getStopCriteriaEpsilon(self) float
initClick(*args, **kwargs)

Overloaded function.

  1. initClick(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, initFile: str, displayHelp: bool = false, T: visp._visp.core.HomogeneousMatrix = vpHomogeneousMatrix()) -> None

  2. initClick(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, initFile: str, displayHelp: bool = false, T: visp._visp.core.HomogeneousMatrix = vpHomogeneousMatrix()) -> None

  3. initClick(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, points3D_list: list[visp._visp.core.Point], displayFile: str = ) -> None

  4. initClick(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, points3D_list: list[visp._visp.core.Point], displayFile: str = ) -> None

initFromPoints(*args, **kwargs)

Overloaded function.

  1. initFromPoints(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, initFile: str) -> None

Initialise the tracker by reading 3D point coordinates and the corresponding 2D image point coordinates from a file. Comments starting with # character are allowed. 3D point coordinates are expressed in meter in the object frame with X, Y and Z values. 2D point coordinates are expressied in pixel coordinates, with first the line and then the column of the pixel in the image. The structure of this file is the following.

# 3D point coordinates
4                 # Number of 3D points in the file (minimum is four)
0.01 0.01 0.01    #  \
...               #  | 3D coordinates in meters in the object frame
0.01 -0.01 -0.01  # /
# corresponding 2D point coordinates
4                 # Number of image points in the file (has to be the same
as the number of 3D points)
100 200           #  \
...               #  | 2D coordinates in pixel in the image
50 10             #  /
Parameters:
I

Input grayscale image

initFile

Path to the file containing all the points.

  1. initFromPoints(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, initFile: str) -> None

Initialise the tracker by reading 3D point coordinates and the corresponding 2D image point coordinates from a file. Comments starting with # character are allowed. 3D point coordinates are expressed in meter in the object frame with X, Y and Z values. 2D point coordinates are expressied in pixel coordinates, with first the line and then the column of the pixel in the image. The structure of this file is the following.

# 3D point coordinates
4                 # Number of 3D points in the file (minimum is four)
0.01 0.01 0.01    #  \
...               #  | 3D coordinates in meters in the object frame
0.01 -0.01 -0.01  # /
# corresponding 2D point coordinates
4                 # Number of image points in the file (has to be the same
as the number of 3D points)
100 200           #  \
...               #  | 2D coordinates in pixel in the image
50 10             #  /
Parameters:
I_color

Input color image

initFile

Path to the file containing all the points.

  1. initFromPoints(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, points2D_list: list[visp._visp.core.ImagePoint], points3D_list: list[visp._visp.core.Point]) -> None

Initialise the tracking with the list of image points (points2D_list) and the list of corresponding 3D points (object frame) (points3D_list).

Parameters:
I

Input grayscale image

points2D_list

List of image points.

points3D_list

List of 3D points (object frame).

  1. initFromPoints(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, points2D_list: list[visp._visp.core.ImagePoint], points3D_list: list[visp._visp.core.Point]) -> None

Initialise the tracking with the list of image points (points2D_list) and the list of corresponding 3D points (object frame) (points3D_list).

Parameters:
I_color

Input color grayscale image

points2D_list

List of image points.

points3D_list

List of 3D points (object frame).

initFromPose(*args, **kwargs)

Overloaded function.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, initFile: str) -> None

Initialise the tracking thanks to the pose in vpPoseVector format, and read in the file initFile. The structure of this file is (without the comments):

// The six value of the pose vector
0.0000    //  \
0.0000    //  |
1.0000    //  | Example of value for the pose vector where Z = 1 meter
0.0000    //  |
0.0000    //  |
0.0000    //  /

Where the three firsts lines refer to the translation and the three last to the rotation in thetaU parametrisation (see vpThetaUVector ).

Parameters:
I

Input grayscale image

initFile

Path to the file containing the pose.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, initFile: str) -> None

Initialise the tracking thanks to the pose in vpPoseVector format, and read in the file initFile. The structure of this file is (without the comments):

// The six value of the pose vector
0.0000    //  \
0.0000    //  |
1.0000    //  | Example of value for the pose vector where Z = 1 meter
0.0000    //  |
0.0000    //  |
0.0000    //  /

Where the three firsts lines refer to the translation and the three last to the rotation in thetaU parametrisation (see vpThetaUVector ).

Parameters:
I_color

Input color image

initFile

Path to the file containing the pose.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, cMo: visp._visp.core.HomogeneousMatrix) -> None

Initialise the tracking thanks to the pose.

Parameters:
I

Input grayscale image

cMo

Pose matrix.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, cMo: visp._visp.core.HomogeneousMatrix) -> None

Initialise the tracking thanks to the pose.

Parameters:
I_color

Input color image

cMo

Pose matrix.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I: visp._visp.core.ImageGray, cPo: visp._visp.core.PoseVector) -> None

Initialise the tracking thanks to the pose vector.

Parameters:
I

Input grayscale image

cPo

Pose vector.

  1. initFromPose(self: visp._visp.mbt.MbTracker, I_color: visp._visp.core.ImageRGBa, cPo: visp._visp.core.PoseVector) -> None

Initialise the tracking thanks to the pose vector.

Parameters:
I_color

Input color image

cPo

Pose vector.

loadConfigFile(self, configFile: str, verbose: bool = true) None

Load a config file to parameterise the behavior of the tracker.

Virtual method to adapt to each tracker.

Parameters:
configFile: str

An xml config file to parse.

verbose: bool = true

verbose flag.

loadModel(self, modelFile: str, verbose: bool = false, T: visp._visp.core.HomogeneousMatrix = vpHomogeneousMatrix()) None

Load a 3D model from the file in parameter. This file must either be a vrml file (.wrl) or a CAO file (.cao). CAO format is described in the loadCAOModel() method.

Parameters:
modelFile: str

the file containing the the 3D model description. The extension of this file is either .wrl or .cao.

verbose: bool = false

verbose option to print additional information when loading CAO model files which include other CAO model files.

savePose(self, filename: str) None

Save the pose in the given filename

Parameters:
filename: str

Path to the file used to save the pose.

setAngleAppear(self, a: float) None

Set the angle used to test polygons appearance. If the angle between the normal of the polygon and the line going from the camera to the polygon center has a value lower than this parameter, the polygon is considered as appearing. The polygon will then be tracked.

Parameters:
a: float

new angle in radian.

setAngleDisappear(self, a: float) None

Set the angle used to test polygons disappearance. If the angle between the normal of the polygon and the line going from the camera to the polygon center has a value greater than this parameter, the polygon is considered as disappearing. The tracking of the polygon will then be stopped.

Parameters:
a: float

new angle in radian.

setCameraParameters(self, cam: visp._visp.core.CameraParameters) None

Set the camera parameters.

Parameters:
cam: visp._visp.core.CameraParameters

The new camera parameters.

setClipping(self, flags: int) None

Specify which clipping to use.

Note

See vpMbtPolygonClipping

Parameters:
flags: int

New clipping flags.

setCovarianceComputation(self, flag: bool) None

Set if the covariance matrix has to be computed.

Note

See getCovarianceMatrix()

Parameters:
flag: bool

True if the covariance has to be computed, false otherwise. If computed its value is available with getCovarianceMatrix()

setDisplayFeatures(self, displayF: bool) None

Enable to display the features. By features, we meant the moving edges (ME) and the klt points if used.

Note that if present, the moving edges can be displayed with different colors:

  • If green : The ME is a good point.

  • If blue : The ME is removed because of a contrast problem during the tracking phase.

  • If purple : The ME is removed because of a threshold problem during the tracking phase.

  • If red : The ME is removed because it is rejected by the robust approach in the virtual visual servoing scheme.

Parameters:
displayF: bool

set it to true to display the features.

setEstimatedDoF(self, v: visp._visp.core.ColVector) None

Set a 6-dim column vector representing the degrees of freedom in the object frame that are estimated by the tracker. When set to 1, all the 6 dof are estimated.

Below we give the correspondence between the index of the vector and the considered dof:

  • v[0] = 1 if translation along X is estimated, 0 otherwise;

  • v[1] = 1 if translation along Y is estimated, 0 otherwise;

  • v[2] = 1 if translation along Z is estimated, 0 otherwise;

  • v[3] = 1 if rotation along X is estimated, 0 otherwise;

  • v[4] = 1 if rotation along Y is estimated, 0 otherwise;

  • v[5] = 1 if rotation along Z is estimated, 0 otherwise;

setFarClippingDistance(self, dist: float) None

Set the far distance for clipping.

Parameters:
dist: float

Far clipping value.

setInitialMu(self, mu: float) None

Set the initial value of mu for the Levenberg Marquardt optimization loop.

Parameters:
mu: float

initial mu.

setLambda(self, gain: float) None

Set the value of the gain used to compute the control law.

Parameters:
gain: float

the desired value for the gain.

setLod(self: visp._visp.mbt.MbTracker, useLod: bool, name: str =) None

Set the flag to consider if the level of detail (LOD) is used.

Note

See setMinLineLengthThresh() , setMinPolygonAreaThresh()

Parameters:
useLod

true if the level of detail must be used, false otherwise. When true, two parameters can be set, see setMinLineLengthThresh() and setMinPolygonAreaThresh() .

name

name of the face we want to modify the LOD parameter.

setMask(self: visp._visp.mbt.MbTracker, mask: vpImage<bool>) None
setMaxIter(self, max: int) None

Set the maximum iteration of the virtual visual servoing stage.

Parameters:
max: int

the desired number of iteration

setMinLineLengthThresh(self: visp._visp.mbt.MbTracker, minLineLengthThresh: float, name: str =) None

Set the threshold for the minimum line length to be considered as visible in the LOD case.

Note

See setLod() , setMinPolygonAreaThresh()

Parameters:
minLineLengthThresh

threshold for the minimum line length in pixel.

name

name of the face we want to modify the LOD threshold.

setMinPolygonAreaThresh(self: visp._visp.mbt.MbTracker, minPolygonAreaThresh: float, name: str =) None

Set the minimum polygon area to be considered as visible in the LOD case.

Note

See setLod() , setMinLineLengthThresh()

Parameters:
minPolygonAreaThresh

threshold for the minimum polygon area in pixel.

name

name of the face we want to modify the LOD threshold.

setNearClippingDistance(self, dist: float) None

Set the near distance for clipping.

Parameters:
dist: float

Near clipping value.

setOgreShowConfigDialog(self, showConfigDialog: bool) None

Enable/Disable the appearance of Ogre config dialog on startup.

Warning

This method has only effect when Ogre is used and Ogre visibility test is enabled using setOgreVisibilityTest() with true parameter.

Parameters:
showConfigDialog: bool

if true, shows Ogre dialog window (used to set Ogre rendering options) when Ogre visibility is enabled. By default, this functionality is turned off.

setOgreVisibilityTest(self, v: bool) None

Use Ogre3D for visibility tests

Warning

This function has to be called before the initialization of the tracker.

Parameters:
v: bool

True to use it, False otherwise

setOptimizationMethod(self, opt: visp._visp.mbt.MbTracker.MbtOptimizationMethod) None
setPoseSavingFilename(self, filename: str) None

Set the filename used to save the initial pose computed using the initClick() method. It is also used to read a previous pose in the same method. If the file is not set then, the initClick() method will create a .0.pos file in the root directory. This directory is the path to the file given to the method initClick() used to know the coordinates in the object frame.

Parameters:
filename: str

The new filename.

setProjectionErrorComputation(self, flag: bool) None

Set if the projection error criteria has to be computed. This criteria could be used to detect the quality of the tracking. It computes an angle between 0 and 90 degrees that is available with getProjectionError() . Closer to 0 is the value, better is the tracking.

Note

See getProjectionError()

Parameters:
flag: bool

True if the projection error criteria has to be computed, false otherwise.

setProjectionErrorDisplay(self, display: bool) None

Display or not gradient and model orientation when computing the projection error.

setProjectionErrorDisplayArrowLength(self, length: int) None

Arrow length used to display gradient and model orientation for projection error computation.

setProjectionErrorDisplayArrowThickness(self, thickness: int) None

Arrow thickness used to display gradient and model orientation for projection error computation.

setProjectionErrorKernelSize(self, size: int) None

Set kernel size used for projection error computation.

Parameters:
size: int

Kernel size computed as kernel_size = size*2 + 1.

setProjectionErrorMovingEdge(self, me: visp._visp.me.Me) None

Set Moving-Edges parameters for projection error computation.

Parameters:
me: visp._visp.me.Me

Moving-Edges parameters.

setScanLineVisibilityTest(self, v: bool) None
setStopCriteriaEpsilon(self, eps: float) None

Set the minimal error (previous / current estimation) to determine if there is convergence or not.

Parameters:
eps: float

Epsilon threshold.