Stochastic Plane Fitting API Documentation
Stochastic Plane Fitting
Code adapted from https://github.com/leomariga/pyRANSAC-3D
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
plane_fit(pts, thresh=100, maxIteration=1000)
Find the best-fitting plane to a 3D point cloud using RANSAC (In serial). Slower -- but uses less ram if that's a consideration
This function applies the RANSAC algorithm to find the plane that best fits a set of 3D points, iterating over random samples of points to estimate the plane equation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
ndarray
|
3D point cloud as a |
required |
thresh
|
int or float
|
Threshold distance (in meters) from the plane considered as inliers. Points within this distance from the plane are considered inliers (default: 100). |
100
|
maxIteration
|
int
|
Maximum number of iterations for RANSAC (default: 1000). |
1000
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Note
** Modified from https://github.com/leomariga/pyRANSAC-3D/ **
Example
import pandas as pd
file = 'catalog.csv' # some rows x,y,depth_m all in meters
data = pd.read_csv(file)
cluster_coords = data[["x", "y", "depth_m"]].values
plane_params, inliers = plane_fit(
cluster_coords,
thresh=250,
maxIteration=1000,
)
Source code in ransac3D.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
plane_fit_vectorized(pts, thresh=100, maxIteration=1000, seed=None)
Find the best-fitting plane to a 3D point cloud using RANSAC (vectorized version). Runs faster than plane_fit version below but requires more ram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
ndarray
|
Array of shape (N, 3) where each row is a 3D point. |
required |
thresh
|
float
|
Distance threshold to consider a point as an inlier (default: 100). |
100
|
maxIteration
|
int
|
Number of random plane hypotheses to test (default: 1000). |
1000
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Source code in ransac3D.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |