Table of Contents

Class SACSegmentation

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Sample Consensus algorithm segmentation of 3D point cloud model.

public class SACSegmentation : Algorithm, IDisposable
Inheritance
SACSegmentation
Implements
Inherited Members

Remarks

See SacMethod for supported algorithms and SacModelType for supported models.

Properties

Confidence

The confidence that ensures at least one of the selections is an error-free set of data points.

public virtual double Confidence { get; set; }

Property Value

double

DistanceThreshold

The distance to the model threshold. Considered as inlier point if distance to the model is less than threshold.

public virtual double DistanceThreshold { get; set; }

Property Value

double

IsParallel

Whether to use parallelism or not. The number of threads is set by SetNumThreads(int).

public virtual bool IsParallel { get; set; }

Property Value

bool

MaxIterations

The maximum number of iterations to attempt.

public virtual int MaxIterations { get; set; }

Property Value

int

NumberOfModelsExpected

The number of models expected.

public virtual int NumberOfModelsExpected { get; set; }

Property Value

int

RandomGeneratorState

State used to initialize the RNG (Random Number Generator).

public virtual ulong RandomGeneratorState { get; set; }

Property Value

ulong

SacMethodType

The type of sample consensus method to use.

public virtual SacMethod SacMethodType { get; set; }

Property Value

SacMethod

SacModelType

The type of sample consensus model to use.

public virtual SacModelType SacModelType { get; set; }

Property Value

SacModelType

Methods

Create(SacModelType, SacMethod, double, int)

Creates a SACSegmentation object.

public static SACSegmentation Create(SacModelType sacModelType = SacModelType.SAC_MODEL_PLANE, SacMethod sacMethod = SacMethod.SAC_METHOD_RANSAC, double threshold = 0.5, int maxIterations = 1000)

Parameters

sacModelType SacModelType

The type of sample consensus model to use.

sacMethod SacMethod

The type of sample consensus method to use.

threshold double

The distance to the model threshold.

maxIterations int

The maximum number of iterations to attempt.

Returns

SACSegmentation

SACSegmentation instance

GetCustomModelConstraints()

Gets the custom model coefficient constraint function previously set via SetCustomModelConstraints(ModelConstraintFunction?), or null if none is set.

public virtual SACSegmentation.ModelConstraintFunction? GetCustomModelConstraints()

Returns

SACSegmentation.ModelConstraintFunction

GetRadiusLimits(out double, out double)

Gets the minimum and maximum radius limits for the model.

public virtual void GetRadiusLimits(out double radiusMin, out double radiusMax)

Parameters

radiusMin double
radiusMax double

Segment(InputArray, OutputArray, OutputArray)

Executes segmentation using the sample consensus method.

public virtual int Segment(InputArray inputPts, OutputArray labels, OutputArray modelsCoefficients)

Parameters

inputPts InputArray

Original point cloud, vector of Point3 or Mat of size Nx3/3xN.

labels OutputArray

The label corresponds to the model number, 0 means it does not belong to any model, range [0, Number of final resultant models obtained].

modelsCoefficients OutputArray

The resultant models coefficients. Placed in a matrix of NxK with depth CV_64F, where N is the number of models and K is the number of coefficients of one model.

Returns

int

Number of final resultant models obtained by segmentation.

SetCustomModelConstraints(ModelConstraintFunction?)

Sets a custom model coefficient constraint function. A custom function that takes model coefficients and returns whether the model is acceptable or not. Pass null to clear a previously set constraint function.

public virtual void SetCustomModelConstraints(SACSegmentation.ModelConstraintFunction? customModelConstraints)

Parameters

customModelConstraints SACSegmentation.ModelConstraintFunction

SetRadiusLimits(double, double)

Sets the minimum and maximum radius limits for the model. Only used for models whose model parameters include a radius.

public virtual void SetRadiusLimits(double radiusMin, double radiusMax)

Parameters

radiusMin double
radiusMax double