How to use the plyfile.make2d function in plyfile

To help you get started, we’ve selected a few plyfile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dranjan / python-plyfile / test / test_plyfile.py View on Github external
def test_make2d():
    a = numpy.empty(2, dtype=object)
    a[:] = [numpy.array([0, 1, 2]), numpy.array([3, 4, 5])]

    b = make2d(a)
    assert b.shape == (2, 3)
    assert (b == [[0, 1, 2], [3, 4, 5]]).all()
github haixpham / end2end_AU_speech / src / ShapeUtils2.py View on Github external
def load_shape(filename, load_triangles = False):
    mesh = plyfile.PlyData.read(filename)
    # convert vertices to numpy array
    vertices = np.transpose(np.vstack((mesh['vertex']['x'],mesh['vertex']['y'],mesh['vertex']['z'])))
    # get triangles
    if load_triangles:
        tridata = mesh['face'].data['vertex_indices']
        triangles = plyfile.make2d(tridata)
        return vertices, triangles
    return vertices
github sjdv1982 / seamless / OLD / examples / 3D / cell-load-ply.py View on Github external
filename = PINS.filename.get()

if filename.endswith(".zip"):
    zipf = zipfile.ZipFile(filename)
    assert len(zipf.namelist()) == 1
    zply = zipf.open(zipf.namelist()[0])
    plydata = PlyData.read(zply)
else:
    plydata = PlyData.read(filename)
elements = {e.name: e for e in plydata.elements}
vertices = elements["vertex"].data
faces = elements["face"].data

#faces => indices + edges
indices = make2d(faces['vertex_indices']).astype(np.uint16)
assert indices.shape[1] == 3 #triangles only
edges = set()
for triangle in indices:
    for p1,p2 in ((0,1),(1,2),(2,0)):
        i1, i2 = triangle[p1], triangle[p2]
        if i2 < i1: i1,i2 = i2,i1
        edges.add((i1,i2))
edges = np.array(list(edges),dtype=np.uint16)

#vertices => coordinates + normals
for n in range(len(vertices.dtype)):
    assert vertices.dtype[n] == vertices.dtype[0]
vertices = vertices.view(vertices.dtype[0]).reshape(vertices.shape + (-1,))
coordinates = vertices[:,:3]
normals = vertices[:,3:6]
coordinates -= coordinates.mean(axis=0)
github daeyun / object-shapes-cvpr18 / python / mvshape / io_utils.py View on Github external
def read_ply_pcl(filename):
    plydata = plyfile.PlyData.read(filename)
    v = np.vstack((plydata['vertex']['x'], plydata['vertex']['y'], plydata['vertex']['z'])).T
    normals = np.vstack((plydata['vertex']['nx'], plydata['vertex']['ny'], plydata['vertex']['nz'])).T
    values = plydata['vertex']['value'].T
    confidence = plydata['vertex']['confidence'].T
    ret = {
        'v': v,
        'confidence': confidence,
        'normals': normals,
        'value': values,
    }
    if 'face' in plydata:
        ret['f'] = plyfile.make2d(plydata['face'].data['vertex_indices'])
    return ret