最近在搞点云DL,顺便看了看python版本的点云数据处理库,记录一下。

python我用得少,不喜勿喷,欢迎探讨,为文明和谐的社会主义事业增砖添瓦。

测试数据是这样的。

一、Open3D

A Modern Library for 3D Data Processing,Intel出品,MIT协议。

Open3D是一个支持3D数据处理软件快速开发的开源库。Open3D使用C++和Python公开了一组精心选择的数据结构和算法。后端经过高度优化,并设置为并行化。Open3D的依赖项较少,可在不同的平台上编译与布置。

Open3D侧重于三维数据的可视化与整体处理算法。想学习的同学可百度“Open3D学习计划”。

官网:Open3D – A Modern Library for 3D Data Processing

GitHub:https://github.com/intel-isl/Open3D

安装:pip install open3d 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple open3d

分享给有需要的人,代码质量勿喷。

import open3d as o3d
import numpy as np
from matplotlib import pyplot as plt# read PC
pcd = o3d.io.read_point_cloud("F:/test.pcd")# # write PC
# o3d.io.write_point_cloud("F:/newFile.pcd",pcd)# DBSCAN
with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Debug) as cm:labels = np.array(pcd.cluster_dbscan(eps=0.1, min_points=10, print_progress=True))
max_label = labels.max()
print(f"point cloud has {max_label + 1} clusters")
colors = plt.get_cmap("tab20")(labels / (max_label if max_label > 0 else 1))
colors[labels < 0] = 0
pcd.colors = o3d.utility.Vector3dVector(colors[:, :3])# 可视化
o3d.visualization.draw_geometries([pcd],width=910,height=540)

二、PyVista

3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK),MIT协议。

PyVista具有可视化工具包(VTK)的高级API,空间数据集的网格数据结构和过滤方法,使3D绘图变得简单,可用于大型/复杂数据几何.

PyVista(以前称为vtki)是可视化工具包(VTK)的帮助程序模块,它通过NumPy和直接数组访问采用了与VTK接口不同的方法。该软件包提供了Pythonic的,文档齐全的界面,该界面公开了VTK强大的可视化后端,以促进对空间参考数据集的快速原型制作,分析和可视化集成。该模块可用于演示文稿和研究论文的科学绘图,以及其他与网格相关的Python模块的支持模块。

PyVista侧重于可视化。

官网:The PyVista Project

介绍:PyVista — PyVista 0.32.0 documentation

GitHub:https://github.com/pyvista/pyvista

安装:pip install pyvista 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyvista

分享给有需要的人,代码质量勿喷。

import pyvista as pvmesh = pv.read('F:/test.vtk')
mesh.plot(screenshot='F:/test.vtk.png')

/* ************************************************** 挺好的 *************************************************************** */

三、PCL

PCL(Point Cloud Library)是主要用于点云(二三维图像也可)的独立、强大的开源项目,BSD协议,可免费用于商业和研究用途。

PCL是点云数据处理的王者库,近乎全能,可视化、读写、算法(!!!)。

官网:Point Cloud Library | The Point Cloud Library (PCL) is a standalone, large scale, open project for 2D/3D image and point cloud processing.

GitHub:https://github.com/PointCloudLibrary

但是,python-pcl安装较为麻烦!!!建议谷歌或百度。

四、pclpy

pclpy是python-pcl的姊妹库吧,安装很方便,算法接口啥的也挺全的,而且,支持las。同时存在某些限制,比如正在开发中,API和功能测试也许会不稳定,只支持Windows和python 3.6 x64。

介绍:pclpy · PyPI

GitHub:https://github.com/davidcaron/pclpy

安装:pip install pclpy 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pclpy

分享给有需要的人,代码质量勿喷。

