Dot

class Dot(*args, **kwargs)

Bases: Tracker

This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage .

The underground algorithm is based on a binarization of the image and a connex component segmentation to determine the dot characteristics (location, moments, size…).

The following sample code shows how to grab images from a firewire camera, track a blob and display the tracking results.

#include <visp3/blob/vpDot.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vp1394TwoGrabber.h>

int main()
{
#if defined(VISP_HAVE_DC1394)
  vpImage<unsigned char> I; // Create a gray level image container
  vp1394TwoGrabber g(false); // Create a grabber based on libdc1394-2.x third party lib
  g.acquire(I); // Acquire an image

#if defined(VISP_HAVE_X11)
  vpDisplayX d(I, 0, 0, "Camera view");
#endif
  vpDisplay::display(I);
  vpDisplay::flush(I);

  vpDot blob;
  blob.initTracking(I);
  blob.setGraphics(true);

  while(1) {
    g.acquire(I); // Acquire an image
    vpDisplay::display(I);
    blob.track(I);

    vpDisplay::flush(I);
  }
#endif
}

Note

See vpDot2

Overloaded function.

  1. __init__(self: visp._visp.blob.Dot) -> None

  2. __init__(self: visp._visp.blob.Dot, ip: visp._visp.core.ImagePoint) -> None

Constructor with initialization of the dot location.

Parameters:
ip

An image point with sub-pixel coordinates.

  1. __init__(self: visp._visp.blob.Dot, d: visp._visp.blob.Dot) -> None

Copy constructor.

Methods

__init__

Overloaded function.

display

Display in overlay the dot edges and center of gravity.

displayDot

Overloaded function.

getArea

Gets the area of the blob corresponding also to the zero order moment.

getBBox

Return the dot bounding box.

getCog

Return the location of the dot center of gravity.

getConnexities

Return the list of all the image points inside the dot.

getEdges

Return the list of all the image points on the border of the dot.

getGamma

getGrayLevelPrecision

Return the precision of the gray level of the dot.

getHeight

Return the width of the dot.

getMaxDotSize

getMeanGrayLevel

Return the mean gray level value of the dot.

getPolygon

return:

a vpPolygon made from the edges of the dot.

getWidth

Return the width of the dot.

get_nij

Gets the second order normalized centered moment \(n_{ij}\) as a 3-dim vector containing \(n_{20}, n_{11}, n_{02}\) such as \(n_{ij} = \mu_{ij}/m_{00}\)

initTracking

Overloaded function.

print

setCog

Initialize the dot coordinates with ip .

setComputeMoments

Activates the dot's moments computation.

setConnexity

Set the type of connexity: 4 or 8.

setGraphics

Activates the display of all the pixels of the dot during the tracking.

setGraphicsThickness

Modify the default thickness that is set to 1 of the drawings in overlay when setGraphics() is enabled.

setGrayLevelMax

setGrayLevelMin

setGrayLevelPrecision

Set the precision of the gray level of the dot.

setMaxDotSize

Maximal size of the region to track in terms of image size percentage.

track

Overloaded function.

Inherited Methods

get_p

Return object parameters expressed in the 2D image plane computed by perspective projection.

get_cP

Return object parameters expressed in the 3D camera frame.

cP

p

cPAvailable

Operators

__doc__

__eq__

__hash__

__init__

Overloaded function.

__module__

__ne__

__repr__

Attributes

CONNEXITY_4

CONNEXITY_8

__annotations__

__hash__

cP

cPAvailable

p

class ConnexityType(self, value: int)

Bases: pybind11_object

Type of connexity 4, or 8.

Values:

  • CONNEXITY_4: For a given pixel 4 neighbors are considered (left, right, up, down)

  • CONNEXITY_8: For a given pixel 8 neighbors are considered (left, right, up, down, and the 4 pixels located on the diagonal)

__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
__eq__(self, d: visp._visp.blob.Dot) bool
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.blob.Dot) -> None

  2. __init__(self: visp._visp.blob.Dot, ip: visp._visp.core.ImagePoint) -> None

Constructor with initialization of the dot location.

Parameters:
ip

