Me¶
- class Me(*args, **kwargs)¶
Bases:
pybind11_object
This class defines predetermined masks for sites and holds moving edges tracking parameters.
JSON serialization
Since ViSP 3.6.0, if ViSP is build with soft_tool_json 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.
#include <visp3/me/vpMe.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { #if defined(VISP_HAVE_NLOHMANN_JSON) std::string filename = "me.json"; { vpMe me; me.setLikelihoodThresholdType(vpMe::NORMALIZED_THRESHOLD); me.setThreshold(20); // Value in range [0 ; 255] me.setThresholdMarginRatio(-1.); // Deactivate automatic thresholding me.setMinThreshold(-1.); // Deactivate automatic thresholding me.setMaskNumber(180); me.setMaskSign(0); me.setMu1(0.5); me.setMu2(0.5); me.setNbTotalSample(0); me.setPointsToTrack(200); me.setRange(5); me.setStrip(2); std::ofstream file(filename); const nlohmann::json j = me; file << j; file.close(); } { std::ifstream file(filename); const nlohmann::json j = nlohmann::json::parse(file); vpMe me; me = j; file.close(); std::cout << "Read moving-edges settings from " << filename << ":" << std::endl; me.print(); } #endif }
If you build and execute the sample code, it will produce the following output:
Read moving-edges settings from me.json: Moving edges settings Size of the convolution masks....5x5 pixels Number of masks..................180 Query range +/- J................5 pixels Likelihood threshold type........normalized Likelihood threshold.............20 Likelihood margin ratio..........unused Minimum likelihood threshold.....unused Contrast tolerance +/-...........50% and 50% Sample step......................10 pixels Strip............................2 pixels Min sample step..................4 pixels
The content of the ` me.json ` file is the following:
$ cat me.json {"maskSign":0,"maskSize":5,"minSampleStep":4.0,"mu":[0.5,0.5],"nMask":180,"ntotalSample":0,"pointsToTrack":200, "range":5,"sampleStep":10.0,"strip":2,"threshold":20.0,"thresholdMarginRatio":-1.0,"minThreshold":-1.0,"thresholdType":"normalized"}
Overloaded function.
__init__(self: visp._visp.me.Me) -> None
Default constructor.
__init__(self: visp._visp.me.Me, me: visp._visp.me.Me) -> None
Copy constructor.
Methods
Overloaded function.
Check sample step wrt min value.
Return the angle step.
Return the selected choice for the likelihood threshold.
Return the number of mask applied to determine the object contour.
Return the mask sign.
Return the actual mask size (in pixel) used to compute the image gradient and determine the object contour.
Get the minimum allowed sample step.
Return the minimum contrast threshold of the ** vpMeSite ** that can be used when using the automatic threshold computation.
Get the minimum image contrast allowed to detect a contour.
Get the maximum image contrast allowed to detect a contour.
Get how many discretized points are used to track the feature.
Return the number of points to track.
Return the seek range on both sides of the reference pixel.
Get the minimum distance in pixel between two discretized points.
Get the number of pixels that are ignored around the image borders.
Return the likelihood threshold used to determine if the moving edge is valid or not.
Return the ratio of the initial contrast to use to initialize the contrast threshold of the ** vpMeSite ** .
Indicates if the contrast threshold of the vpMeSite is automatically computed.
Initialise the array of matrices with the defined size and the number of matrices to create.
Print using std::cout moving edges settings.
Set the angle step.
Set the number of mask applied to determine the object contour.
Set the mask sign.
Set the mask size (in pixel) used to compute the image gradient and determine the object contour.
Set the minimum allowed sample step.
Set the minimum value of the contrast threshold of the ** vpMeSite ** .
Set the minimum image contrast allowed to detect a contour.
Set the maximum image contrast allowed to detect a contour.
Set how many discretized points are used to track the feature.
Set the number of points to track.
Set the seek range on both sides of the reference pixel.
Set the minimum distance in pixel between two discretized points.
Set the number of pixels that are ignored around the image borders.
Set the likelihood threshold used to determined if the moving edge is valid or not.
Set the the ratio of the initial contrast to use to initialize the contrast threshold of the ** vpMeSite ** .
Inherited Methods
Operators
__doc__
Overloaded function.
__module__
Attributes
NORMALIZED_THRESHOLD
OLD_THRESHOLD
__annotations__
- class LikelihoodThresholdType(self, value: int)¶
Bases:
pybind11_object
Type of likelihood threshold to use.
Values:
OLD_THRESHOLD: Old likelihood ratio threshold (to be avoided).
NORMALIZED_THRESHOLD: Easy-to-use normalized likelihood threshold corresponding to the minimal luminance contrast to consider with values in [0 ; 255].
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.me.Me) -> None
Default constructor.
__init__(self: visp._visp.me.Me, me: visp._visp.me.Me) -> None
Copy constructor.
- checkSamplestep(self, sample_step: float) float ¶
Check sample step wrt min value.
- getLikelihoodThresholdType(self) visp._visp.me.Me.LikelihoodThresholdType ¶
Return the selected choice for the likelihood threshold.
Note
See setLikelihoodThresholdType() , setThreshold() , getThreshold()
- Returns:
The likelihood threshold type to consider.
- getMaskNumber(self) int ¶
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.
- Returns:
the current number of mask.
- getMaskSize(self) int ¶
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.
- Returns:
the current mask size.
- getMinSampleStep(self) float ¶
Get the minimum allowed sample step. Useful to specify a lower bound when the sample step is changed.
- Returns:
Value of min sample step.
- getMinThreshold(self) float ¶
Return the minimum contrast threshold of the ** vpMeSite ** that can be used when using the automatic threshold computation.
Note
See setThresholdMarginRatio() , getThresholdMarginRatio() , setMinThreshold() , getLikelihoodThresholdType() , setLikelihoodThresholdType()
- Returns:
Value of the minimum contrast threshold.
- getMu1(self) float ¶
Get the minimum image contrast allowed to detect a contour.
- Returns:
Value of mu1.
- getMu2(self) float ¶
Get the maximum image contrast allowed to detect a contour.
- Returns:
Value of mu2.
- getNbTotalSample(self) int ¶
Get how many discretized points are used to track the feature.
- Returns:
Value of ntotal_sample.
- getPointsToTrack(self) int ¶
Return the number of points to track.
- Returns:
Value of points_to_track.
- getRange(self) int ¶
Return the seek range on both sides of the reference pixel.
- Returns:
Value of range.
- getSampleStep(self) float ¶
Get the minimum distance in pixel between two discretized points.
- Returns:
Value of sample_step.
- getStrip(self) int ¶
Get the number of pixels that are ignored around the image borders.
- Returns:
the value of strip.
- getThreshold(self) float ¶
Return the likelihood threshold used to determine if the moving edge is valid or not.
Note
See setThreshold() , getLikelihoodThresholdType() , setLikelihoodThresholdType()
- Returns:
Value of the likelihood threshold.
- getThresholdMarginRatio(self) float ¶
Return the ratio of the initial contrast to use to initialize the contrast threshold of the ** vpMeSite ** .
Note
See setThresholdMarginRatio() , setMinThreshold() , getMinThreshold() , getLikelihoodThresholdType() , setLikelihoodThresholdType()
- Returns:
Value of the likelihood threshold ratio, between 0 and 1.
- getUseAutomaticThreshold(self) bool ¶
Indicates if the contrast threshold of the vpMeSite is automatically computed.
- Returns:
true The contrast threshold of the vpMeSite is automatically computed.false The vpMe::m_threshold is used as a global threshold.
- initMask(self) None ¶
Initialise the array of matrices with the defined size and the number of matrices to create.
- setLikelihoodThresholdType(self, likelihood_threshold_type: visp._visp.me.Me.LikelihoodThresholdType) None ¶
- setMaskNumber(self, mask_number: int) None ¶
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.
- setMaskSize(self, mask_size: int) None ¶
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.
- setMinSampleStep(self, min_samplestep: float) None ¶
Set the minimum allowed sample step. Useful to specify a lower bound when the sample step is changed.
- setMinThreshold(self, minThreshold: float) None ¶
Set the minimum value of the contrast threshold of the ** vpMeSite ** .
Note
See getMinThreshold() , setThresholdMarginRatio() , getThresholdMarginRatio() , getLikelihoodThresholdType() , setLikelihoodThresholdType()
- setNbTotalSample(self, ntotal_sample: int) None ¶
Set how many discretized points are used to track the feature.
- setPointsToTrack(self, points_to_track: int) None ¶
Set the number of points to track.
Warning
This method is useful only for the vpMeNurbsTracker.
- setSampleStep(self, sample_step: float) None ¶
Set the minimum distance in pixel between two discretized points.
- setStrip(self, strip: int) None ¶
Set the number of pixels that are ignored around the image borders.
- setThreshold(self, threshold: float) None ¶
Set the likelihood threshold used to determined if the moving edge is valid or not.
vpMe me; me.setLikelihoodThresholdType(NORMALIZED_THRESHOLD); me.setThreshold(20); // Value in range [0 ; 255] me.setThresholdMarginRatio(-1.); // Deactivate automatic thresholding me.setMinThreshold(-1.); // Deactivate automatic thresholding
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() .
vpMe me; // By default the constructor set the threshold type to OLD_THRESHOLD me.setThreshold(10000); // Value that depends on the minimal luminance contrast to consider and the mask size. me.setThresholdMarginRatio(-1.); // Deactivate automatic thresholding me.setMinThreshold(-1.); // Deactivate automatic thresholding
The previous sample code is similar to the next one:
vpMe me; me.setLikelihoodThresholdType(OLD_THRESHOLD); me.setThreshold(10000); // Value that depends on the minimal luminance contrast to consider and the mask size. me.setThresholdMarginRatio(-1.); // Deactivate automatic thresholding me.setMinThreshold(-1.); // Deactivate automatic thresholding
Note
See getThreshold() , getLikelihoodThresholdType()
- Parameters:
- threshold: float¶
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].
- setThresholdMarginRatio(self, thresholdMarginRatio: float) None ¶
Set the the ratio of the initial contrast to use to initialize the contrast threshold of the ** vpMeSite ** .
Note
See getThresholdMarginRatio() , setMinThreshold() , getMinThreshold() , getLikelihoodThresholdType() , setLikelihoodThresholdType()