🟠 RANSAC Fitting

Function Description

This operator uses the RANSAC algorithm to perform geometric model fitting on input point cloud data, capable of fitting basic geometric shapes such as planes, lines, spheres, and 3D circles.

RANSAC is an iterative algorithm that can identify "inliers" (points conforming to the model) and "outliers" (noise or points not conforming to the model) in input data, estimating accurate model fitting parameters.

Usage Scenarios

  • Geometric object detection: When specific geometric shapes of objects (such as tabletops, pipes, spherical objects, circular holes) need to be detected and located in complex 3D scenes.

  • Point cloud segmentation: Segment point clouds into different parts based on whether they conform to a certain geometric model. For example, extract all flat surfaces from a scene.

  • Noise filtering: By identifying main geometric structures, noise points that don’t conform to that structure can be identified as outliers and separated.

  • Parameter estimation: Extract precise parameters of specific geometric shapes from point cloud data, such as plane equations, sphere centers and radii, etc.

Input Output

Input

Point Cloud: Input point cloud data to be fitted, can be a single point cloud or point cloud list.

Output

Fitted Interior Point Cloud: Point cloud of the fitting model (inliers).

Fitted Exterior Point Cloud: Point cloud that doesn’t belong to the fitting model (outliers).

Equation Parameters: List of equation parameters of the fitted shape.

  • Plane model: [a,b,c,d], where the plane equation is ax+by+cz+d=0. (a,b,c) is the plane’s normal vector, d is a parameter related to the plane’s distance to origin.

  • Line model: [x,y,z,dx,dy,dz], where (x,y,z) is a point on the line, (dx,dy,dz) is the line’s direction vector.

  • Sphere model: [center.x,center.y,center.z,radius], i.e., sphere center’s three-dimensional coordinates and sphere radius.

  • 3D circle model: [center.x,center.y,center.z,normal.x,normal.y,normal.z,radius], i.e., circle center’s three-dimensional coordinates, circle plane normal vector’s three-dimensional coordinates, and circle radius.

Result Direction: List of main direction vectors of fitting results.

  • Plane fitting: Returns plane normal vector [nx,ny,nz].

  • Line fitting: Returns line direction vector [dx,dy,dz].

  • 3D circle fitting: Returns normal vector [nx,ny,nz] of the plane where the circle lies.

  • Sphere fitting: Does not return direction vector.

Parameter Description

This operator has two versions:

  • RANSAC Fitting: Processes point clouds without normal information.

  • RANSAC Fitting (With Normals): Processes point clouds with normal information.

Both have identical core functions and parameters, differing only in the type of point cloud data processed.

Minimum Fit Points

Parameter Description

Minimum number of point cloud points that each iteration candidate model must contain to be considered valid.

Parameter Adjustment

  • Increase this value: Can ensure that the fitted model is supported by enough points, helping to avoid mistaking noise points or very small point clusters as valid models. But may also make it impossible to detect small objects or incomplete parts of objects.

  • Decrease this value: Allows fitting models with fewer points. Easier to detect small objects or incomplete parts of objects, but may also be more susceptible to noise. This value should not be less than the minimum number of points needed to define the selected geometric model (e.g., at least 3 points for a plane, at least 2 points for a line).

Parameter Range

[1,10000000], Default: 100

Maximum Fit Points

Parameter Description

Maximum number of point cloud points that each iteration candidate model can contain.

Parameter Adjustment

This parameter is usually used to prevent a very large structure that conforms to the model (such as a huge plane background) from consuming all points, making it impossible to detect other smaller structures on it. If the main goal is to detect the largest structure conforming to the model in the scene, this value can be set very large.

Parameter Range

[1,4000000], Default: 4000000

Repeat Count

Parameter Description

Refers to the number of times the RANSAC fitting process is repeated for each input point cloud data. Each repetition may find a new, different model instance. Generally, this value corresponds to the number of output result groups. If set to k, it will generally output k groups of data, unless after multiple fittings still cannot fit k results, then the output will be less than k.

Parameter Adjustment

  • Set to 1: The operator will try to find the most significant (usually containing the most inliers) model instance.

  • Set greater than 1: The operator will try to find multiple model instances in the point cloud. For example, if there are multiple tabletops in the scene, increasing this value can help detect all tabletops.

Note: Increasing this value will significantly increase computation time.

Parameter Range

[0,5000], Default: 1

Maximum Iterations

