<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          點(diǎn)云:Python版本的點(diǎn)云數(shù)據(jù)處理庫

          共 10908字,需瀏覽 22分鐘

           ·

          2022-03-04 13:35

          最近在搞點(diǎn)云DL,順便看了看python版本的點(diǎn)云數(shù)據(jù)處理庫,記錄一下。

          python我用得少,不喜勿噴,歡迎探討,為文明和諧的社會(huì)主義事業(yè)增磚添瓦。

          測試數(shù)據(jù)是這樣的。

          一、Open3D

          A Modern Library for 3D Data Processing,Intel出品,MIT協(xié)議。

          Open3D是一個(gè)支持3D數(shù)據(jù)處理軟件快速開發(fā)的開源庫。Open3D使用C++和Python公開了一組精心選擇的數(shù)據(jù)結(jié)構(gòu)和算法。后端經(jīng)過高度優(yōu)化,并設(shè)置為并行化。Open3D的依賴項(xiàng)較少,可在不同的平臺(tái)上編譯與布置。

          Open3D側(cè)重于三維數(shù)據(jù)的可視化與整體處理算法。想學(xué)習(xí)的同學(xué)可百度“Open3D學(xué)習(xí)計(jì)劃”。

          官網(wǎng):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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import open3d as o3d

          2. import numpy as np

          3. from matplotlib import pyplot as plt


          4. # read PC

          5. pcd = o3d.io.read_point_cloud("F:/test.pcd")


          6. # # write PC

          7. # o3d.io.write_point_cloud("F:/newFile.pcd",pcd)


          8. # DBSCAN

          9. with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Debug) as cm:

          10. labels = np.array(pcd.cluster_dbscan(eps=0.1, min_points=10, print_progress=True))

          11. max_label = labels.max()

          12. print(f"point cloud has {max_label + 1} clusters")

          13. colors = plt.get_cmap("tab20")(labels / (max_label if max_label > 0 else 1))

          14. colors[labels < 0] = 0

          15. pcd.colors = o3d.utility.Vector3dVector(colors[:, :3])


          16. # 可視化

          17. 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協(xié)議。

          PyVista具有可視化工具包(VTK)的高級(jí)API,空間數(shù)據(jù)集的網(wǎng)格數(shù)據(jù)結(jié)構(gòu)和過濾方法,使3D繪圖變得簡單,可用于大型/復(fù)雜數(shù)據(jù)幾何.

          PyVista(以前稱為vtki)是可視化工具包(VTK)的幫助程序模塊,它通過NumPy和直接數(shù)組訪問采用了與VTK接口不同的方法。該軟件包提供了Pythonic的,文檔齊全的界面,該界面公開了VTK強(qiáng)大的可視化后端,以促進(jìn)對空間參考數(shù)據(jù)集的快速原型制作,分析和可視化集成。該模塊可用于演示文稿和研究論文的科學(xué)繪圖,以及其他與網(wǎng)格相關(guān)的Python模塊的支持模塊。

          PyVista側(cè)重于可視化。

          官網(wǎng):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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import pyvista as pv


          2. mesh = pv.read('F:/test.vtk')

          3. mesh.plot(screenshot='F:/test.vtk.png')


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

          三、PCL

          PCL(Point Cloud Library)是主要用于點(diǎn)云(二三維圖像也可)的獨(dú)立、強(qiáng)大的開源項(xiàng)目,BSD協(xié)議,可免費(fèi)用于商業(yè)和研究用途。

          PCL是點(diǎn)云數(shù)據(jù)處理的王者庫,近乎全能,可視化、讀寫、算法(!!!)。

          官網(wǎng):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。同時(shí)存在某些限制,比如正在開發(fā)中,API和功能測試也許會(huì)不穩(wěn)定,只支持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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import pclpy

          2. from pclpy import pcl


          3. # 讀

          4. pc=pclpy.pcl.PointCloud.PointXYZRGBA()

          5. pcl.io.loadPCDFile('F:/test.pcd',pc)


          6. # 顯示

          7. viewer=pcl.visualization.PCLVisualizer('Point Cloud viewer')

          8. viewer.addPointCloud(pc)

          9. while(not viewer.wasStopped()):

          10. viewer.spinOnce(100)

          五、pyntcloud

          pyntcloud是一個(gè)Python 3.x庫,利用Python科學(xué)堆棧的強(qiáng)大功能處理3D點(diǎn)云。

          pyntcloud側(cè)重于點(diǎn)云數(shù)據(jù)處理,例如讀寫(支持las)、屬性、濾波、數(shù)據(jù)結(jié)構(gòu)組織、構(gòu)建體素、抽稀、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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. from pyntcloud import PyntCloud

          2. import open3d as o3d


          3. # io

          4. cloud = PyntCloud.from_file("F:/test.ply")

          5. # structures

          6. kdtree_id = cloud.add_structure("kdtree")

          7. # neighbors

          8. k_neighbors = cloud.get_neighbors(k=5, kdtree=kdtree_id)

          9. # scalar_fields

          10. ev = cloud.add_scalar_field("eigen_values", k_neighbors=k_neighbors)

          11. # filters

          12. f = cloud.get_filter("BBOX", min_x=0.1, max_x=0.8)


          13. # FROM Open3D

          14. original_triangle_mesh = o3d.io.read_triangle_mesh("F:/test.ply")

          15. cloud = PyntCloud.from_instance("open3d", original_triangle_mesh)


          16. # TO Open3D

          17. cloud = PyntCloud.from_file("F:/test.ply")

          18. converted_triangle_mesh = cloud.to_instance("open3d", mesh=True) # mesh=True by default

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

          六、libLAS

          libLAS是一個(gè)C/C++/Python庫(接觸的第一個(gè)點(diǎn)云處理庫),用于讀寫LAS格式的點(diǎn)云。libLAS支持ASPRS LAS格式規(guī)范版本:1.0、1.1、1.2和1.3(基本支持)。雖然libLAS已經(jīng)被 PDAL / Laspy 取代,但不可否認(rèn),它是一個(gè)很nice的庫。

          libLAS庫側(cè)重于點(diǎn)云的讀寫、修改編輯處理。

          介紹: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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import liblas

          2. from liblas import file

          3. from liblas import header


          4. # 讀

          5. f=file.File('F:/test.las',mode='r')


          6. # 頭文件

          7. lasHeader = f.header

          8. print('主版本號(hào):' + str(lasHeader.major_version))

          9. print('副版本號(hào):' + str(lasHeader.minor_version))

          10. print('最小值:%f,%f,%f' % (lasHeader.min[0],lasHeader.min[1],lasHeader.min[2]))

          11. print('最大值:%f,%f,%f' % (lasHeader.max[0],lasHeader.max[1],lasHeader.max[2]))

          12. print('比例:%f,%f,%f' % (lasHeader.scale[0],lasHeader.scale[1],lasHeader.scale[2]))

          13. print('偏移量:%f,%f,%f' % (lasHeader.offset[0],lasHeader.offset[1],lasHeader.offset[2]))

          14. print('點(diǎn)云數(shù)量:%d' % (lasHeader.point_records_count))


          15. # 遍歷點(diǎn)

          16. for point in f:

          17. # point = f[0]

          18. print('x=%f, y=%f, z=%f, intensity=%d, PointsourceID=%d, GPStime=%f,

          19. Red=%d, Green=%d, Blue=%d, Classification=%d, UserData=%d'

          20. % (point.x, point.y, point.z,

          21. point.intensity, point.point_source_id, point.raw_time,

          22. point.color.red, point.color.green, point.color.blue,

          23. point.classification, point.user_data))


          24. # 寫

          25. las_header = header.Header()

          26. las_header.dataformat_id = 1

          27. las_header.minor_version = 2

          28. fw = file.File('F:/new.las', mode='w', header=las_header)

          29. pt = liblas.point.Point()

          30. for i in range(10):

          31. pt.x = 118.0+i

          32. pt.y = 532.0+i

          33. pt.z = 112.0+i

          34. fw.write(pt)

          35. fw.close()


          36. print('ok666')

          七、PDAL

          libLAS的升級(jí)版。PDAL(Point Data Abstraction Library)是一個(gè)C/C ++開源庫,用于轉(zhuǎn)換和處理點(diǎn)云數(shù)據(jù)。盡管庫中許多重點(diǎn)工具源于LiDAR,但它不限于LiDAR數(shù)據(jù)。

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

          API:Python Class Documentation — liblas.org

          GitHub:https://github.com/PDAL

          安裝:pip install PDAL(沒成功,郁悶)???

          八、Laspy

          兼容 libLAS 的點(diǎn)云處理python庫,與 libLAS算是一家吧。Laspy是一個(gè)用于讀取、修改和創(chuàng)建LAS LiDAR文件的python庫。對LAZ的支持僅限于1.0-1.3版本。Laspy與Python 2.6+和3.5+兼容。Laspy包含一組命令行工具,可用于執(zhí)行基本文件操作,例如格式轉(zhuǎn)換和驗(yàn)證以及比較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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import math

          2. import numpy as np

          3. import laspy



          4. # 讀

          5. las = laspy.read('E:/data/test.las')


          6. # 頭

          7. lasHeader = las.header

          8. print('主版本號(hào):' + str(lasHeader.major_version))

          9. print('副版本號(hào):' + str(lasHeader.minor_version))

          10. print('最小值:%f,%f,%f' % (lasHeader.min[0], lasHeader.min[1], lasHeader.min[2]))

          11. print('最大值:%f,%f,%f' % (lasHeader.max[0], lasHeader.max[1], lasHeader.max[2]))

          12. print('比例:%f,%f,%f' % (lasHeader.scale[0], lasHeader.scale[1], lasHeader.scale[2]))

          13. print('偏移量:%f,%f,%f' % (lasHeader.offset[0], lasHeader.offset[1], lasHeader.offset[2]))

          14. print('點(diǎn)云數(shù)量:%d' % (lasHeader.point_records_count))


          15. # 遍歷點(diǎn)

          16. points = las.points


          17. def scaled_x_dimension(las_file):

          18. x_dimension = las_file.X

          19. scale = las_file.header.scale[0]

          20. offset = las_file.header.offset[0]

          21. return (x_dimension * scale + offset)


          22. ##################### 遍歷點(diǎn),給GPStime賦新值

          23. gpstime= []

          24. for i in range(lasHeader.point_records_count):

          25. print('x=%f, y=%f, z=%f, intensity=%d, GPStime=%f, PointSourceID=%f, '

          26. 'Classification=%d, UserData=%d, Red=%d, Green=%d, Blue=%d'

          27. % (scaled_x_dimension(las)[i], las.y[i],las.z[i],

          28. las.intensity[i], las.gps_time[i],las.point_source_id[i],

          29. las.classification[i],las.user_data[i],

          30. las.red[i],las.green[i], las.blue[i]))

          31. gpstime.append(i)


          32. ############################writer:原有XYZ不變

          33. new_las = laspy.LasData(las.header)

          34. new_las.x = las.x

          35. new_las.y = las.y

          36. new_las.z = las.z

          37. new_las.intensity = las.intensity

          38. new_las.gps_time = gpstime

          39. new_las.red = las.red

          40. new_las.green = las.green

          41. new_las.blue = las.blue

          42. new_las.write("E:/new_las.las")



          43. ####################################按類別篩選

          44. new_file_c0 = laspy.create(point_format=las.header.point_format,

          45. file_version=las.header.version)

          46. new_file_c0.points = las.points[las.classification == 0]

          47. new_file_c0.write('E:/new_file_c0.las')




          48. #region #################旋轉(zhuǎn)點(diǎn)云,XY變化,頭 變化,添加新的屬性

          49. #旋轉(zhuǎn)參數(shù)

          50. basePx = (lasHeader.min[0]+lasHeader.max[0]) / 2

          51. basePy = (lasHeader.min[1]+lasHeader.max[1]) / 2

          52. cosa = 0.5

          53. sina = math.sqrt(1-cosa*cosa)


          54. #遍歷點(diǎn)

          55. xo = []

          56. yo = []

          57. xj = []

          58. for i in range(lasHeader.point_records_count):

          59. x = las.x[i] - basePx

          60. y = las.y[i] - basePy


          61. xnew = x * cosa - y * sina + basePx

          62. ynew = x * sina + y * cosa + basePy

          63. xo.append(xnew)

          64. yo.append(ynew)

          65. xj.append(i)


          66. #保存新的點(diǎn)云

          67. header = laspy.LasHeader(point_format=3, version="1.2")

          68. header.offsets = [np.min(xo), np.min(yo), las.header.offsets[2]]

          69. header.scales = np.array([0.0001, 0.0001, 0.0001])

          70. header.add_extra_dim(laspy.ExtraBytesParams(name="xj", type=np.int32))


          71. new_las = laspy.LasData(header)

          72. new_las.x = xo

          73. new_las.y = yo

          74. new_las.z = las.z

          75. new_las.intensity = las.intensity

          76. new_las.gps_time = las.gps_time

          77. new_las.point_source_id = las.point_source_id

          78. new_las.classification = las.classification

          79. new_las.red = las.red

          80. new_las.green = las.green

          81. new_las.blue = las.blue

          82. new_las.xj = xj


          83. new_las.write('E:/new_file_rotation.las')

          84. #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

          挺實(shí)用。

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

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

          十一、pptk

          pptk(Point Processing Toolkit)是用于可視化和處理二三維點(diǎn)云的python包。目前,其具有以下功能:

          (1)點(diǎn)云查看,可接受任何3列numpy數(shù)組作為輸入;

          (2)基于Octree的LOD點(diǎn)云渲染可視化;

          (3)支持點(diǎn)選,用于檢查和注釋點(diǎn)數(shù)據(jù);

          (4)并行化的點(diǎn)KD-tree;

          (5)基于點(diǎn)云鄰域PCA的法線估計(jì)。

          介紹: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

          分享給有需要的人,代碼質(zhì)量勿噴。

          1. import pptk


          2. # Create 100 random points

          3. xyz = pptk.rand(200, 3)


          4. # Visualize points shaded by height

          5. v = pptk.viewer(xyz, xyz[:, 2])

          6. v.set(point_size=0.005)

          十二、PyLidar

          PyLidar用于從LiDAR設(shè)備中獲取數(shù)據(jù)。其分為PyLidar2和PyLidar3,分別對應(yīng)python2和python3版本。

          介紹:PyLidar — Pylidar 0.4.4 documentation

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

          安裝:pip install PyLidar3

          /* ************************************** 以下的已經(jīng)不維護(hù)或者很久沒更新了 ********************************************** */

          十三、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


          瀏覽 467
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  无码成人在线观看 | 在线精品视频你懂的 | 大香蕉电影网 | 亚洲精品乱码久久久久久9色 | 亚洲性射|