import pclpy
from pclpy import pcl# 读
pc=pclpy.pcl.PointCloud.PointXYZRGBA()
pcl.io.loadPCDFile('F:/test.pcd',pc)# 显示
viewer=pcl.visualization.PCLVisualizer('Point Cloud viewer')
viewer.addPointCloud(pc)
while(not viewer.wasStopped()):viewer.spinOnce(100)

五、pyntcloud

pyntcloud是一个Python 3.x库,利用Python科学堆栈的强大功能处理3D点云。

pyntcloud侧重于点云数据处理,例如读写(支持las)、属性、滤波、数据结构组织、构建体素、抽稀、RANSAC等。与Open3D、PyVista等库衔接较好。

介绍:pyntcloud | Read the Docs

GitHub:https://github.com/daavoo/pyntcloud

安装:pip install pyntcloud 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyntcloud

分享给有需要的人,代码质量勿喷。

from pyntcloud import PyntCloud
import open3d as o3d# io
cloud = PyntCloud.from_file("F:/test.ply")
# structures
kdtree_id = cloud.add_structure("kdtree")
# neighbors
k_neighbors = cloud.get_neighbors(k=5, kdtree=kdtree_id)
# scalar_fields
ev = cloud.add_scalar_field("eigen_values", k_neighbors=k_neighbors)
# filters
f = cloud.get_filter("BBOX", min_x=0.1, max_x=0.8)# FROM Open3D
original_triangle_mesh = o3d.io.read_triangle_mesh("F:/test.ply")
cloud = PyntCloud.from_instance("open3d", original_triangle_mesh)# TO Open3D
cloud = PyntCloud.from_file("F:/test.ply")
converted_triangle_mesh = cloud.to_instance("open3d", mesh=True)  # mesh=True by default

/* *************************************************  liblas系列  *************************************************** */

六、libLAS

libLAS是一个C/C++/Python库(接触的第一个点云处理库),用于读写LAS格式的点云。libLAS支持ASPRS LAS格式规范版本:1.0、1.1、1.2和1.3(基本支持)。虽然libLAS已经被 PDAL / Laspy 取代,但不可否认,它是一个很nice的库。

libLAS库侧重于点云的读写、修改编辑处理。

介绍:libLAS - LAS 1.0/1.1/1.2 ASPRS LiDAR data translation toolset — liblas.org

API:Python Class Documentation — liblas.org

GitHub:https://github.com/libLAS

安装:pip install liblas  或者  pip install -i https://pypi.tuna.tsinghua.edu.cn/simple liblas

分享给有需要的人,代码质量勿喷。

import liblas
from liblas import file
from liblas import header# 读
f=file.File('F:/test.las',mode='r')# 头文件
lasHeader = f.header
print('主版本号:' + str(lasHeader.major_version))
print('副版本号:' + str(lasHeader.minor_version))
print('最小值:%f,%f,%f' % (lasHeader.min[0],lasHeader.min[1],lasHeader.min[2]))
print('最大值:%f,%f,%f' % (lasHeader.max[0],lasHeader.max[1],lasHeader.max[2]))
print('比例:%f,%f,%f' % (lasHeader.scale[0],lasHeader.scale[1],lasHeader.scale[2]))
print('偏移量:%f,%f,%f' % (lasHeader.offset[0],lasHeader.offset[1],lasHeader.offset[2]))
print('点云数量:%d' % (lasHeader.point_records_count))# 遍历点
for point in f:# point = f[0]print('x=%f, y=%f, z=%f, intensity=%d, PointsourceID=%d, GPStime=%f,Red=%d, Green=%d, Blue=%d, Classification=%d, UserData=%d'% (point.x, point.y, point.z,point.intensity, point.point_source_id, point.raw_time,point.color.red, point.color.green, point.color.blue,point.classification, point.user_data))# 写
las_header = header.Header()
las_header.dataformat_id = 1
las_header.minor_version = 2
fw = file.File('F:/new.las', mode='w', header=las_header)
pt = liblas.point.Point()
for i in range(10):pt.x = 118.0+ipt.y = 532.0+ipt.z = 112.0+ifw.write(pt)
fw.close()print('ok666')