Parameter Description

In a single RANSAC fitting process (one attempt controlled by "Repeat Count"), the maximum number of iteration rounds the algorithm performs for random sampling and model validation.

Parameter Adjustment

  • Increase this value: The algorithm has more chances to randomly extract good sample points from data to build models, thus increasing the probability of finding the best possible model, especially when the inlier ratio is low (high noise), but this will increase computation time.

  • Decrease this value: Faster computation speed, but when there’s high noise or the model is not obvious, it may not find a good model.

Parameter Range

[0,100000], Default: 100

Loss Function Threshold

Parameter Description

Defines a distance threshold. If a point’s distance to the current candidate model is less than or equal to this threshold, the point is considered an "inlier" of this model.

Parameter Adjustment

  • Smaller values: Require points to be very close to the model to be accepted. This makes fitting more strict about model shape requirements, with more precise results, but more sensitive to noise and point cloud imperfections, and may miss some valid points that are slightly farther away.

  • Larger values: Allow points to be accepted even when they are relatively far from the model. This makes the algorithm more tolerant of noise and shape deviations, but may also cause some outliers to be incorrectly included, making model fitting less accurate.

It’s recommended to carefully adjust this parameter based on point cloud density, noise level, and model accuracy requirements. You can start with a moderate value, observe fitting results, and then gradually adjust.

Parameter Range

[0,1000000], Default: 8

Fit Model

Parameter Description

Choose the type of geometric model you want to fit from the point cloud.

Parameter Adjustment

Choose based on the shape of objects you need to detect in the point cloud. For example, if you want to detect tabletops, choose "Plane"; if you want to detect pipes (part of them), you can try "Line" (axial) or "Circle" in subsequent "RANSAC Fitting (With Normals)".

Parameter Range

Options: Plane, Line, Sphere, 3D Circle

Model Direction

Parameter Description

Sets the expected main direction of the model.

This parameter only takes effect when "Plane", "Line", or "3D Circle" models are selected. For "Plane" model, this is the plane normal vector; for "Line" model, this is the line direction; for "3D Circle" model, this is the normal vector of the plane where the circle lies.

Parameter Adjustment

Provides a rough reference direction. For example, if you need to detect a roughly vertical plane, you can set this parameter to [0,0,1] or [0,0,-1] (assuming Z-axis points up). The algorithm will search for the best match within this reference direction and the allowed "Axial Float Range" (angleEps). If the direction is completely unknown, the constraining effect of this parameter will weaken, and you can increase the "Axial Float Range".

Parameter Range

[0,0,1]

Axial Float Range

Parameter Description

Sets the maximum angular deviation allowed between the fitted model’s main direction and the direction specified by the "Model Direction" parameter.

Only takes effect when "Plane", "Line", or "3D Circle" models are selected.

Parameter Adjustment

  • Smaller values (e.g., 5-15°): Indicates you have strong prior knowledge about the model’s direction, and fitting results' direction will be strictly limited near the "Model Direction". Suitable for cases where target direction is known and doesn’t vary much.

  • Larger values (e.g., 30-90°): Indicates the model direction constraint is loose, allowing search for directions within a larger range. Suitable for cases where target direction is uncertain or you want to detect objects within a larger angular range.

Parameter Range

[0,300], Default: 30, Unit: °

Radius Size

Parameter Description

Sets the expected radius size for fitting "Sphere" or "3D Circle".

Only takes effect when "Sphere" or "3D Circle" models are selected.

Parameter Adjustment

Provides an estimate of the expected radius. The algorithm will combine "Radius Float Range" (radiusEps) to find the best match near this estimate.

Parameter Range

[0,10000], Default: 10, Unit: mm

Radius Float Range

Parameter Description

Sets the maximum deviation allowed between the fitted "Sphere" or "3D Circle" radius and the radius specified by the "Radius Size" (radius) parameter.

Unit is mm. This parameter only takes effect when "Sphere" or "3D Circle" models are selected.

Parameter Adjustment

  • Smaller values (e.g., 1-5mm): Have relatively precise estimates of the model’s radius, fitting results' radius will be strictly limited near the "Radius Size".

  • Larger values (e.g., 10-50mm): Indicates model radius constraint is loose, allowing fitting of models whose radius differs significantly from the preset value, suitable for cases where radius is uncertain or you want to detect objects within a larger radius range.

Parameter Range

[0,300], Default: 5, Unit: mm