An image point with sub-pixel coordinates.

  1. __init__(self: visp._visp.blob.Dot, d: visp._visp.blob.Dot) -> None

Copy constructor.

__ne__(self, d: visp._visp.blob.Dot) bool
display(self, I: visp._visp.core.ImageGray, color: visp._visp.core.Color, thickness: int = 1) None

Display in overlay the dot edges and center of gravity.

Parameters:
I: visp._visp.core.ImageGray

Image.

color: visp._visp.core.Color

The color used for the display.

static displayDot(*args, **kwargs)

Overloaded function.

  1. displayDot(I: visp._visp.core.ImageGray, cog: visp._visp.core.ImagePoint, edges_list: list[visp._visp.core.ImagePoint], color: visp._visp.core.Color, thickness: int = 1) -> None

Display the dot center of gravity and its list of edges.

Parameters:
I

The image used as background.

cog

The center of gravity.

edges_list

The list of edges;

color

Color used to display the dot.

thickness

Thickness of the dot.

  1. displayDot(I: visp._visp.core.ImageRGBa, cog: visp._visp.core.ImagePoint, edges_list: list[visp._visp.core.ImagePoint], color: visp._visp.core.Color, thickness: int = 1) -> None

Display the dot center of gravity and its list of edges.

Parameters:
I

The image used as background.

cog

The center of gravity.

edges_list

The list of edges;

color

Color used to display the dot.

thickness

Thickness of the dot.

getArea(self) float

Gets the area of the blob corresponding also to the zero order moment.

Returns:

The blob area.

getBBox(self) visp._visp.core.Rect

Return the dot bounding box.

Note

See getWidth() , getHeight()

getCog(self) visp._visp.core.ImagePoint

Return the location of the dot center of gravity.

Returns:

The coordinates of the center of gravity.

getConnexities(self) list[visp._visp.core.ImagePoint]

Return the list of all the image points inside the dot.

Returns:

The list of all the images points in the dot. This list is updated after a call to track() .

getEdges(self) list[visp._visp.core.ImagePoint]

Return the list of all the image points on the border of the dot.

Warning

Doesn’t return the image points inside the dot anymore. To get those points see getConnexities() .

getGamma(self) float
getGrayLevelPrecision(self) float

Return the precision of the gray level of the dot. It is a double precision float witch value is in ]0,1]. 1 means full precision, whereas values close to 0 show a very bad precision.

getHeight(self) int

Return the width of the dot.

Note

See getHeight()

getMaxDotSize(self) float
getMeanGrayLevel(self) float

Return the mean gray level value of the dot.

getPolygon(self) visp._visp.core.Polygon
Returns:

a vpPolygon made from the edges of the dot.

getWidth(self) int

Return the width of the dot.

Note

See getHeight()

get_cP(self) visp._visp.core.ColVector

Return object parameters expressed in the 3D camera frame.

get_nij(self) visp._visp.core.ColVector

Gets the second order normalized centered moment \(n_{ij}\) as a 3-dim vector containing \(n_{20}, n_{11}, n_{02}\) such as \(n_{ij} = \mu_{ij}/m_{00}\)

Note

See getCog() , getArea()

Returns:

The 3-dim vector containing \(n_{20}, n_{11}, n_{02}\) .

get_p(self) visp._visp.core.ColVector

Return object parameters expressed in the 2D image plane computed by perspective projection.

initTracking(*args, **kwargs)

Overloaded function.

  1. initTracking(self: visp._visp.blob.Dot, I: visp._visp.core.ImageGray) -> None

Initialize the tracking with a mouse click and update the dot characteristics (center of gravity, moments).

Wait a user click in a gray area in the image I. The clicked pixel will be the starting point from which the dot will be tracked.

The threshold used to segment the dot is set with the grayLevelPrecision parameter. See the formula in setGrayLevelPrecision() function.

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog() . To compute the moments use setComputeMoments(true) before a call to initTracking() .

Warning

The content of the image modified since we call track() to compute the dot characteristics.

Note

See track() , getCog()

Parameters:
I

Image to process.

  1. initTracking(self: visp._visp.blob.Dot, I: visp._visp.core.ImageGray, ip: visp._visp.core.ImagePoint) -> None

