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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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.
__init__(self: visp._visp.blob.Dot) -> None
__init__(self: visp._visp.blob.Dot, ip: visp._visp.core.ImagePoint) -> None
__init__(self: visp._visp.blob.Dot, d: visp._visp.blob.Dot) -> None
Copy constructor.
Methods
Overloaded function.
Display in overlay the dot edges and center of gravity.
Overloaded function.
Gets the area of the blob corresponding also to the zero order moment.
Return the dot bounding box.
Return the location of the dot center of gravity.
Return the list of all the image points inside the dot.
Return the list of all the image points on the border of the dot.
Return the precision of the gray level of the dot.
Return the width of the dot.
Return the mean gray level value of the dot.
- return:
a vpPolygon made from the edges of the dot.
Return the width of the dot.
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}\)
Overloaded function.
Initialize the dot center of gravity coordinates with cog .
Activates the dot's moments computation.
Activates the display of all the pixels of the dot during the tracking.
Modify the default thickness that is set to 1 of the drawings in overlay when setGraphics() is enabled.
Set the precision of the gray level of the dot.
Maximal size of the region to track in terms of image size percentage.
Overloaded function.
Inherited Methods
cP
Return object parameters expressed in the 2D image plane computed by perspective projection.
cPAvailable
p
Return object parameters expressed in the 3D camera frame.
Operators
__doc__
Overloaded function.
__module__
__repr__
Attributes
CONNEXITY_4
CONNEXITY_8
__annotations__
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)
- __eq__(self, d: visp._visp.blob.Dot) bool ¶
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.blob.Dot) -> None
__init__(self: visp._visp.blob.Dot, ip: visp._visp.core.ImagePoint) -> None
__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.
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.
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() .
- 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.
- getPolygon(self) visp._visp.core.Polygon ¶
- Returns:
a vpPolygon made from the edges of the dot.
- 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.
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 gray level precision 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.
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.
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.
- setCog(self, cog: visp._visp.core.ImagePoint) None ¶
Initialize the dot center of gravity coordinates with cog .
- 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}\) .
- setConnexity(self, connexityType: visp._visp.blob.Dot.ConnexityType) None ¶
- 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()
- setGraphicsThickness(self, thickness: int) None ¶
Modify the default thickness that is set to 1 of the drawings in overlay when setGraphics() is enabled.
Note
See setGraphics()
- 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 .
- track(*args, **kwargs)¶
Overloaded function.
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.
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
¶