![]() |
Visual Servoing Platform version 3.7.0
|
#include <vpMe.h>
Public Types | |
| enum | vpLikelihoodThresholdType { OLD_THRESHOLD = 0 , NORMALIZED_THRESHOLD = 1 } |
Public Member Functions | |
| vpMe () | |
| vpMe (const vpMe &me) | |
| virtual | ~vpMe () |
| vpMe & | operator= (const vpMe &me) |
| vpMe & | operator= (const vpMe &&me) |
| void | checkSamplestep (double &sample_step) |
| unsigned int | getAngleStep () const |
| int | getInitRange () const |
| vpMatrix * | getMask () const |
| unsigned int | getMaskNumber () const |
| int | getMaskSign () const |
| unsigned int | getMaskSize () const |
| double | getMinSampleStep () const |
| double | getMu1 () const |
| double | getMu2 () const |
| int | getNbTotalSample () const |
| int | getPointsToTrack () const |
| unsigned int | getRange () const |
| double | getSampleStep () const |
| int | getStrip () const |
| double | getThreshold () const |
| double | getThresholdMarginRatio () const |
| double | getMinThreshold () const |
| bool | getUseAutomaticThreshold () const |
| vpLikelihoodThresholdType | getLikelihoodThresholdType () const |
| void | initMask () |
| void | print () |
| void | setAngleStep (const unsigned int &anglestep) |
| void | setInitRange (const int &initRange) |
| void | setMaskNumber (const unsigned int &mask_number) |
| void | setMaskSign (const int &mask_sign) |
| void | setMaskSize (const unsigned int &mask_size) |
| void | setMinSampleStep (const double &min_samplestep) |
| void | setMu1 (const double &mu_1) |
| void | setMu2 (const double &mu_2) |
| void | setNbTotalSample (const int &ntotal_sample) |
| void | setPointsToTrack (const int &points_to_track) |
| void | setRange (const unsigned int &range) |
| void | setSampleStep (const double &sample_step) |
| void | setStrip (const int &strip) |
| void | setThreshold (const double &threshold) |
| void | setThresholdMarginRatio (const double &thresholdMarginRatio) |
| void | setMinThreshold (const double &minThreshold) |
| void | setLikelihoodThresholdType (const vpLikelihoodThresholdType likelihood_threshold_type) |
Friends | |
| void | to_json (nlohmann::json &j, const vpMe &me) |
| void | from_json (const nlohmann::json &j, vpMe &me) |
This class defines predetermined masks for moving-edges (ME) sites and holds moving edges tracking parameters.
To know more about moving-edges and their usage for object tracking, follow Tutorial: Moving-edges tracking.
JSON serialization
Since ViSP 3.6.0, if ViSP is build with JSON for modern C++ 3rd-party we introduce JSON serialization capabilities for vpMe. The following sample code shows how to save moving-edges settings in a file named me.json and reload the values from this JSON file.
If you build and execute the sample code, it will produce the following output:
The content of the me.json file is the following:
Tutorials
If you are interested in using a ME tracker in your application, you may have a look at:
| vpMe::vpMe | ( | ) |
Default constructor.
Definition at line 433 of file vpMe.cpp.
References initMask(), and OLD_THRESHOLD.
Referenced by from_json, operator=(), operator=(), to_json, and vpMe().
| vpMe::vpMe | ( | const vpMe & | me | ) |
|
inline |
|
inline |
Return the angle step.
Definition at line 202 of file vpMe.h.
Referenced by vpMeSite::computeMaskIndex().
|
inline |
|
inline |
Return the selected choice for the likelihood threshold.
Definition at line 342 of file vpMe.h.
Referenced by vpMeSite::computeFinalThreshold(), from_json, and to_json.
|
inline |
Get the matrix of the mask.
Definition at line 215 of file vpMe.h.
Referenced by vpMeSite::convolution(), and vpMeSite::convolution().
|
inline |
Return the number of mask applied to determine the object contour. The number of mask determines the precision of the normal of the edge for every sample. If precision is 2deg, then there are 360/2 = 180 masks.
Definition at line 224 of file vpMe.h.
Referenced by to_json.
|
inline |
|
inline |
Return the actual mask size (in pixel) used to compute the image gradient and determine the object contour. The mask size defines the size of the convolution mask used to detect an edge.
Definition at line 240 of file vpMe.h.
Referenced by vpMeSite::computeFinalThreshold(), vpMeSite::convolution(), vpMeSite::convolution(), from_json, and to_json.
|
inline |
|
inline |
Return the minimum contrast threshold of the vpMeSite that can be used when using the automatic threshold computation.
Definition at line 325 of file vpMe.h.
Referenced by from_json, vpMeSite::setContrastThreshold(), and to_json.
|
inline |
Get the minimum image contrast allowed to detect a contour.
Definition at line 255 of file vpMe.h.
Referenced by to_json, vpMeSite::track(), and vpMeSite::trackMultipleHypotheses().
|
inline |
Get the maximum image contrast allowed to detect a contour.
Definition at line 262 of file vpMe.h.
Referenced by to_json, vpMeSite::track(), and vpMeSite::trackMultipleHypotheses().
|
inline |
|
inline |
|
inline |
Return the seek range on both sides of the reference pixel.
Definition at line 283 of file vpMe.h.
Referenced by from_json, to_json, vpMeSite::track(), and vpMeSite::trackMultipleHypotheses().
|
inline |
|
inline |
Get the number of pixels that are ignored around the image borders.
Definition at line 297 of file vpMe.h.
Referenced by vpMeSite::convolution(), vpMeSite::convolution(), from_json, and to_json.
|
inline |
Return the likelihood threshold used to determine if the moving edge is valid or not.
Definition at line 306 of file vpMe.h.
Referenced by from_json, vpMeSite::setContrastThreshold(), and to_json.
|
inline |
Return the ratio of the initial contrast to use to initialize the contrast threshold of the vpMeSite.
|
inline |
Indicates if the contrast threshold of the vpMeSite is automatically computed.
Definition at line 333 of file vpMe.h.
Referenced by vpMeSite::setContrastThreshold().
| BEGIN_VISP_NAMESPACE void vpMe::initMask | ( | ) |
Initialise the array of matrices with the defined size and the number of matrices to create.
Definition at line 383 of file vpMe.cpp.
Referenced by from_json, operator=(), operator=(), setMaskNumber(), setMaskSize(), and vpMe().
| void vpMe::print | ( | ) |
Print using std::cout moving edges settings.
Definition at line 404 of file vpMe.cpp.
References NORMALIZED_THRESHOLD.
|
inline |
|
inline |
Set the range used during the initialization step. A negative value means that the default value is used by the different ME primitives.
| initRange | : New range, or a negative value to use the default ranges. |
Definition at line 368 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the likelihood threshold type used to determine if the moving edge is valid or not.
| likelihood_threshold_type | : Likelihood threshold type. It is recommended to use NORMALIZED_THRESHOLD and set the threshold using setThreshold() with a value corresponding to the minimal luminance contrast to consider that can handle values in range [0 ; 255]. |
Definition at line 531 of file vpMe.h.
Referenced by from_json.
| void vpMe::setMaskNumber | ( | const unsigned int & | mask_number | ) |
Set the number of mask applied to determine the object contour. The number of mask determines the precision of the normal of the edge for every sample. If precision is 2deg, then there are 360/2 = 180 masks.
| mask_number | : The number of mask. |
Definition at line 555 of file vpMe.cpp.
References initMask().
Referenced by from_json.
|
inline |
| void vpMe::setMaskSize | ( | const unsigned int & | mask_size | ) |
Set the mask size (in pixel) used to compute the image gradient and determine the object contour. The mask size defines the size of the convolution mask used to detect an edge.
| mask_size | : New mask size. |
Definition at line 563 of file vpMe.cpp.
References initMask().
Referenced by from_json.
|
inline |
|
inline |
Set the minimum value of the contrast threshold of the vpMeSite.
| minThreshold | Minimum value of the contrast threshold. A negative value means that automatic thresholding is not activated. |
Definition at line 517 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the minimum image contrast allowed to detect a contour.
| mu_1 | : new mu1. |
Definition at line 408 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the maximum image contrast allowed to detect a contour.
| mu_2 | : New mu2. |
Definition at line 415 of file vpMe.h.
Referenced by from_json.
|
inline |
Set how many discretized points are used to track the feature.
| ntotal_sample | : New total number of sample. |
Definition at line 422 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the number of points to track.
| points_to_track | : New number of points to track. |
Definition at line 431 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the seek range on both sides of the reference pixel.
| range | : New range. |
Definition at line 438 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the minimum distance in pixel between two discretized points.
| sample_step | : New sample_step. |
Definition at line 445 of file vpMe.h.
Referenced by from_json.
|
inline |
|
inline |
Set the likelihood threshold used to determined if the moving edge is valid or not.
| threshold | : Threshold to consider. Two different cases need to be considered depending on the likelihood threshold type that can be set using setLikelihoodThresholdType() or get using getLikelihoodThresholdType(). The default likelihood threshold type is set to OLD_THRESHOLD to keep compatibility with ViSP previous releases, but it is recommended to use rather the NORMALIZED_THRESHOLD type like in the following sample code. When doing so, the threshold is more easy to set since it corresponds to the minimal luminance contrast to consider with values in range [0 ; 255]. |
When the likelihood threshold type is set by default to OLD_THRESHOLD like in the next example, values of the likelihood threshold depends on the minimal luminance contrast to consider and the mask size that can be set using setMaskSize() and retrieved using getMaskSize().
The previous sample code is similar to the next one:
Definition at line 489 of file vpMe.h.
Referenced by from_json.
|
inline |
Set the the ratio of the initial contrast to use to initialize the contrast threshold of the vpMeSite.
| thresholdMarginRatio | Value of the likelihood threshold ratio, between 0 and 1. A negative value means that this the automatic thresholding is not activated. The threshold of a vpMeSite is computed from the convolution value computed when initializing the vpMeTracker multiplied by this ratio. |
Definition at line 500 of file vpMe.h.
References vpException::badValue.
Referenced by from_json.
|
friend |
Retrieve a vpMe object from a JSON representation.
JSON content (key: type):
Example:
| j | JSON representation to convert |
| me | converted object |
Definition at line 658 of file vpMe.h.
References from_json, getInitRange(), getLikelihoodThresholdType(), getMaskSign(), getMaskSize(), getMinSampleStep(), getMinThreshold(), getNbTotalSample(), getPointsToTrack(), getRange(), getSampleStep(), getStrip(), getThreshold(), getThresholdMarginRatio(), initMask(), setAngleStep(), setInitRange(), setLikelihoodThresholdType(), setMaskNumber(), setMaskSign(), setMaskSize(), setMinSampleStep(), setMinThreshold(), setMu1(), setMu2(), setNbTotalSample(), setPointsToTrack(), setRange(), setSampleStep(), setStrip(), setThreshold(), setThresholdMarginRatio(), and vpMe().
Referenced by from_json.
|
friend |
Convert a vpMe object to a JSON representation.
| j | : Resulting json object. |
| me | : The object to convert. |
Definition at line 637 of file vpMe.h.
References getInitRange(), getLikelihoodThresholdType(), getMaskNumber(), getMaskSign(), getMaskSize(), getMinSampleStep(), getMinThreshold(), getMu1(), getMu2(), getNbTotalSample(), getPointsToTrack(), getRange(), getSampleStep(), getStrip(), getThreshold(), getThresholdMarginRatio(), to_json, and vpMe().
Referenced by to_json.