Пример #1
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

    pix = []
    for n, i in enumerate(b['mask_image']):
        plt.axis('off')
        plt.imshow(i[0], cmap='gray')
        plt.show()

    from utils.smpl_torch.pytorch.smpl_layer import SMPL_Layer
    from utils.smpl_torch.display_utils import Drawer
    from utils.trans_numpy_torch import numpy_to_tensor_float, tensor_to_numpy

    from utils.conversion_SMPL_h36m_torch import from_smpl_to_h36m_world_torch,project_vertices_onto_mask
    cuda = False
#plt.show()



#######################################################################
#test cropping
#######################################################################
from utils.utils_H36M.transformations import get_patch_image,transform_2d_joints
from utils.utils_H36M.transformations import world_to_pixel,world_to_camera
from utils.utils_H36M.transformations_torch import world_to_camera_batch, camera_to_pixels_batch, transform_2d_joints_batch
b=Drawer()
joints_world=sample_metadata['joint_world'][6].astype(np.float32)
joint_cam=world_to_camera(joints_world, 17, sample_metadata['R'].astype(np.float32), sample_metadata['T'].astype(np.float32))
f=plt.figure()
f=b.pose_3d(joint_cam, plot = True, fig = f,  azim=-90, elev=-180)
joints_world_torch = numpy_to_tensor_float(joints_world.reshape(1, 17, 3))
R_torch = numpy_to_tensor_float(sample_metadata['R'].astype(np.float32).reshape(1, 3, 3))
T_torch =numpy_to_tensor_float(sample_metadata['T'].astype(np.float32).reshape(1, 1, 3))
f_torch = numpy_to_tensor_float(sample_metadata['f'].astype(np.float32).reshape(1, 1, 2))
c_torch =numpy_to_tensor_float(sample_metadata['c'].astype(np.float32).reshape(1, 1, 2))
joints_cam_torch = world_to_camera_batch(joints_world_torch,17,R_torch,T_torch)
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'],