MeNurbs¶
- class MeNurbs(*args, **kwargs)¶
Bases:
MeTracker
Class that tracks in an image a edge defined by a Nurbs.
The advantage of this class is that it enables to track an edge whose equation is not known in advance. At each iteration, the Nurbs corresponding to the edge is computed.
It is possible to have a direct access to the nurbs. It is indeed a public parameter.
The code below shows how to use this class.
#include <visp3/core/vpImage.h> #include <visp3/core/vpImagePoint.h> #include <visp3/me/vpMeNurbs.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<unsigned char> I(240, 320); // Fill the image with a black rectangle I = 0u; for (int i = 100; i < 180; i ++) { for (int j = 0; j < 320; j ++) { I[i][j] = 255; } } // Set the moving-edges tracker parameters vpMe me; me.setRange(25); me.setPointsToTrack(20); me.setLikelihoodThresholdType(vpMe::NORMALIZED_THRESHOLD); me.setThreshold(20); me.setSampleStep(10); // Initialize the moving-edges tracker parameters vpMeNurbs meNurbs; meNurbs.setNbControlPoints(4); meNurbs.setMe(&me); // Initialize the location of the edge to track (here a horizontal line std::list<vpImagePoint> ipList; //List of points belonging to the edge ipList.push_back(vpImagePoint(110,119)); ipList.push_back(vpImagePoint(140,119)); ipList.push_back(vpImagePoint(160,119)); ipList.push_back(vpImagePoint(170,119)); meNurbs.initTracking(I, ipList); while ( 1 ) { // ... Here the code to read or grab the next image. // Track the line. meNurbs.track(I); } return 0; }
Note
It is possible to display the nurbs as an overlay. For that you must use the display function of the class vpMeNurbs .
Note
In case of an edge which is not smooth, it can be interesting to use the canny detection to find the extremities. In this case, use the method setEnableCannyDetection to enable it.
Warning
: This function requires OpenCV.
Overloaded function.
__init__(self: visp._visp.me.MeNurbs) -> None
Basic constructor that calls the constructor of the class vpMeTracker .
__init__(self: visp._visp.me.MeNurbs, menurbs: visp._visp.me.MeNurbs) -> None
Copy constructor.
Methods
Overloaded function.
Overloaded function.
Overloaded function.
Gets the nurbs;
Overloaded function.
Resample a part of the edge if two vpMeSite are too far from each other.
Resample the edge if the number of sample is less than 70% of the expected value.
Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities of the nurbs.
Seek along the edge defined by the nurbs, the two extremities of the edge.
Seek the extremities of the edge thanks to a canny edge detection.
Enables to set the two thresholds use by the canny detection.
Enables or disables the canny detection used during the extremities search.
Sets the number of control points used to compute the Nurbs.
Suppression of the points which:
Suppress vpMeSites if they are too close to each other.
Overloaded function.
Set the alpha value (normal to the edge at this point) of the different vpMeSite to a value computed thanks to the nurbs.
Inherited Methods
Overloaded function.
Return the total number of moving-edges.
cP
Return object parameters expressed in the 2D image plane computed by perspective projection.
Return number of moving-edges that are tracked.
Return the initial range.
Return the number of points that has not been suppressed.
Set the list of moving edges.
Reset the tracker by removing all the moving edges.
Initialize the tracker.
cPAvailable
Overloaded function.
p
Return object parameters expressed in the 3D camera frame.
Set type of moving-edges display.
Set the mask.
Set the initial range.
Operators
__doc__
Overloaded function.
__module__
Attributes
__annotations__
cP
cPAvailable
p
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.me.MeNurbs) -> None
Basic constructor that calls the constructor of the class vpMeTracker .
__init__(self: visp._visp.me.MeNurbs, menurbs: visp._visp.me.MeNurbs) -> None
Copy constructor.
- display(*args, **kwargs)¶
Overloaded function.
display(self: visp._visp.me.MeNurbs, I: visp._visp.core.ImageGray, color: visp._visp.core.Color, thickness: int = 1) -> None
Display edge.
Warning
To effectively display the edge a call to vpDisplay::flush() is needed.
- Parameters:
- I
Image in which the edge appears.
- color
Color of the displayed line.
- thickness
Drawings thickness.
display(self: visp._visp.me.MeTracker, I: visp._visp.core.ImageGray) -> None
Display the moving edge sites with a color corresponding to their state.
If green : The vpMeSite is a good point.
If blue : The point is removed because of the vpMeSite tracking phase (contrast problem).
If purple : The point is removed because of the vpMeSite tracking phase (threshold problem).
If red : The point is removed because of the robust method in the virtual visual servoing (M-Estimator problem).
If cyan : The point is removed because it’s too close to another.
Yellow otherwise.
- Parameters:
- I
The image.
display(self: visp._visp.me.MeTracker, I: visp._visp.core.ImageRGBa) -> None
Display the moving edge sites with a color corresponding to their state.
If green : The vpMeSite is a good point.
If blue : The point is removed because of the vpMeSite tracking phase (contrast problem).
If purple : The point is removed because of the vpMeSite tracking phase (threshold problem).
If red : The point is removed because of the robust method in the virtual visual servoing (M-Estimator problem).
If cyan : The point is removed because it’s too close to another.
Yellow otherwise.
- Parameters:
- I
The image.
- static displayMeNurbs(*args, **kwargs)¶
Overloaded function.
displayMeNurbs(I: visp._visp.core.ImageGray, n: visp._visp.me.Nurbs, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None
Display of a moving nurbs.
- Parameters:
- I
The image used as background.
- n
Nurbs to display
- color
Color used to display the nurbs.
- thickness
Drawings thickness.
displayMeNurbs(I: visp._visp.core.ImageRGBa, n: visp._visp.me.Nurbs, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None
Display of a moving nurbs.
- Parameters:
- I
The image used as background.
- n
Nurbs to display
- color
Color used to display the nurbs.
- thickness
Drawings thickness.
- getMeList(*args, **kwargs)¶
Overloaded function.
getMeList(self: visp._visp.me.MeTracker) -> list[visp._visp.me.MeSite]
Return the list of moving edges
- Returns:
List of Moving Edges.
getMeList(self: visp._visp.me.MeTracker) -> list[visp._visp.me.MeSite]
Return the list of moving edges
- Returns:
List of Moving Edges.
- getNbPoints(self) int ¶
Return the number of points that has not been suppressed.
- Returns:
Number of good points.
- getNurbs(self) visp._visp.me.Nurbs ¶
Gets the nurbs;
- get_cP(self) visp._visp.core.ColVector ¶
Return object parameters expressed in the 3D camera frame.
- 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.me.MeNurbs, I: visp._visp.core.ImageGray) -> None
Initialization of the tracking. Ask the user to click left on several points along the edge to track and click right at the end.
- Parameters:
- I
Image in which the edge appears.
initTracking(self: visp._visp.me.MeNurbs, I: visp._visp.core.ImageGray, ptList: list[visp._visp.core.ImagePoint]) -> None
Initialization of the tracking. The Nurbs is initialized thanks to the list of vpImagePoint .
- Parameters:
- I
Image in which the edge appears.
- ptList
List of point to initialize the Nurbs.
initTracking(self: visp._visp.me.MeTracker, I: visp._visp.core.ImageGray) -> None
Virtual function that is called by lower classes vpMeEllipse , vpMeLine and vpMeNurbs .
- localReSample(self, I: visp._visp.core.ImageGray) None ¶
Resample a part of the edge if two vpMeSite are too far from each other. In this case the method try to initialize any vpMeSite between the two points.
- Parameters:
- I: visp._visp.core.ImageGray¶
Image in which the edge appears.
- outOfImage(*args, **kwargs)¶
Overloaded function.
outOfImage(self: visp._visp.me.MeTracker, i: int, j: int, border: int, nrows: int, ncols: int) -> bool
- Parameters:
- i
Pixel coordinates.
- j
Pixel coordinates.
- border
Number of pixels along the image border to exclude. When border is set to 0, consider the complete image.
- nrows
Size of the image.
- ncols
Size of the image.
- Returns:
true when the pixel is inside the image minus the border size, false otherwise.
outOfImage(self: visp._visp.me.MeTracker, iP: visp._visp.core.ImagePoint, border: int, nrows: int, ncols: int) -> bool
- Parameters:
- iP
Pixel coordinates.
- border
Number of pixels along the image border to exclude. When border is set to 0, consider the complete image.
- nrows
Size of the image.
- ncols
Size of the image.
- Returns:
true when the pixel is inside the image minus the border size, false otherwise.
- reSample(self, I: visp._visp.core.ImageGray) None ¶
Resample the edge if the number of sample is less than 70% of the expected value.
Note
The expected value is computed thanks to the length of the nurbs and the parameter which indicates the number of pixel between two points (vpMe::sample_step).
- Parameters:
- I: visp._visp.core.ImageGray¶
Image in which the edge appears.
- sample(self, I: visp._visp.core.ImageGray, doNotTrack: bool = false) None ¶
Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities of the nurbs.
- Parameters:
- I: visp._visp.core.ImageGray¶
Image in which the edge appears.
- doNotTrack: bool = false¶
Inherited parameter, not used.
- seekExtremities(self, I: visp._visp.core.ImageGray) None ¶
Seek along the edge defined by the nurbs, the two extremities of the edge. This function is useful in case of translation of the edge.
- Parameters:
- I: visp._visp.core.ImageGray¶
Image in which the edge appears.
- seekExtremitiesCanny(self, I: visp._visp.core.ImageGray) None ¶
Seek the extremities of the edge thanks to a canny edge detection. The edge detection enable to find the points belonging to the edge. The any vpMeSite are initialized at this points.
This method is useful when the edge is not smooth.
Note
To use the canny detection, OpenCV has to be installed.
- Parameters:
- I: visp._visp.core.ImageGray¶
Image in which the edge appears.
- setCannyThreshold(self, th1: float, th2: float) None ¶
Enables to set the two thresholds use by the canny detection.
- setDisplay(self, select: visp._visp.me.MeSite.MeSiteDisplayType) None ¶
Set type of moving-edges display.
- Parameters:
- select: visp._visp.me.MeSite.MeSiteDisplayType¶
Display type selector.
- setEnableCannyDetection(self, enable_canny: bool) None ¶
Enables or disables the canny detection used during the extremities search.
- setMask(self: visp._visp.me.MeTracker, mask: vpImage<bool>) None ¶
Set the mask.
- Parameters:
- mask
Mask.
- setMeList(self, meList: list[visp._visp.me.MeSite]) None ¶
Set the list of moving edges.
- Parameters:
- meList: list[visp._visp.me.MeSite]¶
List of Moving Edges.
- setNbControlPoints(self, nb_point: int) None ¶
Sets the number of control points used to compute the Nurbs.
- suppressPoints(self) None ¶
Suppression of the points which:
belong no more to the edge.
which are to closed to another point.
- supressNearPoints(self) None ¶
Suppress vpMeSites if they are too close to each other.
The goal is to keep the order of the vpMeSites in the list.
- track(*args, **kwargs)¶
Overloaded function.
track(self: visp._visp.me.MeNurbs, I: visp._visp.core.ImageGray) -> None
Track the edge in the image I.
- Parameters:
- I
Image in which the edge appears.
track(self: visp._visp.me.MeTracker, I: visp._visp.core.ImageGray) -> None
Track moving-edges.
- Parameters:
- I
Image.