Advertisement
lamiastella

rg camera in SPMLIify-X

Jan 8th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. $ rg camera
  2. smplifyx/cmd_parser.py
  3. 101: parser.add_argument('--camera_type', type=str, default='persp',
  4. 103: help='The type of camera used')
  5. 168: help='Which joints to use for initializing the camera')
  6. 174: ' the initial depth of the camera. The format' +
  7. 236: ' z coordinate of the camera translation')
  8.  
  9. smplifyx/main.py
  10. 38:from camera import create_camera
  11. 123: # Create the camera object
  12. 125: camera = create_camera(focal_length_x=focal_length,
  13. 130: if hasattr(camera, 'rotation'):
  14. 131: camera.rotation.requires_grad = False
  15. 178: camera = camera.to(device=device)
  16. 247: camera=camera,
  17.  
  18. smplifyx/mesh_viewer.py
  19. 50: camera_pose = np.eye(4)
  20. 51: camera_pose[:3, 3] = np.array([0, 0, 3])
  21. 52: self.scene.add(pc, pose=camera_pose)
  22.  
  23. smplifyx/camera.py
  24. 35:def create_camera(camera_type='persp', **kwargs):
  25. 36: if camera_type.lower() == 'persp':
  26. 39: raise ValueError('Uknown camera type: {}'.format(camera_type))
  27. 54: # the camera matrix
  28. 97: camera_mat = torch.zeros([self.batch_size, 2, 2],
  29. 99: camera_mat[:, 0, 0] = self.focal_length_x
  30. 100: camera_mat[:, 1, 1] = self.focal_length_y
  31. 102: camera_transform = transform_mat(self.rotation,
  32. 111: [camera_transform, points_h])
  33. 115: img_points = torch.einsum('bki,bji->bjk', [camera_mat, img_points]) \
  34.  
  35. smplifyx/fitting.py
  36. 47: ''' Initializes the camera translation vector
  37. 57: the camera translation
  38. 59: The focal length of the camera
  39. 70: The vector with the estimated camera location
  40. 217: optimizer, body_model, camera=None,
  41. 246: total_loss = loss(body_model_output, camera=camera,
  42. 275: elif loss_type == 'camera_init':
  43. 365: def forward(self, body_model_output, camera, gt_joints, joints_conf,
  44. 369: projected_joints = camera(body_model_output.joints)
  45. 486: def forward(self, body_model_output, camera, gt_joints,
  46. 489: projected_joints = camera(body_model_output.joints)
  47. 501: camera.translation[:, 2] - self.trans_estimation[:, 2]).pow(2))
  48.  
  49. smplifyx/fit_single_frame.py
  50. 52: camera,
  51. 266: # The indices of the joints used for the initialization of the camera
  52. 276: camera_loss = fitting.create_loss('camera_init',
  53. 281: camera_loss.trans_estimation[:] = init_t
  54. 314: camera_loss.reset_loss_weights({'data_weight': data_weight})
  55. 327: # Update the value of the translation of the camera as well as
  56. 330: camera.translation[:] = init_t.view_as(camera.translation)
  57. 331: camera.center[:] = torch.tensor([W, H], dtype=dtype) * 0.5
  58. 333: # Re-enable gradient calculation for the camera translation
  59. 334: camera.translation.requires_grad = True
  60. 336: camera_opt_params = [camera.translation, body_model.global_orient]
  61. 338: camera_optimizer, camera_create_graph = optim_factory.create_optimizer(
  62. 339: camera_opt_params,
  63. 343: fit_camera = monitor.create_fitting_closure(
  64. 344: camera_optimizer, body_model, camera, gt_joints,
  65. 345: camera_loss, create_graph=camera_create_graph,
  66. 350: # Step 1: Optimize over the torso joints the camera translation
  67. 352: # of the camera and the initial pose of the body model.
  68. 353: camera_init_start = time.time()
  69. 354: cam_init_loss_val = monitor.run_fitting(camera_optimizer,
  70. 355: fit_camera,
  71. 356: camera_opt_params, body_model,
  72. 365: time.time() - camera_init_start))
  73. 427: camera=camera, gt_joints=gt_joints,
  74. 467: result = {'camera_' + str(key): val.detach().cpu().numpy()
  75. 468: for key, val in camera.named_parameters()}
  76. 524: camera_center = camera.center.detach().cpu().numpy().squeeze()
  77. 525: camera_transl = camera.translation.detach().cpu().numpy().squeeze()
  78. 528: camera_transl[0] *= -1.0
  79. 530: camera_pose = np.eye(4)
  80. 531: camera_pose[:3, 3] = camera_transl
  81. 533: camera = pyrender.camera.IntrinsicsCamera(
  82. 535: cx=camera_center[0], cy=camera_center[1])
  83. 536: scene.add(camera, pose=camera_pose)
  84. 4938/31772MB(smplifyx)
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement