def __getitem__(self, idx): subpath, file_num = self.get_subpath_and_file_num(idx) depth_filepath = self.root_folder + self.video_folder + subpath + \ self.depth_folder + 'depth_' + \ file_num + '.' + self.depth_fileext depth_image = fpa_io.read_depth_img(depth_filepath) joints_filepath = self.root_folder + self.hand_pose_folder + \ subpath + 'skeleton.txt' hand_joints = fpa_io.read_action_joints_sequence(joints_filepath)[int( file_num)] _, crop_coords = self.get_cropped_depth_img(depth_image, hand_joints) crop_coords_numpy = np.zeros((2, 2)) crop_coords_numpy[0, 0] = crop_coords[0] crop_coords_numpy[0, 1] = crop_coords[1] crop_coords_numpy[1, 0] = crop_coords[2] crop_coords_numpy[1, 1] = crop_coords[3] corner_heatmap1 = conv.color_space_label_to_heatmap( crop_coords_numpy[0, :], heatmap_res=self.orig_img_res, orig_img_res=self.orig_img_res) #print(np.unravel_index(np.argmax(corner_heatmap1), corner_heatmap1.shape)) corner_heatmap2 = conv.color_space_label_to_heatmap( crop_coords_numpy[1, :], heatmap_res=self.orig_img_res, orig_img_res=self.orig_img_res) corner_heatmaps = np.stack((corner_heatmap1, corner_heatmap2)) corner_heatmaps = torch.from_numpy(corner_heatmaps).float() return data_image, corner_heatmaps
def read_depth_img(self, subpath, file_num): depth_filepath = self.root_folder + self.video_folder + subpath + \ self.depth_folder + 'depth_' + \ file_num + '.' + self.depth_fileext return fpa_io.read_depth_img(depth_filepath)
gt_folder = 'Hand_pose_annotation_v1' data_folder = 'video_files' subject = 'Subject_1' action = 'put_tea_bag' sequence = '4' gt_filepath = '/'.join([dataset_root_folder, gt_folder, subject, action, sequence, 'skeleton.txt']) curr_data_folder = '/'.join([dataset_root_folder, data_folder, subject, action, sequence]) gt_skeletons = fpa_io.read_action_joints_sequence(gt_filepath) fig = visualize.create_fig() for i in range(99): if i < 10: frame_num = '000' + str(i) else: frame_num = '00' + str(i) joints = gt_skeletons[i, :].reshape((21, 3)) color_filepath = '/'.join([curr_data_folder, 'color', 'color_' + frame_num + '.jpeg']) depth_filepath = '/'.join([curr_data_folder, 'depth', 'depth_' + frame_num + '.png']) depth_img = fpa_io.read_depth_img(depth_filepath) joints_uv = cam.joints_depth2color(joints, cam.fpa_depth_intrinsics) visualize.plot_joints_from_colorspace(joints_colorspace=joints_uv, data=depth_img, fig=fig, title='/'.join([subject, action, sequence])) visualize.pause(0.001) visualize.clear_plot() visualize.show()