3D human pose estimation dataset.

class Human36mDataset[source]

Human36mDataset(path, remove_static_joints=True) :: MocapDataset

Human3.6M pose estimation dataset.

class Human36mDataset(MocapDataset):
    """Human3.6M pose estimation dataset."""
    def __init__(self, path, remove_static_joints=True):
        super().__init__(fps=50, skeleton=h36m_skeleton)
        self.cameras = copy.deepcopy(h36m_cameras_extrinsic_params)

        for cameras in self._cameras.values():
            for i, cam in enumerate(cameras):
                cam.update(h36m_cameras_intrinsic_params[i])
                for k, v in cam.items():
                    if k not in ["id", "res_w", "res_h"]:
                        cam[k] = np.array(v, dtype='float32')
        
        # Normalize camera frame.
        cam['center'] = normalize_screen_coordinates(
            cam['center'], w=cam['res_w'], h=cam['res_h']).astype('float32')
        cam['focal_length'] = cam['focal_length']/cam['res_w']*2
        if 'translation' in cam:
            cam['translation'] = cam['translation']/1000 # Milimeters to meters.  
        # Add intrinsic parameters vector.
        cam['intrinsic'] = np.concatenate(
            (cam['focal_length'], cam['center'], 
            cam['radial_distortion'], cam['tangential_distortion']))

        # Load serialized dataset.
        data = np.load(path, allow_pickle=True)['positions_3d'].item() 
    
        self._data = {}
        for subject, actions in data.items():
            self._data[subject] = {}
            for action_name, positions in actions.items():
                self._data[subject][action_name] = {
                    'positions': positions,
                    'cameras': self._cameras[subject],
                }    
                
        if remove_static_joints:
            # Bring the skeleton to 17 joints instead of the original 32
            self.remove_joints([
                4, 5, 9, 10, 11, 16, 20, 21, 22, 23, 24,28, 29, 30, 31
            ])
            
            # Rewire shoulders to the correct parents
            self._skeleton._parents[11] = 8
            self._skeleton._parents[14] = 8

Specific parameters for the Human3.6M skeleton

This is mainly to be consistent with other work.

h36m_skeleton = Skeleton(
       parents=[
              -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12,
              16, 17, 18, 19, 20, 19, 22, 12, 24, 25, 26, 27, 28, 27, 30
       ],
       joints_left=[6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23],
       joints_right=[1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31]
)