MbtPolygon

class MbtPolygon(*args, **kwargs)

Bases: Polygon3D

Implementation of a polygon of the model used by the model-based tracker.

Overloaded function.

  1. __init__(self: visp._visp.mbt.MbtPolygon) -> None

Basic constructor.

  1. __init__(self: visp._visp.mbt.MbtPolygon, mbtp: visp._visp.mbt.MbtPolygon) -> None

Methods

__init__

Overloaded function.

getIndex

Get the index of the face.

getName

Get the name of the face.

isAppearing

isPolygonOriented

isVisible

Overloaded function.

setIndex

Set the index of the face.

setIsPolygonOriented

Set if the polygon is oriented or not.

setLod

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

setMinLineLengthThresh

Set the threshold for the minimum line length to be considered as visible in the LOD (level of detail) case.

setMinPolygonAreaThresh

Set the minimum polygon area to be considered as visible in the LOD (level of detail) case.

setName

Set the name of the face.

Inherited Methods

distNearClip

setClipping

Specify which clipping to use.

addPoint

Add a corner point to the list of polygon's corners.

getClipping

Get the clipping used.

NO_CLIPPING

getNearClippingDistance

Get the near distance for clipping.

distFarClip

getNbCornerInsideImage

Static method to check the number of points of a region defined by the vector of image point that are inside the image.

getClippedPolygon

Static method to compute the clipped points from a set of initial points.

nbCornersInsidePrev

polyClipped

RIGHT_CLIPPING

FAR_CLIPPING

getFarClippingDistance

Get the far distance for clipping.

setNearClippingDistance

Set the near distance for clipping.

getRoiClipped

Overloaded function.

computePolygonClipped

Compute the region of interest in the image according to the used clipping.

getNbPoint

Return the number of corners.

LEFT_CLIPPING

setFarClippingDistance

Set the far distance for clipping.

getNbCornerInsidePrevImage

Return the number of corners at the previous computation.

changeFrame

Project the 3D corner points into the image thanks to the pose of the camera.

getMinMaxRoi

return:

A tuple containing:

UP_CLIPPING

clippingFlag

getPolygonClippedWithInfo

Get the 3D clipped points and their clipping information.

getRoi

Overloaded function.

ALL_CLIPPING

roiInsideImage

Static method to check whether the region defined by the vector of image point is contained entirely in the image.

nbpt

DOWN_CLIPPING

FOV_CLIPPING

Polygon3DClippingType

Values:

getPolygonClipped

Get the 3D clipped points.

setNbPoint

Set the number of points which are the corners of the polygon.

getPoint

Get a reference to a corner.

NEAR_CLIPPING

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

ALL_CLIPPING

DOWN_CLIPPING

FAR_CLIPPING

FOV_CLIPPING

LEFT_CLIPPING

NEAR_CLIPPING

NO_CLIPPING

RIGHT_CLIPPING

UP_CLIPPING

__annotations__

clippingFlag

distFarClip

distNearClip

hasOrientation

inLineLengthThresh

inPolygonAreaThresh

index

isappearing

isvisible

name

nbCornersInsidePrev

nbpt

polyClipped

useLod

class Polygon3DClippingType(self, value: int)

Bases: pybind11_object

Values:

  • NO_CLIPPING

  • NEAR_CLIPPING

  • FAR_CLIPPING

  • LEFT_CLIPPING

  • RIGHT_CLIPPING

  • UP_CLIPPING

  • DOWN_CLIPPING

  • FOV_CLIPPING

  • ALL_CLIPPING

__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.mbt.MbtPolygon) -> None

Basic constructor.

  1. __init__(self: visp._visp.mbt.MbtPolygon, mbtp: visp._visp.mbt.MbtPolygon) -> None

addPoint(self, n: int, P: visp._visp.core.Point) None

Add a corner point to the list of polygon’s corners.

Parameters:
n: int

The index of the corner.

P: visp._visp.core.Point

The point to add.

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

Project the 3D corner points into the image thanks to the pose of the camera.

Parameters:
cMo: visp._visp.core.HomogeneousMatrix

The pose of the camera.

computePolygonClipped(self, cam: visp._visp.core.CameraParameters = vpCameraParameters()) None

Compute the region of interest in the image according to the used clipping.

Warning

If the FOV clipping is used, camera normals have to be precomputed.

Parameters:
cam: visp._visp.core.CameraParameters = vpCameraParameters()

camera parameters used to compute the field of view.

static getClippedPolygon(ptIn: list[visp._visp.core.Point], cMo: visp._visp.core.HomogeneousMatrix, clippingFlags: int, cam: visp._visp.core.CameraParameters = vpCameraParameters(), znear: float = 0.001, zfar: float = 100) list[visp._visp.core.Point]

