def __init__()

in data/dataset.py [0:0]


    def __init__(self, transform, mode):
        self.mode = mode
        self.img_path = '../data/images/subject_' + cfg.subject
        self.annot_path = '../data/annotations'
        self.hand_model_path = '../data/hand_model'
        
        if cfg.subject == '1':
            self.sequence_names = glob(osp.join(self.img_path, '00*')) # 00: right single hand, 01: left single hand, 02: double hands
        else:
            self.sequence_names = glob(osp.join(self.img_path, '*RT*')) # RT: right single hand, LT: left single hand, DH: double hands
        self.sequence_names = [name for name in self.sequence_names if osp.isdir(name)]
        self.sequence_names = [name for name in self.sequence_names if 'ROM' not in name] # 'ROM' exclude in training
        self.sequence_names = [x.split('/')[-1] for x in self.sequence_names]

        self.krt_path = osp.join(self.annot_path, 'KRT_512') # camera parameters

        self.obj_file_path = osp.join(self.hand_model_path, 'hand.obj')
        self.template_skeleton_path = osp.join(self.hand_model_path, 'skeleton.txt')
        self.template_skinning_weight_path = osp.join(self.hand_model_path, 'skinning_weight.txt')
        self.template_local_pose_path = osp.join(self.hand_model_path, 'local_pose.txt')
        self.template_global_pose_path = osp.join(self.hand_model_path, 'global_pose.txt')
        self.template_global_pose_inv_path = osp.join(self.hand_model_path, 'global_pose_inv.txt')
 
        self.joint_num = 22
        self.root_joint_idx = 21
        self.align_joint_idx = [8, 12, 16, 20, 21]
        self.non_rigid_joint_idx = [3,21]

        self.original_img_shape = (512, 334) # height, width 
        self.transform = transform
        
        # load template mesh things
        self.mesh = mesh.Mesh(self.obj_file_path) 
        self.mesh.load_skeleton(self.template_skeleton_path, self.joint_num)
        self.mesh.load_skinning_weight(self.template_skinning_weight_path) 
        self.mesh.load_local_pose(self.template_local_pose_path) 
        self.mesh.load_global_pose(self.template_global_pose_path) 
        self.mesh.load_global_pose_inv(self.template_global_pose_inv_path) 

        # camera load
        krt = load_krt(self.krt_path)
        self.all_cameras = krt.keys()
        self.selected_cameras = [x for x in self.all_cameras if x[:2] == "40"] # 40xx cameras: color cameras
        
        # compute view directions of each camera
        campos = {}
        camrot = {}
        focal = {}
        princpt = {}
        for cam in self.selected_cameras:
            campos[cam] = -np.dot(krt[cam]['extrin'][:3, :3].T, krt[cam]['extrin'][:3, 3]).astype(np.float32)
            camrot[cam] = np.array(krt[cam]['extrin'][:3, :3]).astype(np.float32)
            focal[cam] = krt[cam]['intrin'][:2, :2]
            focal[cam] = np.array([focal[cam][0][0], focal[cam][1][1]]).astype(np.float32)
            princpt[cam] = np.array(krt[cam]['intrin'][:2, 2]).astype(np.float32) 
        self.campos = campos
        self.camrot = camrot
        self.focal = focal
        self.princpt = princpt
      
        # get info for all frames
        self.framelist = []
        for seq_name in self.sequence_names:
            for cam in self.selected_cameras:
                img_path_list = glob(osp.join(self.img_path, seq_name, 'cam' + cam, '*.jpg'))
                for img_path in img_path_list:
                    frame_idx = int(img_path.split('/')[-1][5:-4])

                    # load joint 3D world coordinates
                    joint_path = osp.join(self.annot_path, 'keypoints', 'subject_' + cfg.subject, "keypoints{:04d}".format(frame_idx) + '.pts')
                    if osp.isfile(joint_path):
                        joint_coord, joint_valid = self.load_joint_coord(joint_path, 'right', self.mesh.skeleton) # only use right hand
                    else:
                        continue
       
                    joint = {'world_coord': joint_coord, 'valid': joint_valid}
                    frame = {'img_path': img_path, 'seq_name': seq_name, 'cam': cam, 'frame_idx': frame_idx, 'joint': joint}
                    self.framelist.append(frame)