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.

v0.7.0发布于 2026-08-18 03:48 UTC674star80fork同步于 2026-11-07 07:32 UTC

怎么上手

由 README 提炼,执行前请确认
pip install pyransac3d
硬件要求按 README 说明

README 未说明,仅要求安装 NumPy,未提及 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 RANSAC 从点云中拟合平面、球、圆柱等基本几何体的轻量 Python 库

用 RANSAC 从点云中拟合平面、球、圆柱、长方体、圆和直线等 3D 基元,适合 LiDAR 与三维重建场景做形状检测和分割。

核心能力

  • 用 RANSAC 拟合平面并返回平面方程与内点
  • 支持圆柱、圆锥、长方体、球、圆、直线、点等基元
  • 输入为 NumPy 的 (N,3) 点云数组,接口简洁
  • 可选配合 Open3D 做可视化,并提供拟合过程动画回调

容易踩的坑

仅依赖 NumPy,但需自行把点云整理成 (N,3) 数组;可视化需另外安装 Open3D;拟合阈值 thresh 需按点云尺度自行调整

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v0.7.0
  1. 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 returns center, extents, and axes instead 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 as equation.
    • Fit extras on the object (#17): distances and related measurements stay on the fitter after fit().
    • Iteration callbacks (#34): optional callback on every fit(), with FitState, for plotting or early stop.
    • Typed results: fit() still unpacks as a tuple, and also has named fields (PlaneResult, SphereResult, …).
    • Synthetic clouds (#7): ShapeGenerator for 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 minPoints removed. [Breaking change] Plane.fit(pts, thresh, minPoints, maxIteration) no longer accepts minPoints. Drop that argument; too-small clouds now raise ValueError.

    Fixes

    • Circle center along Z (#29).
    • Degenerate samples (parallel vectors / division by zero) (#28).
    • Clear ValueError when 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 passed minPoints need to drop it.

    New Contributors

  2. 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:

    1. Plane
    2. Cylinder
    3. Cuboid
    4. Sphere
    5. Line
    6. Circle
    7. 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! =)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Tests DOI PyPI Latest Release License

    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
    

    3D Sphere

    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

    License

    Apache 2.0

    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.