temp fix for reading whole sequence of posed
This commit is contained in:
+85
-5
@@ -245,11 +245,16 @@ def read_posed_garment_frame(folder, id, garment, frame, map=None, mask=None, sh
|
||||
|
||||
# can i cache map?
|
||||
# NOT WORKING WELL
|
||||
def read_posed_garment(folder, id, garment, mask=None, shape=None, shapedirs=None, poses=None, unshape=False, deorient=False):
|
||||
body_posed = readPC2(os.path.join(folder, id, 'Body_posed.pc16'), True)['V']
|
||||
offsets = readPC2(os.path.join(folder, id, garment + '_offsets_dynamic.pc16'), True)['V']
|
||||
verts = (body_posed + offsets) * mask[:, None]
|
||||
|
||||
def read_posed_garment(folder, id, garment, map=None, mask=None, shape=None, shapedirs=None, poses=None, unshape=False, deorient=False):
|
||||
# body_posed = readPC2(os.path.join(folder, id, 'Body_posed.pc16'), True)['V']
|
||||
# offsets = readPC2(os.path.join(folder, id, garment + '_offsets_dynamic.pc16'), True)['V']
|
||||
# verts = (body_posed + offsets) * mask[:, None]
|
||||
pc16_path = os.path.join(folder, id, garment + '.pc16')
|
||||
info = loadInfo(os.path.join(folder, id, 'info.mat'))
|
||||
verts = np.stack([readPC2Frame(pc16_path, frame, True) for frame in range(info['poses'].shape[1])])
|
||||
if map is None:
|
||||
map = sio.loadmat(os.path.join(folder, id, garment + '_map.mat'))['map'].reshape((-1))
|
||||
verts = verts[:, map, :]
|
||||
|
||||
if unshape:
|
||||
shape_offsets = np.tensordot(shape, shapedirs, axes=[[1], [2]])
|
||||
@@ -313,6 +318,81 @@ def read_curvatures(h5file, id, frames, neighbourhood=None):
|
||||
curvatures_all.append(curv)
|
||||
return np.array(curvatures_all)
|
||||
|
||||
|
||||
|
||||
|
||||
import sys
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
||||
|
||||
import plotly.graph_objects as go
|
||||
from custom_utils.custom_utils import _maskFaces
|
||||
|
||||
def plot_3d(mesh, faces):
|
||||
fig = go.Figure()
|
||||
|
||||
|
||||
fig.add_trace(go.Mesh3d(
|
||||
# 8 vertices of a cube
|
||||
x=mesh[:,0],
|
||||
y=mesh[:,1],
|
||||
z=mesh[:,2],
|
||||
# i, j and k give the vertices of triangles
|
||||
i = faces[:,0],
|
||||
j = faces[:,1],
|
||||
k = faces[:,2]
|
||||
))
|
||||
|
||||
|
||||
|
||||
fig.update_layout(scene_aspectmode='manual', scene_aspectratio=dict(x=1, y=1, z=1),)
|
||||
helper = dict(xaxis = dict(nticks=4, range=[-1,1],),
|
||||
yaxis = dict(nticks=4, range=[-1,1],),
|
||||
zaxis = dict(nticks=4, range=[-1,1],),)
|
||||
fig.update_layout(scene = helper)
|
||||
|
||||
return fig
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
folder = '/home/workspace/data/dataset/cloth3d/train'
|
||||
F = np.load("custom_utils/smpl_faces.npy")#.astype(np.int32)
|
||||
|
||||
frames = []
|
||||
with open(os.path.join(folder, 'frames_all.txt'), 'r') as f:
|
||||
lines = f.readlines()
|
||||
lines = [line.strip() for line in lines]
|
||||
frames = lines
|
||||
|
||||
for frame in frames:
|
||||
id = frame.split()[0]
|
||||
frame_nr = int(frame.split()[1])
|
||||
garment = frame.split()[2]
|
||||
|
||||
mask = read_garment_mask(folder, id, garment)
|
||||
_, faces = _maskFaces(np.zeros((14475, 3), dtype=np.float32), F, mask)
|
||||
mesh_1 = read_posed_garment(folder, id, garment, mask=mask, unshape=False, deorient=False)[0][mask, :]
|
||||
mesh_2 = read_posed_garment_frame(folder, id, garment, 0, mask=mask, unshape=False, deorient=False)[mask, :]
|
||||
|
||||
plot_3d(mesh_1, faces).show()
|
||||
plot_3d(mesh_2, faces).show()
|
||||
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# import os
|
||||
# import sys
|
||||
# import numpy as np
|
||||
|
||||
Reference in New Issue
Block a user