七、PDAL

libLAS的升级版。PDAL(Point Data Abstraction Library)是一个C/C ++开源库,用于转换和处理点云数据。尽管库中许多重点工具源于LiDAR,但它不限于LiDAR数据。

介绍:PDAL - Point Data Abstraction Library — pdal.io

API:Python Class Documentation — liblas.org

GitHub:https://github.com/PDAL

安装:pip install PDAL(没成功,郁闷)

八、Laspy

兼容 libLAS 的点云处理python库,与 libLAS算是一家吧。Laspy是一个用于读取、修改和创建LAS LiDAR文件的python库。对LAZ的支持仅限于1.0-1.3版本。Laspy与Python 2.6+和3.5+兼容。Laspy包含一组命令行工具,可用于执行基本文件操作,例如格式转换和验证以及比较LAS文件。

API:Laspy: Documentation — laspy 1.2.5 documentation

API:laspy 2.0

GitHub:https://github.com/grantbrown/laspy

安装:pip install laspy 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple laspy

分享给有需要的人,代码质量勿喷。

import math
import numpy as np
import laspy# 读
las = laspy.read('E:/data/test.las')# 头
lasHeader = las.header
print('主版本号:' + str(lasHeader.major_version))
print('副版本号:' + str(lasHeader.minor_version))
print('最小值:%f,%f,%f' % (lasHeader.min[0], lasHeader.min[1], lasHeader.min[2]))
print('最大值:%f,%f,%f' % (lasHeader.max[0], lasHeader.max[1], lasHeader.max[2]))
print('比例:%f,%f,%f' % (lasHeader.scale[0], lasHeader.scale[1], lasHeader.scale[2]))
print('偏移量:%f,%f,%f' % (lasHeader.offset[0], lasHeader.offset[1], lasHeader.offset[2]))
print('点云数量:%d' % (lasHeader.point_records_count))# 遍历点
points = las.pointsdef scaled_x_dimension(las_file):x_dimension = las_file.Xscale = las_file.header.scale[0]offset = las_file.header.offset[0]return (x_dimension * scale + offset)##################### 遍历点,给GPStime赋新值
gpstime= []
for i in range(lasHeader.point_records_count):print('x=%f, y=%f, z=%f, intensity=%d, GPStime=%f, PointSourceID=%f, ''Classification=%d, UserData=%d, Red=%d, Green=%d, Blue=%d'% (scaled_x_dimension(las)[i], las.y[i],las.z[i],las.intensity[i], las.gps_time[i],las.point_source_id[i],las.classification[i],las.user_data[i],las.red[i],las.green[i], las.blue[i]))gpstime.append(i)############################writer:原有XYZ不变
new_las = laspy.LasData(las.header)
new_las.x = las.x
new_las.y = las.y
new_las.z = las.z
new_las.intensity = las.intensity
new_las.gps_time = gpstime
new_las.red = las.red
new_las.green = las.green
new_las.blue = las.blue
new_las.write("E:/new_las.las")####################################按类别筛选
new_file_c0 = laspy.create(point_format=las.header.point_format,file_version=las.header.version)
new_file_c0.points = las.points[las.classification == 0]
new_file_c0.write('E:/new_file_c0.las')#region #################旋转点云,XY变化,头 变化,添加新的属性
#旋转参数
basePx = (lasHeader.min[0]+lasHeader.max[0]) / 2
basePy = (lasHeader.min[1]+lasHeader.max[1]) / 2
cosa = 0.5
sina = math.sqrt(1-cosa*cosa)#遍历点
xo = []
yo = []
xj = []
for i in range(lasHeader.point_records_count):x = las.x[i] - basePxy = las.y[i] - basePyxnew = x * cosa - y * sina + basePxynew = x * sina + y * cosa + basePyxo.append(xnew)yo.append(ynew)xj.append(i)#保存新的点云
header = laspy.LasHeader(point_format=3, version="1.2")
header.offsets = [np.min(xo), np.min(yo), las.header.offsets[2]]
header.scales = np.array([0.0001, 0.0001, 0.0001])
header.add_extra_dim(laspy.ExtraBytesParams(name="xj", type=np.int32))new_las = laspy.LasData(header)
new_las.x = xo
new_las.y = yo
new_las.z = las.z
new_las.intensity = las.intensity
new_las.gps_time = las.gps_time
new_las.point_source_id = las.point_source_id
new_las.classification = las.classification
new_las.red = las.red
new_las.green = las.green
new_las.blue = las.blue
new_las.xj = xjnew_las.write('E:/new_file_rotation.las')
#endregion

