仅依赖 NumPy,但需自行把点云整理成 (N,3) 数组;可视化需另外安装 Open3D;拟合阈值 thresh 需按点云尺度自行调整
pyRANSAC-3D
leomarigaApache-2.0活跃维护用 RANSAC 从点云中拟合平面、球、圆柱、长方体、圆和直线等 3D 基元,适合 LiDAR 与三维重建场景做形状检测和分割。
Python library for fitting 3D primitive shapes to point clouds with RANSAC. Detect planes, spheres, cylinders, cuboids, circles, and lines.
pip install pyransac3dREADME 未说明,仅要求安装 NumPy,未提及 GPU 或显存要求
用 RANSAC 从点云中拟合平面、球、圆柱等基本几何体的轻量 Python 库
用 RANSAC 从点云中拟合平面、球、圆柱、长方体、圆和直线等 3D 基元,适合 LiDAR 与三维重建场景做形状检测和分割。
核心能力
- 用 RANSAC 拟合平面并返回平面方程与内点
- 支持圆柱、圆锥、长方体、球、圆、直线、点等基元
- 输入为 NumPy 的 (N,3) 点云数组,接口简洁
- 可选配合 Open3D 做可视化,并提供拟合过程动画回调
容易踩的坑
- v0.7.0pyRANSAC-3D v0.7.0最新正式版2026-08-18 · 2026-08-18 03:48 UTC
pyRANSAC-3D v0.7.0
Highlights
- Cuboid is a real box (
#40):fit()now returnscenter,extents, andaxesinstead of three plane equations. [Breaking change] Callers that unpacked three plane equations will fail; use the new box parameters. The old plane equations stay on the object asequation. - Fit extras on the object (
#17): distances and related measurements stay on the fitter afterfit(). - Iteration callbacks (
#34): optionalcallbackon everyfit(), withFitState, for plotting or early stop. - Typed results:
fit()still unpacks as a tuple, and also has named fields (PlaneResult,SphereResult, …). - Synthetic clouds (
#7):ShapeGeneratorfor tests and examples. - Examples and tests: per-shape examples (
simple/visual/animation) plus a pytest suite on GitHub Actions. - Packaging: development and publish flow moved to uv.
- Plane
minPointsremoved. [Breaking change]Plane.fit(pts, thresh, minPoints, maxIteration)no longer acceptsminPoints. Drop that argument; too-small clouds now raiseValueError.
Fixes
- Circle center along Z (
#29). - Degenerate samples (parallel vectors / division by zero) (
#28). - Clear
ValueErrorwhen the cloud has too few points (#35). - Cylinder height measurement.
Docs
- Getting Started guide, regenerated API docs, and contributor notes for PyPI / GitHub Pages.
Unpacking
fit()still works (eq, inliers = Plane().fit(...)). Cuboid callers must switch to the new return values. Plane callers that passedminPointsneed to drop it.New Contributors
- @wct432 made their first contribution in https://github.com/leomariga/pyRANSAC-3D/pull/33
- @amaarquadri made their first contribution in https://github.com/leomariga/pyRANSAC-3D/pull/36
- Cuboid is a real box (
- v0.6.0pyRANSAC-3D v0.6.02022-10-16 · 2022-10-16 00:22 UTC
查看更新说明
The first official release for the pyRANSAC-3D library. It contains the default RANSAC implementation applied to the following 3D shapes:
- Plane
- Cylinder
- Cuboid
- Sphere
- Line
- Circle
- Point
Thank you for all your contributions to this project! We expect soon bring you many improvements related to faster and better parameter detection for each 3D shape. See you soon! =)
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
What is pyRANSAC-3D?
pyRANSAC-3D is an open source Python implementation of the Random Sample Consensus (RANSAC) method. It fits primitive shapes such as planes, cuboids, and cylinders to point clouds for applications including 3D SLAM, 3D reconstruction, object tracking, and more.
Features
Installation
Requirement: NumPy
Install from PyPI:
pip install pyransac3d
For a complete introduction see the Getting Started guide.
Quick start
Example 1 - Planar RANSAC
import pyransac3d as pyrsc
points = load_points(.) # Load your point cloud as a NumPy array with shape (N, 3)
plane1 = pyrsc.Plane()
best_eq, best_inliers = plane1.fit(points, 0.01)
The result is the plane equation Ax + By + Cz + D = 0:
[0.720, -0.253, 0.646, 1.100]
Example 2 - Spherical RANSAC
To fit a noisy sphere with r = 5 centered at the origin, use:
import pyransac3d as pyrsc
points = load_points(.) # Load your point cloud as a NumPy array with shape (N, 3)
sph = pyrsc.Sphere()
center, radius, inliers = sph.fit(points, thresh=0.4)
Results:
center: [0.010462385575072288, -0.2855090643954039, 0.02867848979091283]
radius: 5.085218633039647

More examples
Runnable examples of every shape are in the examples folder.
When should I use pyRANSAC-3D?
Use pyRANSAC-3D when you need to:
- Fit a plane to a 3D point cloud in Python, such as a floor, wall, roof, or tabletop.
- Detect cylinders in LiDAR or depth-sensor data, such as pipes, poles, trunks, or columns.
- Segment geometric shapes from noisy point clouds with RANSAC.
- Fit spheres, cuboids, circles, lines, or point clusters from NumPy-compatible
(N, 3)arrays. - Combine lightweight NumPy-based shape fitting with optional Open3D visualization.
Documentation and other links
- Read the documentation.
- Browse the source code in the GitHub repository.
- Install the PyPI package.
- Explore the animation examples to watch each RANSAC fitter update through its callback.
License
Citation
Was this repository useful for your work? Please cite it:
@software{Mariga_pyRANSAC-3D,
author = {Mariga, Leonardo},
doi = {10.5281/zenodo.7212567},
month = {8},
title = {{pyRANSAC-3D}},
url = {https://github.com/leomariga/pyRANSAC-3D},
version = {v0.7.0},
year = {2026}
}
Contributing is awesome!
See CONTRIBUTING
Contact
Developed with :heart: by the internet
Maintainer: Leonardo Mariga
Did you like it? Remember to click the :star2: button.