当前位置: 首页>>代码示例>>Python>>正文


Python PlyData.read方法代码示例

本文整理汇总了Python中plyfile.PlyData.read方法的典型用法代码示例。如果您正苦于以下问题:Python PlyData.read方法的具体用法?Python PlyData.read怎么用?Python PlyData.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plyfile.PlyData的用法示例。


在下文中一共展示了PlyData.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_tsdf

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_tsdf(filename):
  f = open(filename, 'rb')
  fileContent = f.read()

  A = struct.unpack("<3f", fileContent[:12])
  A = np.array(A, np.int32)
  # print(A)
  s1 = A[2]
  s2 = A[0]
  s3 = A[1]
  size = int(A[0]*A[1]*A[2])
  s = "<%df"%(int(size))
  TDF = struct.unpack(s, fileContent[12:12+size*4])

  out = np.zeros((s1, s2, s3))
  for i in range(s1):
    t = np.transpose(np.reshape(TDF[i*s2*s3: (i+1)*s2*s3], (s3, s2)))
    out[i] = t

  out = np.transpose(out, (1,2,0))

  out = out[20:-20, 20:-20, 20:-20]
  return out 
开发者ID:zaiweizhang,项目名称:H3DNet,代码行数:25,代码来源:pc_util.py

示例2: read_ply_xyzrgbnormal

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_ply_xyzrgbnormal(filename):
    """ read XYZ RGB normals point cloud from filename PLY file """
    assert(os.path.isfile(filename))
    with open(filename, 'rb') as f:
        plydata = PlyData.read(f)
        num_verts = plydata['vertex'].count
        vertices = np.zeros(shape=[num_verts, 9], dtype=np.float32)
        vertices[:,0] = plydata['vertex'].data['x']
        vertices[:,1] = plydata['vertex'].data['y']
        vertices[:,2] = plydata['vertex'].data['z']
        vertices[:,3] = plydata['vertex'].data['red']
        vertices[:,4] = plydata['vertex'].data['green']
        vertices[:,5] = plydata['vertex'].data['blue']

        # compute normals
        xyz = np.array([[x, y, z] for x, y, z, _, _, _, _ in plydata["vertex"].data])
        face = np.array([f[0] for f in plydata["face"].data])
        nxnynz = compute_normal(xyz, face)
        vertices[:,6:] = nxnynz
    return vertices 
开发者ID:daveredrum,项目名称:Pointnet2.ScanNet,代码行数:22,代码来源:pc_util.py

示例3: load_ply_mesh

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def load_ply_mesh(mesh_path):
    data = PlyData.read(mesh_path)

    vertex_data = data['vertex'].data
    vertices = np.zeros([vertex_data.shape[0], 3], dtype=np.float32)
    for i in range(vertices.shape[0]):
        for j in range(3):
            vertices[i, j] = vertex_data[i][j]

    face_data = data['face'].data
    faces = np.zeros([face_data.shape[0], 3], dtype=np.int32)
    for i in range(faces.shape[0]):
        for j in range(3):
            faces[i, j] = face_data[i][0][j]

    return vertices, faces 
开发者ID:halimacc,项目名称:DenseHumanBodyCorrespondences,代码行数:18,代码来源:meshutil.py

示例4: read_mesh_vertices_rgb

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_mesh_vertices_rgb(filename):
    """ read XYZ RGB for each vertex.
    Note: RGB values are in 0-255
    """
    assert os.path.isfile(filename)
    with open(filename, 'rb') as f:
        plydata = PlyData.read(f)
        num_verts = plydata['vertex'].count
        vertices = np.zeros(shape=[num_verts, 6], dtype=np.float32)
        vertices[:,0] = plydata['vertex'].data['x']
        vertices[:,1] = plydata['vertex'].data['y']
        vertices[:,2] = plydata['vertex'].data['z']
        vertices[:,3] = plydata['vertex'].data['red']
        vertices[:,4] = plydata['vertex'].data['green']
        vertices[:,5] = plydata['vertex'].data['blue']
    return vertices 
开发者ID:facebookresearch,项目名称:votenet,代码行数:18,代码来源:scannet_utils.py

示例5: load_mesh

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def load_mesh(mesh_file):
    with open(mesh_file, 'r') as f:
        str_file = f.read().split('\n')
        n_vertices, n_faces, _ = list(
            map(lambda x: int(x), str_file[1].split(' ')))
        str_file = str_file[2:]  # Remove first 2 lines

        v = [l.split(' ') for l in str_file[:n_vertices]]
        f = [l.split(' ') for l in str_file[n_vertices:]]

    v = np.array(v).astype(np.float32)
    f = np.array(f).astype(np.uint64)[:, 1:4]

    mesh = trimesh.Trimesh(vertices=v, faces=f, process=False)

    return mesh 