Initialize the tracking for a dot supposed to be located at (u,v) and updates the dot characteristics (center of gravity, moments).

The threshold used to segment the dot is set to 80 percent of the gray level of the pixel (u,v).

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog() . To compute the moments use setComputeMoments(true) before a call to initTracking() .

Warning

The content of the image modified since we call track() to compute the dot characteristics.

Note

See track()

Parameters:
I

Image to process.

ip

Location of the starting point from which the dot will be tracked in the image.

  1. initTracking(self: visp._visp.blob.Dot, I: visp._visp.core.ImageGray, ip: visp._visp.core.ImagePoint, gray_level_min: int, gray_level_max: int) -> None

Initialize the tracking for a dot supposed to be located at (u,v) and updates the dot characteristics (center of gravity, moments).

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog() . To compute the moments use setComputeMoments(true) before a call to initTracking() .

Warning

The content of the image modified since we call track() to compute the dot characteristics.

Note

See track() , getCog()

Parameters:
I

Image to process.

ip

Location of the starting point from which the dot will be tracked in the image.

print(self: visp._visp.blob.Dot, os: std::ostream) None
setCog(self, ip: visp._visp.core.ImagePoint) None

Initialize the dot coordinates with ip .

setComputeMoments(self, activate: bool) None

Activates the dot’s moments computation.

Computed moment are vpDot::m00 , vpDot::m10 , vpDot::m01 , vpDot::m11 , vpDot::m20 , vpDot::m02 and second order centered moments vpDot::mu11 , vpDot::mu20 , vpDot::mu02 computed with respect to the blob centroid.

The coordinates of the region’s centroid (u, v) can be computed from the moments by \(u=\frac{m10}{m00}\) and \(v=\frac{m01}{m00}\) .

Parameters:
activate: bool

true, if you want to compute the moments. If false, moments are not computed.

setConnexity(self, type: visp._visp.blob.Dot.ConnexityType) None

Set the type of connexity: 4 or 8.

setGraphics(self, activate: bool) None

Activates the display of all the pixels of the dot during the tracking. The default thickness of the overlayed drawings can be modified using setGraphicsThickness() .

Warning

To effectively display the dot graphics a call to vpDisplay::flush() is needed.

Note

See setGraphicsThickness()

Parameters:
activate: bool

true to activate the display of dot pixels, false to turn off the display.

setGraphicsThickness(self, t: int) None

Modify the default thickness that is set to 1 of the drawings in overlay when setGraphics() is enabled.

Note

See setGraphics()

setGrayLevelMax(self, level_max: int) None
setGrayLevelMin(self, level_min: int) None
setGrayLevelPrecision(self, grayLevelPrecision: float) None

Set the precision of the gray level of the dot.

Note

See setWidth(), setHeight(), setGrayLevelMin() , setGrayLevelMax()

setMaxDotSize(self, percentage: float) None

Maximal size of the region to track in terms of image size percentage.

During the tracking, if the dot size if bigger than the maximal size allowed an exception is throwed : vpTrackingException::featureLostError .

Parameters:
percentage: float

Image size percentage corresponding to the dot maximal size. Values should be in ]0 : 1]. If 1, that means that the dot to track could take up the whole image.

track(*args, **kwargs)

Overloaded function.

  1. track(self: visp._visp.blob.Dot, I: visp._visp.core.ImageGray) -> None

Track and compute the dot characteristics.

To get the center of gravity coordinates of the dot, use getCog() . To compute the moments use setComputeMoments(true) before a call to initTracking() .

Warning

The image is modified (all the pixels that belong to the point are set to white (ie to 255).

Note

See getCog()

Parameters:
I

Image to process.

  1. track(self: visp._visp.blob.Dot, I: visp._visp.core.ImageGray, ip: visp._visp.core.ImagePoint) -> None

Track and updates the new dot coordinates

To compute the moments use setComputeMoments(true) before a call to initTracking() or track() .

Warning

The image is modified (all the pixels that belong to the point are set to white (ie to 255).

Parameters:
I

Image to process.

ip

[out] : Sub pixel coordinate of the tracked dot center of gravity.

__hash__ = None