/* ************************************************************** 其它 *************************************************** */

九、plyfile

plyfile用于读写ply文件。

GitHub:https://github.com/dranjan/python-plyfile

安装:pip install plyfile 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple plyfile

十、point_cloud_utils

Point Cloud Utils (pcu) - A Python library for common tasks on 3D point clouds

挺实用。

GitHub:https://github.com/fwilliams/point-cloud-utils

安装:pip install git+git://github.com/fwilliams/point-cloud-utils

十一、pptk

pptk(Point Processing Toolkit)是用于可视化和处理二三维点云的python包。目前,其具有以下功能:

(1)点云查看,可接受任何3列numpy数组作为输入;

(2)基于Octree的LOD点云渲染可视化;

(3)支持点选,用于检查和注释点数据;

(4)并行化的点KD-tree;

(5)基于点云邻域PCA的法线估计。

介绍:Contents — pptk 0.1.1 documentation

GitHub:https://github.com/heremaps/pptk

安装:pip install pptk 或者 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pptk

分享给有需要的人,代码质量勿喷。

import pptk# Create 100 random points
xyz = pptk.rand(200, 3)# Visualize points shaded by height
v = pptk.viewer(xyz, xyz[:, 2])
v.set(point_size=0.005)

十二、PyLidar

PyLidar用于从LiDAR设备中获取数据。其分为PyLidar2和PyLidar3,分别对应python2和python3版本。

介绍:PyLidar — Pylidar 0.4.4 documentation

GitHub:https://github.com/lakshmanmallidi/PyLidar3

安装:pip install PyLidar3

/* ************************************** 以下的已经不维护或者很久没更新了 ********************************************** */

十三、pylas

This code is no longer maintained.

Originally designed as a proof-of-concept for reading Light Detection and Ranging (LIDAR) data in binary LAS format and converting to GIS point data formats (xyz or shapefile). Today, there are much better tools for using LIDAR in python code - this repo is for archival purposes only.

GitHub:https://github.com/perrygeo/pylas

十四、las