开发者ID:autonomousvision,项目名称:occupancy_flow,代码行数:18,代码来源:io.py

示例6: load_file

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def load_file(file_name, voxel_size):
  plydata = PlyData.read(file_name)
  data = plydata.elements[0].data
  coords = np.array([data['x'], data['y'], data['z']], dtype=np.float32).T
  colors = np.array([data['red'], data['green'], data['blue']], dtype=np.float32).T / 255
  labels = np.array(data['label'], dtype=np.int32)

  # Generate input pointcloud
  pcd = o3d.geometry.PointCloud()
  pcd.points = o3d.utility.Vector3dVector(coords)
  pcd.colors = o3d.utility.Vector3dVector(colors)

  # Normalize feature
  norm_coords = coords - coords.mean(0)
  feats = np.concatenate((colors - 0.5, norm_coords), 1)

  coords, feats, labels = ME.utils.sparse_quantize(
      coords, feats, labels, quantization_size=voxel_size)

  return coords, feats, labels, pcd 
开发者ID:chrischoy,项目名称:SpatioTemporalSegmentation,代码行数:22,代码来源:stanford.py

示例7: load_ply_file

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def load_ply_file(fname) :
    """Loads a .ply mesh to return a collection of weighted Dirac atoms: one per triangle face."""

    # Load the data, and read the connectivity information:
    plydata = PlyData.read(fname)
    triangles = np.vstack( plydata['face'].data['vertex_indices'] )

    # Normalize the point cloud, as specified by the user:
    points = np.vstack( [ [v[0],v[1],v[2]] for v in  plydata['vertex'] ] )

    return to_measure(points, triangles)
    

################################################################################
# Utility: load ".nii" volume file.
# 
开发者ID:jeanfeydy,项目名称:geomloss,代码行数:18,代码来源:plot_interpolation_3D.py

示例8: __getitem__

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def __getitem__(self, index):
        fn = self.fns[index]
        cls = self.cat[fn.split('/')[0]]
        with open(os.path.join(self.root, fn), 'rb') as f:
            plydata = PlyData.read(f)
        pts = np.vstack([plydata['vertex']['x'], plydata['vertex']['y'], plydata['vertex']['z']]).T
        choice = np.random.choice(len(pts), self.npoints, replace=True)
        point_set = pts[choice, :]

        point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0)  # center
        dist = np.max(np.sqrt(np.sum(point_set ** 2, axis=1)), 0)
        point_set = point_set / dist  # scale

        if self.data_augmentation:
            theta = np.random.uniform(0, np.pi * 2)
            rotation_matrix = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]])
            point_set[:, [0, 2]] = point_set[:, [0, 2]].dot(rotation_matrix)  # random rotation
            point_set += np.random.normal(0, 0.02, size=point_set.shape)  # random jitter

        point_set = torch.from_numpy(point_set.astype(np.float32))
        cls = torch.from_numpy(np.array([cls]).astype(np.int64))
        return point_set, cls 
开发者ID:fxia22,项目名称:pointnet.pytorch,代码行数:24,代码来源:dataset.py

示例9: readPlyFile

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def readPlyFile(filename):
    """
    Usese plyfile python pacakage to read a ply file.
    Gets around issues with pcl having a bad ply writer for pointclouds
    :param filename:
    :type filename: str
    :return: vtkPolyData
    :rtype:
    """

    from plyfile import PlyData

    plydata = PlyData.read(filename)
    vertex_data = plydata['vertex'].data # numpy array with fields ['x', 'y', 'z']
    pts = np.zeros([vertex_data.size, 3])
    pts[:, 0] = vertex_data['x']
    pts[:, 1] = vertex_data['y']
    pts[:, 2] = vertex_data['z']

    return vnp.numpyToPolyData(pts) 
开发者ID:RobotLocomotion,项目名称:director,代码行数:22,代码来源:ioUtils.py

示例10: dataSource

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def dataSource(fn):
    with open(fn, 'rb') as f:
            plydata=PlyData.read(f)
        #print(plydata,'\n',plydata['vertex'][0],'\n',plydata.elements[0].properties)        
    print(plydata) #可以通过打印,查看读取的点云数据格式,从而进一步提取所需数据。
    pointsX=plydata['vertex']['x']  #等同于plydata['vertex'][0]
    pointsY=plydata['vertex']['y']
    pointsZ=plydata['vertex']['z']
    pointsR=plydata['vertex']['red']
    pointsG=plydata['vertex']['green']
    pointsB=plydata['vertex']['blue']
    pointsXYZ=np.array([pointsX,pointsY,pointsZ])
    pointsRGB=np.array([pointsR,pointsG,pointsB])
    #[:,:1000]
    print(pointsRGB.shape,pointsXYZ.shape)
    print(pointsRGB.transpose())  
    return pointsXYZ,pointsRGB 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:19,代码来源:kinect3Dcould.py

