本文整理汇总了Python中pcl.PointCloud方法的典型用法代码示例。如果您正苦于以下问题:Python pcl.PointCloud方法的具体用法?Python pcl.PointCloud怎么用?Python pcl.PointCloud使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pcl
的用法示例。
在下文中一共展示了pcl.PointCloud方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_xyzrgb
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def create_xyzrgb(data):
'''
Create PointXYZRGB point cloud from ordinary nx6 array, or equivalent list representation
Note that RGB value should be represented in integer of 0~255
'''
data = np.array(data, copy=False)
if data.shape[-1] != 6:
return ValueError("Each point should contain 3 values")
rgb_dt = np.dtype(dict(names=['b','g','r'], formats=['u1','u1','u1'], itemsize=4))
rgb_arr = np.empty(len(data), dtype=rgb_dt)
rgb_arr['r'], rgb_arr['g'], rgb_arr['b'] = data[:,3], data[:,4], data[:,5]
cloud_dt = np.dtype(dict(names=['x','y','z','rgb'], formats=['f4','f4','f4','u4'], offsets=[0,4,8,16], itemsize=20))
cloud_arr = np.empty(len(data), dtype=cloud_dt)
cloud_arr['x'], cloud_arr['y'], cloud_arr['z'], cloud_arr['rgb'] = data[:,0], data[:,1], data[:,2], rgb_arr.view('u4')
return PointCloud(cloud_arr, 'XYZRGB')
示例2: test_load_pointcloud
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_load_pointcloud(self):
cloud1 = pcl.PointCloud(np.random.rand(100, 4).astype('f4'))
cloud2 = pcl.PointCloud(np.random.rand(100, 4).astype('f4'))
viewer = pcl.Visualizer()
viewer.addPointCloud(cloud1)
viewer.addCoordinateSystem()
viewer.removeCoordinateSystem()
v1 = viewer.createViewPort(0, 0, 0.5, 1)
v2 = viewer.createViewPort(0.5, 0, 1, 1)
viewer.addPointCloud(cloud1, viewport=v1, id="cloud1")
viewer.addPointCloud(cloud2, viewport=v2, id="cloud2")
viewer.spinOnce(time=1000)
viewer.close()
示例3: test_add_callback
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_add_callback(self):
def key_callback(event):
print(event.KeyCode, event.KeySym)
def mouse_callback(event):
print(event.X, event.Y, event.Type, event.Button)
def picking_callback(event):
print(event.Point, event.PointIndex)
def area_callback(event):
print(event.PointsIndices)
cloud = pcl.PointCloud(np.random.rand(100, 4).astype('f4'))
viewer = pcl.Visualizer()
viewer.addPointCloud(cloud)
viewer.registerKeyboardCallback(key_callback)
viewer.registerMouseCallback(mouse_callback)
viewer.registerPointPickingCallback(picking_callback)
viewer.registerAreaPickingCallback(area_callback)
viewer.spinOnce(time=2000)
viewer.close()
示例4: test_add_shape
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_add_shape(self):
cloud = pcl.PointCloud(np.random.rand(100, 4).astype('f4'))
viewer = pcl.Visualizer()
viewer.addPointCloud(cloud)
viewer.addLine([-1,-1,-1], [1,1,1])
viewer.addArrow([1,-1,-1], [-1,1,1], line_color=[0.7,0,0], text_color=[0,3,0,0])
viewer.addSphere([0,0,0], 1)
viewer.addText("Text", -1, 1, fontsize=100)
viewer.addText3D("Text3D", [-1,1,-1], text_scale=2)
viewer.spinOnce(time=500)
viewer.updateSphere([0,0,0], 2)
viewer.spinOnce(time=500)
viewer.close()
示例5: XYZRGB_to_XYZ
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def XYZRGB_to_XYZ(XYZRGB_cloud):
""" Converts a PCL XYZRGB point cloud to an XYZ point cloud (removes color info)
Args:
XYZRGB_cloud (PointCloud_PointXYZRGB): A PCL XYZRGB point cloud
Returns:
PointCloud_PointXYZ: A PCL XYZ point cloud
"""
XYZ_cloud = pcl.PointCloud()
points_list = []
for data in XYZRGB_cloud:
points_list.append([data[0], data[1], data[2]])
XYZ_cloud.from_list(points_list)
return XYZ_cloud
示例6: exact_planar_normals
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def exact_planar_normals(self):
import pcl
if self.__csv_path == "":
print "csv file path is not spcified!"
raw_data = np.genfromtxt(self.__csv_path, delimiter=",", skip_header=1)
points_xyz_arr = np.array(raw_data[:, :3], dtype=np.float32)
points_cloud = pcl.PointCloud()
points_cloud.from_array(points_xyz_arr)
for i in xrange(self.__palnar_normal_num):
seg = points_cloud.make_segmenter()
seg.set_optimize_coefficients(True)
seg.set_model_type(pcl.SACMODEL_PLANE)
seg.set_method_type(pcl.SAC_RANSAC)
seg.set_distance_threshold(self.ransac_distance_threshold)
indices, model = seg.segment()
if len(indices) < self.__plane_detection_points_thre:
break
# model turns Hessian Normal Form of a plane in 3D
# http://mathworld.wolfram.com/HessianNormalForm.html
self.__normals_list.append(model)
tmp = points_cloud.to_array()
tmp = np.delete(tmp, indices, 0)
points_cloud.from_array(tmp)
# show_xyzrgb_points_vtk(tmp)
示例7: get_plane_model
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def get_plane_model(arr):
import pcl
ransac_distance_threshold = 0.05
point_cloud = pcl.PointCloud(arr.astype(np.float32))
seg = point_cloud.make_segmenter_normals(ksearch=50)
seg.set_model_type(pcl.SACMODEL_PLANE)
seg.set_method_type(pcl.SAC_RANSAC)
seg.set_max_iterations(10000)
seg.set_distance_threshold(ransac_distance_threshold)
indices, model = seg.segment()
print "percentage of points in plane model: ", np.float32(len(indices)) / arr.shape[0]
return model
# project a point to an estimated plane
示例8: get_pc_segments
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def get_pc_segments(pc_np):
view_range = 300
ground_range = 0.3
inds = (
(pc_np[:, 0] < view_range)
& (pc_np[:, 1] < view_range)
& (pc_np[:, 2] > ground_range)
& (pc_np[:, 0] > -view_range)
& (pc_np[:, 1] > -view_range)
)
pc_np = pc_np[inds]
pc = pcl.PointCloud(pc_np.astype(np.float32))
pc_segments = pc_segmentation(pc)
return pc_segments
示例9: create_rgb
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def create_rgb(data):
'''
Create RGB point cloud from ordinary nx3 array, or equivalent list representation.
Note that RGB value should be represented in integer of 0~255
'''
data = np.array(data, copy=False)
if data.shape[-1] != 3:
return ValueError("Each point should contain 3 values")
rgb_dt = np.dtype(dict(names=['b','g','r'], formats=['u1','u1','u1'], itemsize=16))
rgb_arr = np.empty(len(data), dtype=rgb_dt)
rgb_arr['r'], rgb_arr['g'], rgb_arr['b'] = data[:,0], data[:,1], data[:,2]
return PointCloud(rgb_arr.view('u4'), 'RGB')
示例10: create_xyz
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def create_xyz(data):
'''
Create PointXYZ point cloud from ordinary nx3 array, or equivalent list representation
'''
data = np.array(data, copy=False)
if data.shape[-1] != 3:
return ValueError("Each point should contain 3 values")
dt = np.dtype(dict(names=['x','y','z'], formats=['f4','f4','f4'], itemsize=16))
arr = np.empty(len(data), dtype=dt)
arr['x'], arr['y'], arr['z'] = data[:,0], data[:,1], data[:,2]
return PointCloud(arr, 'XYZ')
示例11: create_xyzrgba
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def create_xyzrgba(data):
'''
Create PointXYZRGBA point cloud from ordinary nx6 array, or equivalent list representation
'''
data = np.array(data, copy=False)
if data.shape[-1] != 7:
return ValueError("Each point should contain 3 values")
rgba_dt = np.dtype(dict(names=['b','g','r','a'], formats=['u1','u1','u1','u1'], itemsize=4))
rgba_arr = np.empty(len(data), dtype=rgba_dt)
rgba_arr['r'], rgba_arr['g'], rgba_arr['b'], rgba_arr['a'] = data[:,3], data[:,4], data[:,5], data[:,6]
cloud_dt = np.dtype(dict(names=['x','y','z','rgba'], formats=['f4','f4','f4','u4'], offsets=[0,4,8,16], itemsize=20))
cloud_arr = np.empty(len(data), dtype=cloud_dt)
cloud_arr['x'], cloud_arr['y'], cloud_arr['z'], cloud_arr['rgba'] = data[:,0], data[:,1], data[:,2], rgba_arr.view('u4')
return PointCloud(cloud_arr, 'XYZRGBA')
示例12: create_xyzi
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def create_xyzi(data):
'''
Create PointXYZI point cloud from ordinary nx4 array, or equivalent list representation
'''
data = np.array(data, copy=False)
if data.shape[-1] != 4:
return ValueError("Each point should contain 4 values")
dt = np.dtype(dict(names=['x','y','z','intensity'], formats=['f4','f4','f4','f4'], offsets=[0,4,8,16], itemsize=32))
arr = np.empty(len(data), dtype=dt)
arr['x'], arr['y'], arr['z'], arr['intensity'] = data[:,0], data[:,1], data[:,2], data[:,3]
return PointCloud(arr, 'XYZI')
示例13: test_normal_init
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_normal_init(self):
cloud_array = np.array([[1,2,3],[2,3,4]], dtype='f4')
with self.assertRaises(ValueError):
cloud = pcl.PointCloud(cloud_array)
# add padding zeros after points
cloud_array_pad = np.insert(cloud_array, 3, 0, axis=1)
cloud = pcl.PointCloud(cloud_array_pad)
assert len(cloud) == 2
assert np.allclose(cloud.xyz, cloud_array)
assert len(cloud.fields) == 3
assert cloud.names == ['x', 'y', 'z']
示例14: test_list_init
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_list_init(self):
cloud = pcl.PointCloud([(1,2,3),(2,3,4)], 'xyz')
assert len(cloud) == 2
assert np.allclose(cloud.xyz, [[1,2,3],[2,3,4]])
assert cloud.names == ['x', 'y', 'z']
示例15: test_struct_init
# 需要导入模块: import pcl [as 别名]
# 或者: from pcl import PointCloud [as 别名]
def test_struct_init(self):
cloud_array = np.array([(1,2,3),(2,3,4)],
dtype={'names':['x','y','z'], 'formats':['f4','f4','f4'], 'itemsize':16})
cloud = pcl.PointCloud(cloud_array)
assert len(cloud) == 2
assert np.allclose(cloud.xyz, [[1,2,3],[2,3,4]])
assert cloud.names == ['x', 'y', 'z']
cloud = pcl.PointCloud(np.array([(1,2,3,5),(2,3,4,5)],
dtype={'names':['x','y','z','i'], 'formats':['f4','f4','f4','i1'], 'offsets':[0,4,8,16]}))
assert len(cloud) == 2
assert np.allclose(cloud.xyz, [[1,2,3],[2,3,4]])
assert cloud.names == ['x', 'y', 'z', 'i']