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>

int main()
{
  vpImage<unsigned char> I(240, 320);

  // Fill the image with a black rectangle
  I = 0;
  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.

  1. __init__(self: visp._visp.me.MeNurbs) -> None

Basic constructor that calls the constructor of the class vpMeTracker .

  1. __init__(self: visp._visp.me.MeNurbs, menurbs: visp._visp.me.MeNurbs) -> None

Copy constructor.

Methods

__init__

Overloaded function.

display

Overloaded function.

displayMeNurbs

Overloaded function.

getNurbs

Gets the nurbs;

initTracking

Overloaded function.

localReSample

Resample a part of the edge if two vpMeSite are too far from each other.

reSample

Resample the edge if the number of sample is less than 70% of the expected value.

sample

Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities of the nurbs.

seekExtremities

Seek along the edge defined by the nurbs, the two extremities of the edge.

seekExtremitiesCanny

Seek the extremities of the edge thanks to a canny edge detection.

setCannyThreshold

Enables to set the two thresholds use by the canny detection.

setEnableCannyDetection

Enables or disables the canny detection used during the extremities search.

setNbControlPoints

Sets the number of control points used to compute the Nurbs.

suppressPoints

Suppression of the points which:

supressNearPoints

Suppress vpMeSites if they are too close to each other.

track

Overloaded function.

updateDelta

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

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.

getInitRange

Return the initial range.

reset

Reset the tracker by removing all the moving edges.

cP

init

Initialize the tracker.

p

setMask

Set the mask.

getNbPoints

Return the number of points that has not been suppressed.

totalNumberOfSignal

Return the total number of moving-edges.

setInitRange

Set the initial range.

outOfImage

Overloaded function.

setDisplay

Set type of moving-edges display.

numberOfSignal

Return number of moving-edges that are tracked.

getMeList

Overloaded function.

setMeList

Set the list of moving edges.

cPAvailable

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

cP

cPAvailable

p

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.me.MeNurbs) -> None

Basic constructor that calls the constructor of the class vpMeTracker .

  1. __init__(self: visp._visp.me.MeNurbs, menurbs: visp._visp.me.MeNurbs) -> None

Copy constructor.

display(*args, **kwargs)

Overloaded function.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

getInitRange(self) int

Return the initial range.

Returns:

Value of init_range.

getMeList(*args, **kwargs)

Overloaded function.

  1. getMeList(self: visp._visp.me.MeTracker) -> list[visp._visp.me.MeSite]

Return the list of moving edges

Returns:

List of Moving Edges.

  1. 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.

init(self) None

Initialize the tracker.

initTracking(*args, **kwargs)

Overloaded function.

  1. 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.

  1. 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.

  1. 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.

numberOfSignal(self) int

Return number of moving-edges that are tracked.

outOfImage(*args, **kwargs)

Overloaded function.

  1. 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.

  1. 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.

reset(self) None

Reset the tracker by removing all the moving edges.

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.

Parameters:
th1: float

The first threshold;

th2: float

The second threshold;

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.

Parameters:
enable_canny: bool

if true it enables the canny detection.

setInitRange(self, r: int) None

Set the initial range.

Parameters:
r: int

initial range.

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.

Parameters:
nb_point: int

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.

totalNumberOfSignal(self) int

Return the total number of moving-edges.

track(*args, **kwargs)

Overloaded function.

  1. 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.

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

Track moving-edges.

Parameters:
I

Image.

updateDelta(self) None

Set the alpha value (normal to the edge at this point) of the different vpMeSite to a value computed thanks to the nurbs.