TemplateTrackerZone

class TemplateTrackerZone(*args, **kwargs)

Bases: pybind11_object

A zone is defined by a set of triangles defined as vpTemplateTrackerTriangle .

A zone can be initialized either by user interaction using mouse click in a display device throw initClick() , or by a list of points throw initFromPoints() .

Overloaded function.

  1. __init__(self: visp._visp.tt.TemplateTrackerZone) -> None

Default constructor.

  1. __init__(self: visp._visp.tt.TemplateTrackerZone, z: visp._visp.tt.TemplateTrackerZone) -> None

Copy constructor.

Methods

__init__

Overloaded function.

add

Add a triangle to the zone and update the bounding box.

clear

Remove all the triangles that define the zone.

copy

Copy all the triangles that define zone Z in the current zone (*this) and update the zone bounding box.

display

Overloaded function.

fillTriangle

Modify all the pixels inside a triangle with a given gray level.

getArea

Return the area of the template zone.

getBoundingBox

Return a rectangle that defines the bounding box of the zone.

getCenter

Overloaded function.

getMaxx

Note

See getMinx() , getBoundingBox()

getMaxy

Note

See getMiny() , getBoundingBox()

getMinx

Note

See getMaxx() , getBoundingBox()

getMiny

Note

See getMaxy() , getBoundingBox()

getNbTriangle

Return the number of triangles that define the zone.

getPyramidDown

Return a zone with triangles that are down scaled by a factor 2.

getTriangle

Overloaded function.

inZone

Overloaded function.

initClick

Initialize a zone in image I using mouse click.

initFromPoints

Initialize the zone using a vector of image points.

Inherited Methods

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.tt.TemplateTrackerZone) -> None

Default constructor.

  1. __init__(self: visp._visp.tt.TemplateTrackerZone, z: visp._visp.tt.TemplateTrackerZone) -> None

Copy constructor.

add(self, t: visp._visp.tt.TemplateTrackerTriangle) None

Add a triangle to the zone and update the bounding box.

Parameters:
t: visp._visp.tt.TemplateTrackerTriangle

Triangle to introduce in the zone.

clear(self) None

Remove all the triangles that define the zone.

copy(self, z: visp._visp.tt.TemplateTrackerZone) None

Copy all the triangles that define zone Z in the current zone (*this) and update the zone bounding box.

Parameters:
z: visp._visp.tt.TemplateTrackerZone

Zone with a set of triangles provided as input.

display(*args, **kwargs)

Overloaded function.

  1. display(self: visp._visp.tt.TemplateTrackerZone, I: visp._visp.core.ImageGray, col: visp._visp.core.Color = vpColor::green, thickness: int = 3) -> None

If a display device is associated to image I , display in overlay the triangles that define the zone.

Parameters:
I

Image.

col

Color used to display the triangles.

thickness

Thickness of the triangle lines.

  1. display(self: visp._visp.tt.TemplateTrackerZone, I: visp._visp.core.ImageRGBa, col: visp._visp.core.Color = vpColor::green, thickness: int = 3) -> None

If a display device is associated to image I , display in overlay the triangles that define the zone.

Parameters:
I

Image.

col

Color used to display the triangles.

thickness

Thickness of the triangle lines.

fillTriangle(self, I: visp._visp.core.ImageGray, id: int, gray_level: int) None

Modify all the pixels inside a triangle with a given gray level.

Parameters:
I: visp._visp.core.ImageGray

Output image.

id: int

Triangle id. This value should be less than the number of triangles used to define the zone and available using getNbTriangle() .

gray_level: int

Color used to fill the triangle with.

getArea(self) float

Return the area of the template zone.

getBoundingBox(self) visp._visp.core.Rect

Return a rectangle that defines the bounding box of the zone.

Note

See getMinx() , getMiny() , getMaxx() , getMaxy()

getCenter(*args, **kwargs)

Overloaded function.

  1. getCenter(self: visp._visp.tt.TemplateTrackerZone) -> visp._visp.core.ImagePoint

Return the position of the center of gravity of the zone.

  1. getCenter(self: visp._visp.tt.TemplateTrackerZone, borne_x: int, borne_y: int) -> visp._visp.core.ImagePoint

Return the position of the center of gravity in a given area.

Parameters:
borne_x

Right coordinate of the area to consider.

borne_y

Bottom coordinate of the area to consider.

getMaxx(self) int

Note

See getMinx() , getBoundingBox()

Returns:

The maximal x coordinate (along the columns of the image) of the points that are in the zone.

getMaxy(self) int

Note