The las module implements a reader for LAS (Log ASCII Standard) well log files (LAS 2.0). For more information about this format, see the Canadian Well Logging Society web page (http://www.cwls.org/las/).

GitHub:https://github.com/WarrenWeckesser/las

点云:python版本的点云数据处理库相关推荐

  1. python视频免费百度云-Python开发视频百度云分享

    原标题:Python开发视频百度云分享 Python有很好的3D渲染库和游戏开发框架,有很多使用Python开发的游戏,如迪斯尼卡通城.黑暗之刃.常用PyGame.Pykyra等和一个PyWeek的比 ...

  2. python2.7安装包百度云_python2.7下载地址,最好是云(python安装教程 百度云)

    python2.7下载地址,最好是云 python2.7下载地址 http://pan.baidu.com/s/1i5IKX0L Python从入门通,可以先自学 python基础视程:http:// ...

  3. 阿里云ubuntu版本搭建本地私有厂库

    首先安装好docker,这是基础,假设你的云主机的公网地址是172.163.10.1 1.在本地下载registry镜像: docker pull registry 2.使用registry镜像创建一 ...

  4. 腾讯云 python sdk,腾讯云cos对象存储python SDK使用

    pip install -U cos-python-sdk-v5 初始化代码# -*- coding=utf-8 # appid 已在配置中移除,请在参数 Bucket 中带上 appid.Bucke ...

  5. 金蝶云 python脚本调试

    金蝶云 python脚本调试 金蝶云 python脚本调试,通过断点调试可以轻松解决问题. 优点: 1.调试python与c#相比无需重启IIS. 2.测试脚本无需关闭界面重新打开,修改保存即为最新脚 ...

  6. python import找不到so库的可能原因

    gen 在import一个so库里的类或函数时,有时发现so文件分明就在那路径下,可是总是报错ModuleNotFoundError: No module named  ***,这种错误的可能原因有: ...

  7. 新浪云python示例_在新浪云上部署Django应用程序

    前言 近日,笔者利用空闲时间写了一个简单的在线预约系统,使用的工具包括Python 3.5.1 和 Django 1.9.5 .早就有听说Django响亮的口号,"The web frame ...

  8. python代码示例百度云-python利用百度云接口实现车牌识别的示例

    一个小需求---实现车牌识别. 目前有两个想法 1. 调云在线的接口或者使用SDK做开发(配置环境和编译第三方库很麻烦,当然使用python可以避免这些问题) 2. 自己实现车牌识别算法(复杂) 一开 ...

  9. 使用阿里云Python SDK管理ECS安全组

    准备工作 本机操作系统:CentOS7 python版本:python2.7.5 还需要准备如下信息: 一个云账号.Access Key ID.Access Key Secret.安全组ID.Regi ...

  10. [CentOS Python系列] 六.阿里云搭建Django网站详解

    本篇文章主要介绍讲述部署阿里云服务器Django网站环境,并通过IP地址访问网页的过程.写代码过程中往往第一步需要解决的就是配置开发环境,对于新手来说,这是非常头疼的事情,而当配置好之后或者对于老手来 ...

最新文章

  1. Linux 下的动态库、静态库与环境变量
  2. 安全36计 你需要了解的那些安全术语
  3. 【CV】图像分析用 OpenCV 与 Skimage,哪一个更好?
  4. PHP安装加载yaf扩展
  5. matlab 主成分 分类,matlab主成分分析
  6. 专业课程设计之客户与服务器程序的同步与通信机制的设计(一)项目介绍
  7. 【Linux】shell脚本执行错误 $‘\r‘:command not found
  8. 西双版纳真的适合养老吗?
  9. 阿里巴巴 CTO 程立:开源是基础软件的源头!
  10. mevan 的常用命令和参数解释
  11. java中controller层是干嘛的?
  12. 华为高姐寄来的新年礼物
  13. 什么是pptp,什么是vps?两者有何区别?
  14. 结构体与联合体概念引入
  15. Excel-移动平均分析及预测分析
  16. 科技爱好者周刊(第 153 期):机器翻译是对译者的侮辱吗?
  17. 英语2017年6月听力
  18. Java学习之旅(二):生病的狗2(java例化)
  19. python爬取微博评论(通过xpath解析的方式)
  20. 苏州PHp工资哪家高,苏州各区平均工资排行榜,第一名居然是..……

热门文章

  1. Android TV开发总结(五)TV上屏幕适配总结
  2. 数据结构(C语言版)严蔚敏课后答案
  3. 一个基于SpringBoot的在线教育系统「源码开源」
  4. 俄罗斯方块代码(自写)
  5. JAVA与SQL对应数据类型转换表
  6. C8051单片机在交流变频调速系统中的应用(收集)
  7. vba 正与服务器联系以获取信息,vba读取云服务器的数据库连接
  8. VB6.0软件安装包(永久),适用于Windows各系统附安装教程
  9. PUBG雷蛇鼠标宏,简单易学,有手就行。
  10. 学python需要c-为什么我建议每个开发人员都需要学 Python ?