trying to figx data generation

This commit is contained in:
2023-02-18 00:53:41 +00:00
parent a94be773d3
commit e0d1916901
6 changed files with 317 additions and 222 deletions
+31 -16
View File
@@ -231,10 +231,6 @@ def read_posed_garment_frame(folder, id, garment, frame, map=None, mask=None, sh
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]])
verts[mask, :] = verts[mask, :] - np.squeeze(shape_offsets)[mask, :]
if deorient:
R = scipy.spatial.transform.Rotation.from_euler('xyz', pose[:3]).inv()
# R = scipy.spatial.transform.Rotation.from_euler([0,0,-zrot])
@@ -255,10 +251,6 @@ def read_posed_garment(folder, id, garment, map=None, mask=None, shape=None, sha
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]])
verts[:, mask, :] = verts[:, mask, :] - np.squeeze(shape_offsets)[None, mask, :]
if deorient:
for i in range(verts.shape[0]):
R = scipy.spatial.transform.Rotation.from_euler('xyz', poses[:3, i]).inv()
@@ -308,17 +300,40 @@ def read_posed_body(folder, id, poses=None, deorient=False):
return verts
def read_curvatures(h5file, id, garment, frames, neighbourhood=None):
frames_filtered = [frame for frame in frames if (frame.split()[0] == id and frame.split()[2] == garment)]
garment = frames_filtered[0].split()[2]
curvatures_all = []
for frame_nr in range(len(frames_filtered)):
curv = h5file.get_node(f'/{id}/{frame_nr}/{garment}/curvature_raw').read()
curvatures_all.append(curv)
return np.array(curvatures_all)
# def read_curvatures(h5file, id, garment, frames, neighbourhood=None):
# frames_filtered = [frame for frame in frames if (frame.split()[0] == id and frame.split()[2] == garment)]
# if len(frames_filtered) == 0:
# print(f'No frames found for {id} {garment}')
# if len(frames_filtered[0].split()) < 3:
# print(f'No garment specified for {id} {garment}')
# print(frames_filtered[0].split())
# garment = frames_filtered[0].split()[2]
# curvatures_all = []
# for frame_nr in range(len(frames_filtered)):
# curv = h5file.get_node(f'/{id}/{frame_nr}/{garment}/curvature_raw').read()
# curvatures_all.append(curv)
# return np.array(curvatures_all)
def read_curvatures(folder, id, garment, frames=None, count=None, neighbourhood=None, per_garment=False):
if neighbourhood is not None:
raise NotImplementedError('Neighbourhood not implemented for reading curvatures')
if count is None:
frames_filtered = [frame for frame in frames if (frame.split()[0] == id and frame.split()[2] == garment)]
count = len(frames_filtered)
all = []
for i in range(count):
curv = np.load(os.path.join(folder, 'curvature_mesh_global' if not per_garment else 'curvature_mesh_garment', f'{id}_{i}_{garment}.npz'))['mesh_curvature_raw'] # not actually raw
all.append(curv)
return all
def read_curvature_frame(folder, id, garment, frame, neighbourhood=None, per_garment=False):
if neighbourhood is not None:
raise NotImplementedError('Neighbourhood not implemented for reading curvatures')
curv = np.load(os.path.join(folder, 'curvature_mesh_global' if not per_garment else 'curvature_mesh_garment', f'{id}_{frame}_{garment}.npz'))['mesh_curvature_raw'] # not actually raw
return curv
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')