only read info.mat once

This commit is contained in:
2023-01-06 11:27:13 +00:00
parent 022c488180
commit 3c2c851ba5
2 changed files with 14 additions and 18 deletions
+8 -12
View File
@@ -57,16 +57,14 @@ class DataReader:
- V: human mesh vertices
- F: mesh faces
"""
def read_human(self, sample, frame, absolute=True):
# Read sample data
info = self.read_info(sample)
def read_human(self, sample, frame, trans, zrot):
# SMPL parameters
gender, pose, shape, trans = self.read_smpl_params(sample, frame)
# Compute SMPL
V, J = self.smpl[gender].set_params(pose=pose, beta=shape, trans=trans if absolute else None)
V, J = self.smpl[gender].set_params(pose=pose, beta=shape, trans=trans)
V -= J[0:1]
# Apply rotation on z-axis
zRot = zRotMatrix(info['zrot'])
zRot = zRotMatrix(zrot)
return zRot.dot(V.T).T, self.smpl[gender].faces, zRot.dot(trans.T).T[None,:], zRot.dot((J - J[0:1] + trans[None,:]).T).T[None,:], zRot.dot((J - J[0:1]).T).T[None,:]
""" Garment data """
@@ -76,21 +74,19 @@ class DataReader:
- sample: name of the sample
- garment: type of garment (e.g.: 'Tshirt', 'Jumpsuit', ...)
- frame: frame number
- absolute: True for absolute vertex locations, False for locations relative to SMPL root joint
- TODO: absolute: True for absolute vertex locations, False for locations relative to SMPL root joint
Outputs:
- V: 3D vertex locations for the specified sample, garment and frame
"""
def read_garment_vertices(self, sample, garment, frame, absolute=True):
def read_garment_vertices(self, sample, garment, frame, trans, zrot):
# Read garment vertices (relative to root joint)
pc16_path = os.path.join(self.SRC, sample, garment + '_registered.pc16')
V = readPC2Frame(pc16_path, frame, True)
# Read sample data
info = self.read_info(sample)
if absolute:
if trans is not None:
# Transform to absolute
V += info['trans'][:,frame][None]
# Apply rotation on z-axis
zRot = zRotMatrix(info['zrot'])
V += trans[None]
zRot = zRotMatrix(zrot)
return zRot.dot(V.T).T
"""