MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __init__

Method __init__

detrsmpl/data/data_structures/smc_reader.py:14–74  ·  view source on GitHub ↗

Read SenseMocapFile endswith ".smc", see: https://github.com/open- mmlab/detrsmpl/blob/main/docs/smc.md. Args: file_path (str): Path to an SMC file. body_model (nn.Module or dict): Only needed for SMPL transformation to device

(self, file_path, body_model=None)

Source from the content-addressed store, hash-verified

12
13class SMCReader:
14 def __init__(self, file_path, body_model=None):
15 """Read SenseMocapFile endswith ".smc", see: https://github.com/open-
16 mmlab/detrsmpl/blob/main/docs/smc.md.
17
18 Args:
19 file_path (str):
20 Path to an SMC file.
21 body_model (nn.Module or dict):
22 Only needed for SMPL transformation to device frame
23 if nn.Module: a body_model instance
24 if dict: a body_model config
25 """
26 self.smc = h5py.File(file_path, 'r')
27 self.__calibration_dict__ = None
28 self.action_id = self.smc.attrs['action_id']
29 self.actor_id = self.smc.attrs['actor_id']
30 self.datetime_str = self.smc.attrs['datetime_str'] # .decode()
31 self.kinect_num_frames = self.smc['Kinect'].attrs['num_frame']
32 self.num_kinects = self.smc['Kinect'].attrs['num_device']
33 self.kinect_color_resolution = self.get_kinect_color_resolution(0)
34 self.kinect_depth_resolution = self.get_kinect_depth_resolution(0)
35 self.iphone_exists = 'iPhone' in self.smc.keys()
36 self.num_iphones = 1
37 if self.iphone_exists:
38 self.iphone_num_frames = self.smc['iPhone'].attrs['num_frame']
39 self.iphone_color_resolution = \
40 self.smc['iPhone'].attrs['color_resolution'] # vertical
41 self.iphone_depth_resolution = \
42 self.smc['iPhone'].attrs['depth_resolution'] # vertical
43 self.keypoint_exists = 'Keypoints3D' in self.smc.keys()
44 if self.keypoint_exists:
45 self.keypoints_num_frames = self.smc['Keypoints3D'].attrs[
46 'num_frame']
47 self.keypoints_convention = self.smc['Keypoints3D'].attrs[
48 'convention']
49 self.keypoints_created_time = self.smc['Keypoints3D'].attrs[
50 'created_time']
51 self.smpl_exists = 'SMPL' in self.smc.keys()
52 if self.smpl_exists:
53 self.smpl_num_frames = self.smc['SMPL'].attrs['num_frame']
54 self.smpl_created_time = self.smc['SMPL'].attrs['created_time']
55
56 # initialize body model
57 if isinstance(body_model, torch.nn.Module):
58 self.body_model = body_model
59 elif isinstance(body_model, dict):
60 self.body_model = build_body_model(body_model)
61 else:
62 # in most cases, SMCReader is instantiated for image reading
63 # only. Hence, it is wasteful to initialize a body model until
64 # really needed in get_smpl()
65 self.body_model = None
66 self.default_body_model_config = dict(
67 type='SMPL',
68 gender='neutral',
69 num_betas=10,
70 keypoint_src='smpl_45',
71 keypoint_dst='smpl_45',

Callers

nothing calls this directly

Calls 4

build_body_modelFunction · 0.90
keysMethod · 0.45

Tested by

no test coverage detected