本文整理汇总了Python中plyfile.PlyElement.describe方法的典型用法代码示例。如果您正苦于以下问题:Python PlyElement.describe方法的具体用法?Python PlyElement.describe怎么用?Python PlyElement.describe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plyfile.PlyElement
的用法示例。
在下文中一共展示了PlyElement.describe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_ply_color
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply_color(points, labels, filename, num_classes=None, colormap=pyplot.cm.jet):
""" Color (N,3) points with labels (N) within range 0 ~ num_classes-1 as OBJ file """
labels = labels.astype(int)
N = points.shape[0]
if num_classes is None:
num_classes = np.max(labels)+1
else:
assert(num_classes>np.max(labels))
vertex = []
#colors = [pyplot.cm.jet(i/float(num_classes)) for i in range(num_classes)]
colors = [colormap(i/float(num_classes)) for i in range(num_classes)]
for i in range(N):
c = colors[labels[i]]
c = [int(x*255) for x in c]
vertex.append( (points[i,0],points[i,1],points[i,2],c[0],c[1],c[2]) )
vertex = np.array(vertex, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4'),('red', 'u1'), ('green', 'u1'),('blue', 'u1')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=True).write(filename)
示例2: write_ply_color_multi
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply_color_multi(points, labels, filename, pre_dict=None, colormap=pyplot.cm.jet):
""" Color (N,3) points with labels (N) within range 0 ~ num_classes-1 as OBJ file """
#labels = labels.astype(int)
N = points.shape[0]
cdict = construct_dict(labels, predict=pre_dict)
num_classes = len(cdict.keys())
vertex = []
#colors = [pyplot.cm.jet(i/float(num_classes)) for i in range(num_classes)]
colors = [colormap(i/float(num_classes)) for i in range(num_classes)]
for i in range(N):
c = colors[cdict[hashlist(labels[i,:])]]
c = [int(x*255) for x in c]
vertex.append( (points[i,0],points[i,1],points[i,2],c[0],c[1],c[2]) )
vertex = np.array(vertex, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4'),('red', 'u1'), ('green', 'u1'),('blue', 'u1')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=True).write(filename)
return cdict
示例3: write_ply_label
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply_label(points, labels, filename, num_classes, colormap=pyplot.cm.jet):
""" Color (N,3) points with labels (N) within range 0 ~ num_classes-1 as OBJ file """
labels = labels.astype(int)
N = points.shape[0]
#cdict = construct_dict(labels, predict=pre_dict)
#num_classes = len(cdict.keys())
vertex = []
#colors = [pyplot.cm.jet(i/float(num_classes)) for i in range(num_classes)]
colors = [colormap(i/float(num_classes)) for i in range(num_classes)]
for i in range(N):
c = colors[labels[i]]
c = [int(x*255) for x in c]
vertex.append( (points[i,0],points[i,1],points[i,2],c[0],c[1],c[2]) )
vertex = np.array(vertex, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4'),('red', 'u1'), ('green', 'u1'),('blue', 'u1')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=True).write(filename)
示例4: write_ply_color
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply_color(points, filename, text=True):
""" input: Nx6, write points to filename as PLY format. """
points_ = [(points[i,0], points[i,1], points[i,2]) for i in range(points.shape[0])]
points_color_ = [(255*points[i,3], 255*points[i,4], 255*points[i,5]) for i in range(points.shape[0])]
n = points.shape[0]
vertex = np.array(points_, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4')])
vertex_color = np.array(points_color_, dtype=[('red', 'u1'), ('green', 'u1'),('blue', 'u1')])
vertex_all = np.empty(n, vertex.dtype.descr + vertex_color.dtype.descr)
for prop in vertex.dtype.names:
vertex_all[prop] = vertex[prop]
for prop in vertex_color.dtype.names:
vertex_all[prop] = vertex_color[prop]
ply = PlyData([PlyElement.describe(vertex_all, 'vertex')], text=True)
ply.write(filename)
# ----------------------------------------
# Simple Point cloud and Volume Renderers
# ----------------------------------------
示例5: write_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply(points, filename, text=True):
""" input: Nx3, write points to filename as PLY format. """
points = [(points[i,0], points[i,1], points[i,2]) for i in range(points.shape[0])]
vertex = np.array(points, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=text).write(filename)
# ----------------------------------------
# Simple Point cloud and Volume Renderers
# ----------------------------------------
示例6: write_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply(points, filename, text=True):
""" input: Nx3, write points to filename as PLY format. """
points = [(points[i,0], points[i,1], points[i,2]) for i in range(points.shape[0])]
vertex = np.array(points, dtype=[('x', 'f4'), ('y', 'f4'),('z', 'f4')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=text).write(filename)
示例7: visualize
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def visualize(args):
print("visualizing...")
scene = np.load(CONF.SCANNETV2_FILE.format(args.scene_id))
vertex = []
for i in range(scene.shape[0]):
vertex.append(
(
scene[i][0],
scene[i][1],
scene[i][2],
CONF.PALETTE[int(scene[i][7])][0],
CONF.PALETTE[int(scene[i][7])][1],
CONF.PALETTE[int(scene[i][7])][2]
)
)
vertex = np.array(
vertex,
dtype=[
("x", np.dtype("float32")),
("y", np.dtype("float32")),
("z", np.dtype("float32")),
("red", np.dtype("uint8")),
("green", np.dtype("uint8")),
("blue", np.dtype("uint8"))
]
)
output_pc = PlyElement.describe(vertex, "vertex")
output_pc = PlyData([output_pc])
os.makedirs(CONF.SCAN_LABELS, exist_ok=True)
output_pc.write(CONF.SCANNETV2_LABEL.format(args.scene_id))
示例8: visualize
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def visualize(args, preds):
vertex = []
for i in range(preds.shape[0]):
vertex.append(
(
preds[i][0],
preds[i][1],
preds[i][2],
preds[i][3],
preds[i][4],
preds[i][5],
)
)
vertex = np.array(
vertex,
dtype=[
("x", np.dtype("float32")),
("y", np.dtype("float32")),
("z", np.dtype("float32")),
("red", np.dtype("uint8")),
("green", np.dtype("uint8")),
("blue", np.dtype("uint8"))
]
)
output_pc = PlyElement.describe(vertex, "vertex")
output_pc = PlyData([output_pc])
output_root = os.path.join(CONF.OUTPUT_ROOT, args.folder, "preds")
os.makedirs(output_root, exist_ok=True)
output_pc.write(os.path.join(output_root, "{}.ply".format(args.scene_id)))
示例9: write_point_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_point_ply(filename, v, n):
"""Write point cloud to ply file.
Args:
filename: str, filename for ply file to load.
v: np.array of shape [#v, 3], vertex coordinates
n: np.array of shape [#v, 3], vertex normals
"""
vn = np.concatenate([v, n], axis=1)
vn = [tuple(vn[i]) for i in range(vn.shape[0])]
vn = np.array(vn, dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4'),
('nx', 'f4'), ('ny', 'f4'), ('nz', 'f4')])
el = PlyElement.describe(vn, 'vertex')
PlyData([el]).write(filename)
示例10: export_pointcloud
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def export_pointcloud(vertices, out_file, as_text=True):
assert(vertices.shape[1] == 3)
vertices = vertices.astype(np.float32)
vector_dtype = [('x', 'f4'), ('y', 'f4'), ('z', 'f4')]
vertices = vertices.view(dtype=vector_dtype).flatten()
plyel = PlyElement.describe(vertices, 'vertex')
plydata = PlyData([plyel], text=as_text)
plydata.write(out_file)
示例11: write_color_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_color_ply(points, filename, text=True):
points = [(points[i,0], points[i,1], points[i,2], points[i,3], points[i,4], points[i,5]) for i in range(points.shape[0])]
vertex = np.array(points, dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4'), ('red', 'u1'), ('green', 'u1'), ('blue', 'u1')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=text).write(filename)
示例12: export_pointcloud
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def export_pointcloud(vertices, out_file, as_text=True):
assert(vertices.shape[1] == 3)
vertices = vertices.astype(np.float32)
vertices = np.ascontiguousarray(vertices)
vector_dtype = [('x', 'f4'), ('y', 'f4'), ('z', 'f4')]
vertices = vertices.view(dtype=vector_dtype).flatten()
plyel = PlyElement.describe(vertices, 'vertex')
plydata = PlyData([plyel], text=as_text)
plydata.write(out_file)
示例13: write_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply(array, filepath):
ply_el = PlyElement.describe(array, 'vertex')
target_path, _ = os.path.split(filepath)
if target_path != '' and not os.path.exists(target_path):
os.makedirs(target_path)
PlyData([ply_el]).write(filepath)
示例14: write_point_cloud
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_point_cloud(path, point_cloud):
point_clouds_list = []
for i in range(point_cloud.shape[0]):
point_clouds_list.append((point_cloud[i, 0], point_cloud[i, 1], point_cloud[i, 2], point_cloud[i, 3],
point_cloud[i, 4], point_cloud[i, 5]))
vertex = np.array(point_clouds_list,
dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4'), ('red', 'u1'), ('green', 'u1'), ('blue', 'u1')])
el = PlyElement.describe(vertex, 'vertex')
PlyData([el], text=True).write(path)
return
示例15: write_ply
# 需要导入模块: from plyfile import PlyElement [as 别名]
# 或者: from plyfile.PlyElement import describe [as 别名]
def write_ply(points, filename, text=True):
""" input: Nx3, write points to filename as PLY format. """
points = [(points[i, 0], points[i, 1], points[i, 2]) for i in range(points.shape[0])]
vertex = np.array(points, dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4')])
el = PlyElement.describe(vertex, 'vertex', comments=['vertices'])
PlyData([el], text=text).write(filename)
# ----------------------------------------
# Simple Point cloud and Volume Renderers
# ----------------------------------------