![](/img/trans.png)
[英]Build a mesh for a two-argument function (point data cloud) and save it as .ply file using Python
[英]Coverting point cloud data (.ply) into a range image
我有一個帶有 XYZ 數據的點雲,我已經使用 pyntcloud 讀取了 .ply 文件並將其轉換為 numpy 數組 (553181,3)
我想將點雲例如轉換為一個 800x600x3 矩陣,該矩陣也可以被視為 RGB 圖像。 為此,我將 XY 坐標縮放到 [0,800] 和 [0,600] 范圍。
到目前為止->
我是 python 的新手,非常感謝您的幫助和指導
我不明白你怎么可能在二維圖像中處理 3d 點雲。 如果您有 RGB 數據,您可以使用open3d可視化點雲並將其存儲在 .xyzrgb 文件中的任何方式,這似乎您沒有,因為您將文件轉換為 NumPy 數組,其中 3 列必須是 x、y 和z 值。 因此,您可能需要 RGB 值或為點雲提供隨機值。 一個很好的方法是使用pptk ,它允許您在點雲上生成 RGB colors 並在內置查看器上渲染圖像(屏幕截圖)(我認為這是您需要的)。
一個簡單的工作流程可能是這樣的:
import pptk
xyz = pptk.rand(100, 3) #generates a 3dimensions array or it could be a
#numpy array - your (553181,3) array
v = pptk.viewer(xyz)
rgb = pptk.rand(100, 3) #same here, must be same size as what you used
#or you can create a single random color of the shape you need
import random
r = np.full(shape=100, fill_value=random.randint(1,255))
g = np.full(shape=100, fill_value=random.randint(1,255))
b = np.full(shape=100, fill_value=random.randint(1,255))
rgb = np.dstack((r,g,b))
colors = rgb/256 #you are going to need to convert the values in
#0-1 interval
v.attributes(colors)
v.capture('screenshot.png')
也許您想閱讀這個大規模的 3d-point-clouds-visualization-in-python 。 它或多或少地描述了我在我制作的示例中的內容,這只是其中的“簡短形式”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.