def extract_all_info(
        self,
        metadata,
        background,
        s,
        act,
        subact,
        ca,
        fno,
    ):

        rotation_angle = None
        im, joints_world, R, T, f, c = self.extract_info(
            metadata, s, act, subact, ca, fno)
        bbpx = bounding_box_pixel(joints_world, H36M_CONF.joints.root_idx, R,
                                  T, f, c)
        im, trans = self.crop_img(im, bbpx, rotation_angle)
        background, _ = self.crop_img(background, bbpx, rotation_angle)
        R_centre = cam_pointing_root(joints_world, H36M_CONF.joints.root_idx,
                                     H36M_CONF.joints.number, R, T)
        if rotation_angle is not None:
            R_centre = np.dot(rotate_z(rotation_angle), R_centre)
        R_pointing_centre = np.dot(R_centre, R)
        #self.testing(joints_world, im, background, R, T, f, c, trans)

        return im, R_pointing_centre, background, joints_world
    def extract_image_info(self, s, act, subact, ca, fno, rotation_angle=None):

        metadata = self.all_metadata[s][act][subact][ca]
        im, joints_world, R, T, f, c= self.extract_info(metadata, s, act, subact, ca, fno)
        bbpx = bounding_box_pixel(joints_world, H36M_CONF.joints.root_idx, R, T, f,c)
        im, trans = self.crop_img(im, bbpx, rotation_angle)
        R_centre = cam_pointing_root(joints_world, H36M_CONF.joints.root_idx, H36M_CONF.joints.number, R, T)
        if rotation_angle is not None:
            R_centre = np.dot(rotate_z(rotation_angle), R_centre)
        R_pointing_centre = np.dot( R_centre, R)
        return im, joints_world, R_pointing_centre
 def extract_masks_info(self,s,act,subact,ca,fno, rotation_angle=None):
     metadata = self.all_metadata[s][act][subact][ca]
     im, joints_world, R, T, f, c = self.extract_mask_info(metadata, s, act, subact, ca, fno)
     bbpx = bounding_box_pixel(joints_world, H36M_CONF.joints.root_idx, R, T, f, c)
     im, trans = self.crop_img(im, bbpx, rotation_angle)
     return im, R, T, f, c, trans
Ejemplo n.º 4
0


if __name__ == '__main__':
    a = SMPL_Data_Load(2000,index_file_content=['s'],
                 index_file_list=[[6]],)

    from utils.utils_H36M.visualise import Drawer
    import matplotlib.pyplot as plt

    d = Drawer()
    im = a.load_image(6, 2, 2, 2, 371)
    #im = np.transpose(im, axes=[1, 2, 0])
    metadata = a.all_metadata[6][2][2][2]
    im, joints_world, R, T, f, c = a.extract_info(metadata, 6, 2, 2, 2, 371)
    bbpx = bounding_box_pixel(joints_world, H36M_CONF.joints.root_idx, R, T, f, c)
    im, trans = a.crop_img(im, bbpx, None)
    im2 = im.copy()
    im2[:, :, 0] = im[:, :, 2]
    im2[:, :, 2] = im[:, :, 0]
    plt.axis('off')
    plt.imshow(im2)
    plt.title("ssksk")
    plt.show()
    #[6.   2.   1.   1. 101.   3.]
    #[6. 2. 2. 1. 1. 4.]
    #[6.   2.   2.   2. 371.   4.]
    fig = plt.figure()
    d.pose_3d(b['joints_im'], plot=True, fig=fig, azim=-90, elev=0)
    plt.show()
    from utils.utils_H36M.transformations import world_to_pixel, transform_2d_joints
joints_pix_torch = camera_to_pixels_batch(joints_cam_torch,17, f_torch, c_torch)


joint_px=world_to_pixel(
    joints_world,
    H36M_CONF.joints.number,
    sample_metadata['R'],
    sample_metadata['T'],
    sample_metadata['f'],
    sample_metadata['c']
)




bbpx_px=bounding_box_pixel(joints_world, 0, sample_metadata['R'], sample_metadata['T'], sample_metadata['f'], sample_metadata['c'])
imwarped,trans = get_patch_image(img, bbpx_px, (256,256), 0)#np.pi/4) # in degrees rotation around z axis
trans_torch = numpy_to_tensor_float(trans.reshape(1, 2, 3))
trsft_joints_torch = transform_2d_joints_batch(joints_pix_torch, trans_torch)
trsf_joints = transform_2d_joints(joint_px, trans)
trsft_joints_torch = tensor_to_numpy(trsft_joints_torch).reshape(17,2)

plt.figure()
imwarped=c.get_image(imwarped)
plt.imshow(imwarped)
plt.axis("off")
plt.show()