MbtPolygon¶
- class MbtPolygon(*args, **kwargs)¶
Bases:
Polygon3D
Implementation of a polygon of the model used by the model-based tracker.
Overloaded function.
__init__(self: visp._visp.mbt.MbtPolygon) -> None
Basic constructor.
__init__(self: visp._visp.mbt.MbtPolygon, mbtp: visp._visp.mbt.MbtPolygon) -> None
Methods
Overloaded function.
Get the index of the face.
Get the name of the face.
Overloaded function.
Set the index of the face.
Set if the polygon is oriented or not.
Set the flag to consider if the level of detail (LOD) is used or not.
Set the threshold for the minimum line length to be considered as visible in the LOD (level of detail) case.
Set the minimum polygon area to be considered as visible in the LOD (level of detail) case.
Set the name of the face.
Inherited Methods
Return the number of corners at the previous computation.
Specify which clipping to use.
Get the near distance for clipping.
LEFT_CLIPPING
Static method to compute the clipped points from a set of initial points.
polyClipped
Static method to check whether the region defined by the vector of image point is contained entirely in the image.
- return:
A tuple containing:
DOWN_CLIPPING
distFarClip
Project the 3D corner points into the image thanks to the pose of the camera.
Get the 3D clipped points.
Return the number of corners.
NEAR_CLIPPING
nbCornersInsidePrev
ALL_CLIPPING
distNearClip
RIGHT_CLIPPING
UP_CLIPPING
Get the far distance for clipping.
Get a reference to a corner.
nbpt
Add a corner point to the list of polygon's corners.
Overloaded function.
Get the clipping used.
Static method to check the number of points of a region defined by the vector of image point that are inside the image.
Set the far distance for clipping.
Compute the region of interest in the image according to the used clipping.
Set the number of points which are the corners of the polygon.
Overloaded function.
Get the 3D clipped points and their clipping information.
Values:
FOV_CLIPPING
Set the near distance for clipping.
clippingFlag
FAR_CLIPPING
NO_CLIPPING
Operators
__doc__
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
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.mbt.MbtPolygon) -> None
Basic constructor.
__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).
- getFarClippingDistance(self) float ¶
Get the far distance for clipping.
- Returns:
Far clipping value.
- 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
- 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
- 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.
- 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.
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.
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.
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.
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.
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.
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.
- isVisible(*args, **kwargs)¶
Overloaded function.
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.
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
- 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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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()
- 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()
- 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()