Static method to compute the clipped points from a set of initial points.

Warning

When using FOV clipping and personnal camera parameters, camera normals have to be computed before (see vpCameraParameters::computeFov() )

Parameters:
ptIn: list[visp._visp.core.Point]

Input points

cMo: visp._visp.core.HomogeneousMatrix

Pose considered for the clipping.

clippingFlags: int

Clipping flag (see vpPolygon3D::vpPolygon3DClippingType ).

cam: visp._visp.core.CameraParameters = vpCameraParameters()

Camera parameters (Only used if clipping flags contain FOV clipping).

znear: float = 0.001

Near clipping distance value (Only used if clipping flags contain Near clipping).

zfar: float = 100

Far clipping distance value (Only used if clipping flags contain Far clipping).

Returns:

A tuple containing:

  • ptOut: Output points (result of the clipping).

getClipping(self) int

Get the clipping used.

Returns:

Clipping flags.

getFarClippingDistance(self) float

Get the far distance for clipping.

Returns:

Far clipping value.

getIndex(self) int

Get the index of the face.

Returns:

index : the index of the face.

static getMinMaxRoi(roi: list[visp._visp.core.ImagePoint]) tuple[int, int, int, int]
Returns:

A tuple containing:

  • i_min

  • i_max

  • j_min

  • j_max

getName(self) str

Get the name of the face.

Returns:

Name of the face.

getNbCornerInsideImage(self, I: visp._visp.core.ImageGray, cam: visp._visp.core.CameraParameters) int

Static method to check the number of points of a region defined by the vector of image point that are inside the image.

Parameters:
I: visp._visp.core.ImageGray

The image used for its size.

cam: visp._visp.core.CameraParameters

The camera parameters.

getNbCornerInsidePrevImage(self) int

Return the number of corners at the previous computation.

Returns:

number of corner of the face at the previous computation

getNbPoint(self) int

Return the number of corners.

Returns:

number of corner of the face

getNearClippingDistance(self) float

Get the near distance for clipping.

Returns:

Near clipping value.

getPoint(self, _index: int) visp._visp.core.Point

Get a reference to a corner.

Parameters:
_index: int

the index of the corner

getPolygonClipped(self) list[visp._visp.core.Point]

Get the 3D clipped points.

Warning

Suppose that changeFrame() and computePolygonClipped() have already been called.

Returns:

A tuple containing:

  • poly: resulting points.

getPolygonClippedWithInfo(self) list[tuple[visp._visp.core.Point, int]]

Get the 3D clipped points and their clipping information.

Warning

Suppose that changeFrame() and computePolygonClipped() have already been called.

Returns:

A tuple containing:

  • poly: resulting points plus clipping information.

getRoi(*args, **kwargs)

Overloaded function.

  1. getRoi(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters) -> list[visp._visp.core.ImagePoint]

Get the region of interest in the image.

Parameters:
cam

camera parameters.

Returns:

Image point corresponding to the region of interest.

  1. getRoi(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters, cMo: visp._visp.core.HomogeneousMatrix) -> list[visp._visp.core.ImagePoint]

Get the region of interest in the image.

Parameters:
cam

camera parameters.

cMo

pose.

Returns:

Image point corresponding to the region of interest.

getRoiClipped(*args, **kwargs)

Overloaded function.

  1. getRoiClipped(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters) -> list[visp._visp.core.ImagePoint]

Get the region of interest clipped in the image.

Warning

Suppose that changeFrame() and computePolygonClipped() have already been called.

Parameters:
cam

camera parameters.

Returns:

A tuple containing:

  • roi: image point corresponding to the region of interest.

  1. getRoiClipped(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters, cMo: visp._visp.core.HomogeneousMatrix) -> list[visp._visp.core.ImagePoint]

Get the region of interest clipped in the image.

Parameters:
cam

camera parameters.

cMo

pose.

Returns:

A tuple containing:

  • roi: image point corresponding to the region of interest.

  1. getRoiClipped(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters) -> list[tuple[visp._visp.core.ImagePoint, int]]

Get the region of interest clipped in the image and the information to know if it’s a clipped point.

Warning

Suppose that changeFrame() and computePolygonClipped() have already been called.

Parameters:
cam

camera parameters.

Returns:

A tuple containing:

  • roi: image point corresponding to the region of interest with clipping information.

  1. getRoiClipped(self: visp._visp.core.Polygon3D, cam: visp._visp.core.CameraParameters, cMo: visp._visp.core.HomogeneousMatrix) -> list[tuple[visp._visp.core.ImagePoint, int]]