See getMiny() , getBoundingBox()

Returns:

The maximal y coordinate (along the rows of the image) of the points that are in the zone.

getMinx(self) int

Note

See getMaxx() , getBoundingBox()

Returns:

The minimal x coordinate (along the columns of the image) of the points that are in the zone.

getMiny(self) int

Note

See getMaxy() , getBoundingBox()

Returns:

The minimal y coordinate (along the rows of the image) of the points that are in the zone.

getNbTriangle(self) int

Return the number of triangles that define the zone.

Note

See getTriangle()

getPyramidDown(self) visp._visp.tt.TemplateTrackerZone

Return a zone with triangles that are down scaled by a factor 2.

getTriangle(*args, **kwargs)

Overloaded function.

  1. getTriangle(self: visp._visp.tt.TemplateTrackerZone, i: int, T: visp._visp.tt.TemplateTrackerTriangle) -> None

A zone is defined by a set of triangles. This function returns the ith triangle.The following sample code shows how to use this function:

vpTemplateTrackerZone zone;
...
for (unsigned int i=0; i < zone.getNbTriangle(); i++) {
  vpTemplateTrackerTriangle triangle;
  zone.getTriangle(i, triangle);
}
Parameters:
i

Index of the triangle to return.

T

The triangle corresponding to index i.

  1. getTriangle(self: visp._visp.tt.TemplateTrackerZone, i: int) -> visp._visp.tt.TemplateTrackerTriangle

The following sample code shows how to use this function:

vpTemplateTrackerZone zone;
...
for (unsigned int i=0; i < zone.getNbTriangle(); i++) {
  vpTemplateTrackerTriangle triangle = zone.getTriangle(i);
}
Parameters:
i

Index of the triangle to return.

Returns:

The triangle corresponding to index i.

inZone(*args, **kwargs)

Overloaded function.

  1. inZone(self: visp._visp.tt.TemplateTrackerZone, i: int, j: int) -> bool

Parameters:
i

Coordinates of the pixel to test.

j

Coordinates of the pixel to test.

Returns:

true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise.

  1. inZone(self: visp._visp.tt.TemplateTrackerZone, i: float, j: float) -> bool

Parameters:
i

Coordinates of the pixel to test.

j

Coordinates of the pixel to test.

Returns:

true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise.

  1. inZone(self: visp._visp.tt.TemplateTrackerZone, i: int, j: int, id_triangle: int) -> tuple[bool, int]

Parameters:
i

Coordinates of the pixel to test.

j

Coordinates of the pixel to test.

id_triangle

Index of the triangle that contains the pixel (i,j).

Returns:

A tuple containing:

  • true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise.

  • id_triangle: Index of the triangle that contains the pixel (i,j).

  1. inZone(self: visp._visp.tt.TemplateTrackerZone, i: float, j: float, id_triangle: int) -> tuple[bool, int]

Parameters:
i

Coordinates of the pixel to test.

j

Coordinates of the pixel to test.

id_triangle

Index of the triangle that contains the pixel (i,j).

Returns:

A tuple containing:

  • true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise.

  • id_triangle: Index of the triangle that contains the pixel (i,j).

initClick(self, I: visp._visp.core.ImageGray, delaunay: bool = false) None

Initialize a zone in image I using mouse click.

Parameters:
I: visp._visp.core.ImageGray

Image used to select the zone.

delaunay: bool = false

Flag used to enable Delaunay triangulation.

  • If true, from the image points selected by the user, a Delaunay triangulation is performed to initialize the zone.

    • A left click select a image point;

    • A right click select the last image point and ends the initialisation stage. In that case at least 3 points need to be selected by the user.

  • If false, the user select directly points as successive triangle corners. Three successive points define a triangle. It is not mandatory that triangles have one edge in common; they can define a discontinued area.

    • A left click select a triangle corner;

    • A right click select the last triangle corner and ends the initialisation stage. The number of points that are selected by the user should be a multiple of 3. For example, to select a zone as two triangles, the user has to left click five times and finish the selection on the sixth corner with a right click.

initFromPoints(self, I: visp._visp.core.ImageGray, ip: list[visp._visp.core.ImagePoint], delaunay: bool = false) None

Initialize the zone using a vector of image points.

Parameters:
I: visp._visp.core.ImageGray

Image to process.

delaunay: bool = false

  • If true, a Delaunay triangulation is perfomed on the vector of image points. This functionality is only available if ViSP is build with OpenCV >2.3 third-party.

  • If false, the vector of image points describe triangles. Its size is then a multiple of 3.