示例11: read_ply

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_ply(filename):
    """ read XYZ point cloud from filename PLY file """
    plydata = PlyData.read(filename)
    pc = plydata['vertex'].data
    pc_array = np.array([[x, y, z] for x,y,z in pc])
    return pc_array 
开发者ID:vinits5,项目名称:pointnet-registration-framework,代码行数:8,代码来源:pc_util.py

示例12: get_xyz_max

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def get_xyz_max(fn_read):
    plydata = PlyData.read(fn_read)
    #x,y,z : embbedding to RGB
    x_ct = np.mean(plydata.elements[0].data['x'])    
    x_abs = np.max(np.abs(plydata.elements[0].data['x']-x_ct))    
    y_ct = np.mean(plydata.elements[0].data['y'])    
    y_abs = np.max(np.abs(plydata.elements[0].data['y']-y_ct))   
    
    z_ct = np.mean(plydata.elements[0].data['z'])    
    z_abs = np.max(np.abs(plydata.elements[0].data['z']-z_ct))   
    
    return x_abs,y_abs,z_abs,x_ct,y_ct,z_ct 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:14,代码来源:2_1_ply_file_to_3d_coord_model.py

示例13: convert_unique

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def convert_unique(fn_read,fn_write,center_x=True,center_y=True,center_z=True):
    plydata = PlyData.read(fn_read)

    #x,y,z : embbedding to RGB
    x_ct = np.mean(plydata.elements[0].data['x'])    
    if not(center_x):
        x_ct=0
    x_abs = np.max(np.abs(plydata.elements[0].data['x']-x_ct))
    
    y_ct = np.mean(plydata.elements[0].data['y'])    
    if not(center_y):
        y_ct=0
    y_abs = np.max(np.abs(plydata.elements[0].data['y']-y_ct))    
    
    z_ct = np.mean(plydata.elements[0].data['z'])    
    if not(center_z):
        z_ct=0
    z_abs = np.max(np.abs(plydata.elements[0].data['z']-z_ct))    
    n_vert = plydata.elements[0].data['x'].shape[0]
   
    for i in range(n_vert):
        r=(plydata.elements[0].data['x'][i]-x_ct)/x_abs #-1 to 1
        r = (r+1)/2 #0 to 2 -> 0 to 1        
        g=(plydata.elements[0].data['y'][i]-y_ct)/y_abs
        g = (g+1)/2
        b=(plydata.elements[0].data['z'][i]-z_ct)/z_abs
        b = (b+1)/2
        #if b> 1: b=1
        #if b<0: b=0
        plydata.elements[0].data['red'][i]=r*255
        plydata.elements[0].data['green'][i]=g*255
        plydata.elements[0].data['blue'][i]=b*255
    plydata.write(fn_write)        
    return x_abs,y_abs,z_abs,x_ct,y_ct,z_ct 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:36,代码来源:2_1_ply_file_to_3d_coord_model.py

示例14: read_ply_xyz

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_ply_xyz(filename):
    """ read XYZ point cloud from filename PLY file """
    assert(os.path.isfile(filename))
    with open(filename, 'rb') as f:
        plydata = PlyData.read(f)
        num_verts = plydata['vertex'].count
        vertices = np.zeros(shape=[num_verts, 3], dtype=np.float32)
        vertices[:,0] = plydata['vertex'].data['x']
        vertices[:,1] = plydata['vertex'].data['y']
        vertices[:,2] = plydata['vertex'].data['z']
    return vertices 
开发者ID:daveredrum,项目名称:Pointnet2.ScanNet,代码行数:13,代码来源:pc_util.py

示例15: read_ply_xyzrgb

# 需要导入模块: from plyfile import PlyData [as 别名]
# 或者: from plyfile.PlyData import read [as 别名]
def read_ply_xyzrgb(filename):
    """ read XYZRGB point cloud from filename PLY file """
    assert(os.path.isfile(filename))
    with open(filename, 'rb') as f:
        plydata = PlyData.read(f)
        num_verts = plydata['vertex'].count
        vertices = np.zeros(shape=[num_verts, 6], dtype=np.float32)
        vertices[:,0] = plydata['vertex'].data['x']
        vertices[:,1] = plydata['vertex'].data['y']
        vertices[:,2] = plydata['vertex'].data['z']
        vertices[:,3] = plydata['vertex'].data['red']
        vertices[:,4] = plydata['vertex'].data['green']
        vertices[:,5] = plydata['vertex'].data['blue']
    return vertices 
开发者ID:daveredrum,项目名称:Pointnet2.ScanNet,代码行数:16,代码来源:pc_util.py


注:本文中的plyfile.PlyData.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。