Get the region of interest clipped in the image and the information to know if it’s a clipped point.

Parameters:
cam

camera parameters.

cMo

pose.

Returns:

A tuple containing:

  • roi: image point corresponding to the region of interest with clipping information.

isAppearing(self) bool
isPolygonOriented(self) bool
isVisible(*args, **kwargs)

Overloaded function.

  1. isVisible(self: visp._visp.mbt.MbtPolygon, cMo: visp._visp.core.HomogeneousMatrix, alpha: float, modulo: bool = false, cam: visp._visp.core.CameraParameters = vpCameraParameters(), width: int = 0, height: int = 0) -> bool

Check if the polygon is visible in the image and if the angle between the normal to the face and the line vector going from the optical center to the cog of the face is below the given threshold. To do that, the polygon is projected into the image thanks to the camera pose.

Parameters:
cMo

The pose of the camera.

alpha

Maximum angle to detect if the face is visible (in rad).

modulo

Indicates if the test should also consider faces that are not oriented counter clockwise. If true, the orientation of the face is without importance.

cam

Camera parameters (intrinsics parameters)

width

Image size used to consider level of detail.

height

Image size used to consider level of detail.

Returns:

Return true if the polygon is visible.

  1. isVisible(self: visp._visp.mbt.MbtPolygon) -> bool

static roiInsideImage(I: visp._visp.core.ImageGray, corners: list[visp._visp.core.ImagePoint]) bool

Static method to check whether the region defined by the vector of image point is contained entirely in the image.

Parameters:
I: visp._visp.core.ImageGray

The image used for its size.

corners: list[visp._visp.core.ImagePoint]

The vector of points defining a region

setClipping(self, flags: int) None

Specify which clipping to use.

Note

See vpPolygon3DClipping

Parameters:
flags: int

New clipping flags.

setFarClippingDistance(self, dist: float) None

Set the far distance for clipping.

Parameters:
dist: float

Far clipping value.

setIndex(self, i: int) None

Set the index of the face.

Parameters:
i: int

the new index of the face.

setIsPolygonOriented(self, oriented: bool) None

Set if the polygon is oriented or not.

Parameters:
oriented: bool

True if the polygon is oriented, false otherwise.

setLod(self, use_lod: bool) None

Set the flag to consider if the level of detail (LOD) is used or not. When activated, lines and faces of the 3D model are tracked if respectively their projected length and area in the image are significative enough. By significative, we mean:

  • if the length of the projected line in the image is greater that a threshold set by setMinLineLengthThresh()

  • if the area of the projected face in the image is greater that a threshold set by setMinPolygonAreaThresh() .

The sample code below shows how to introduce this feature:

#include <visp3/io/vpImageIo.h>
#include <visp3/mbt/vpMbEdgeTracker.h>

int main()
{
  vpImage<unsigned char> I;

  // Acquire an image
  vpImageIo::read(I, "my-image.pgm");

  std::string object = "my-object";
  vpMbEdgeTracker tracker;
  tracker.loadConfigFile( object+".xml" );
  tracker.loadModel( object+".cao" );

  tracker.setLod(true);
  tracker.setMinLineLengthThresh(20.);
  tracker.setMinPolygonAreaThresh(20.*20.);

  tracker.initClick(I, object+".init" );

  while (true) {
    // tracking loop
  }
}

Note

See setMinLineLengthThresh() , setMinPolygonAreaThresh()

Parameters:
use_lod: bool

true if level of detail must be used, false otherwise.

setMinLineLengthThresh(self, min_line_length: float) None

Set the threshold for the minimum line length to be considered as visible in the LOD (level of detail) case. This threshold is only used when setLoD() is turned on.

Note

See setLoD()

Parameters:
min_line_length: float

threshold for the minimum line length in pixel. When a single line that doesn’t belong to a face is considered by the tracker, this line is tracked only if its length in pixel is greater than min_line_length .

setMinPolygonAreaThresh(self, min_polygon_area: float) None

Set the minimum polygon area to be considered as visible in the LOD (level of detail) case. This threshold is only used when setLoD() is turned on.

Note

See setLoD()

Parameters:
min_polygon_area: float

threshold for the minimum polygon area in pixel. When a face is considered by the tracker, this face is tracked only if its area in pixel is greater than min_polygon_area .

setName(self, face_name: str) None

Set the name of the face.

Parameters:
face_name: str

name of the face.

setNbPoint(self, nb: int) None

Set the number of points which are the corners of the polygon.

Parameters:
nb: int

The number of corners.

setNearClippingDistance(self, dist: float) None

Set the near distance for clipping.

Parameters:
dist: float

Near clipping value.