Files
reconstruction/utils/data_utils.py
T
2022-12-23 22:15:22 +00:00

37 lines
931 B
Python

import os
import sys
import numpy as np
import scipy.io as sio
from math import cos, sin
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
from superSMPL.IO import readPC2Frame, readOBJ
class Frame:
def __init__(self, id, frame_nr, garment):
self.id = id
self.frame_nr = frame_nr
self.garment = garment
def mask_faces(F, mask):
F_mask = np.take(mask, F.reshape(-1), axis=0)
F_mask = F_mask.reshape((-1, 3)).sum(axis=1) == 3
V_ind = np.zeros(mask.shape, dtype=np.int32)
V_ind[mask] = np.arange(mask.sum())
F_new = np.take(V_ind, F[F_mask, :].reshape(-1), axis=0).reshape((-1, 3))
return F_new
def read_frames_file(file):
frames = []
with open(file, 'r') as f:
lines = f.readlines()
for line in lines:
id, frame_nr, garment = line.split()
frames.append(Frame(id, int(frame_nr), garment))
return frames