Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import all the points from a .pcd file into a 2d python array

How do you import all the 3d points from a file named edge_cloud.pcd and put them into an array? I want the array to be in the format

array=[[xvalue1,yvalue1,zvalue1],[xvalue2,yvalue2,zvalue2]] 
like image 395
Brian Kreidberg Avatar asked Apr 23 '26 09:04

Brian Kreidberg


1 Answers

Tested with Python 3.7.3, numpy 1.16.2, and open3d 0.7.0.0:

import numpy as np 
import open3d as o3d

pcd = o3d.io.read_point_cloud("C:\\Users\\Username\\Source\\pointcloud\\bunny.pcd")
out_arr = np.asarray(pcd.points)  
print("output array from input list : ", out_arr)  

Output:

output array from input list :  
[[ 0.0054216  0.11349    0.040749 ]
 [-0.0017447  0.11425    0.041273 ]
 [-0.010661   0.11338    0.040916 ]
 ...
 [-0.064992   0.17802   -0.054645 ]
 [-0.069935   0.17983   -0.051988 ]
 [-0.07793    0.17516   -0.0444   ]]

Input PCD file:

https://github.com/PointCloudLibrary/pcl/blob/master/test/bunny.pcd

like image 151
iokevins Avatar answered Apr 26 '26 03:04

iokevins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!