Muhammad Taqi Raza commited on
Commit
2caa0db
·
1 Parent(s): 419a65f

adding camera offsets values

Browse files
inference/v2v_data/demo.py CHANGED
@@ -588,84 +588,21 @@ class GetAnchorVideos:
588
  .to(opts.device)
589
  )
590
 
591
- camera_x = getattr(opts, "init_dx", 0.0)
592
- camera_y = getattr(opts, "init_dy", 0.0)
593
- camera_z = getattr(opts, "init_dz", 0.0)
594
-
595
- print("camera_x", camera_x)
596
- print("camera_y", camera_y)
597
- print("camera_z", camera_z)
598
-
599
  c2w_init = (
600
  torch.tensor(
601
  [
602
- [-1.0, 0.0, 0.0, camera_x],
603
- [0.0, 1.0, 0.0, camera_y],
604
- [0.0, 0.0, -1.0, camera_z],
605
  [0.0, 0.0, 0.0, 1.0],
606
  ]
607
  ).to(opts.device).unsqueeze(0)
608
  )
609
-
610
- theta = torch.deg2rad(torch.tensor(0)).to(opts.device)
611
- sin_value_x = torch.sin(theta)
612
- cos_value_x = torch.cos(theta)
613
- rot_mat_x = (
614
- torch.tensor(
615
- [
616
- [1, 0, 0, 0],
617
- [0, cos_value_x, -sin_value_x, 0],
618
- [0, sin_value_x, cos_value_x, 0],
619
- [0, 0, 0, 1],
620
- ]
621
- )
622
- .unsqueeze(0)
623
- .repeat(c2w_init.shape[0], 1, 1)
624
- .to(opts.device)
625
- )
626
-
627
- phi = torch.deg2rad(torch.tensor(0)).to(opts.device)
628
- sin_value_y = torch.sin(phi)
629
- cos_value_y = torch.cos(phi)
630
- rot_mat_y = (
631
- torch.tensor(
632
- [
633
- [cos_value_y, 0, sin_value_y, 0],
634
- [0, 1, 0, 0],
635
- [-sin_value_y, 0, cos_value_y, 0],
636
- [0, 0, 0, 1],
637
- ]
638
- )
639
- .unsqueeze(0)
640
- .repeat(c2w_init.shape[0], 1, 1)
641
- .to(opts.device)
642
- )
643
-
644
- c2w_init = torch.matmul(rot_mat_x, c2w_init)
645
- c2w_init = torch.matmul(rot_mat_y, c2w_init)
646
- # c2ws[:, 2, 3] -= r
647
- # if x is not None:
648
- # c2ws[:, 1, 3] += y
649
- # if y is not None:
650
- # c2ws[:, 0, 3] -= x
651
-
652
- # c2w_init = (
653
- # torch.tensor(
654
- # [
655
- # [-1.0, 0.0, 0.0, 0.0],
656
- # [0.0, 1.0, 0.0, 0.0],
657
- # [0.0, 0.0, -1.0, 0.0],
658
- # [0.0, 0.0, 0.0, 1.0],
659
- # ]
660
- # )
661
- # .to(opts.device)
662
- # .unsqueeze(0)
663
- # )
664
 
665
  if opts.camera == 'target':
666
  dtheta, dphi, dr, dx, dy = opts.target_pose
667
  poses = generate_traj_specified(
668
- c2w_init, dtheta, dphi, dr * radius, dx, dy, num_frames, opts.device
669
  )
670
  elif opts.camera == 'target_fast':
671
  dtheta, dphi, dr, dx, dy = opts.target_pose
 
588
  .to(opts.device)
589
  )
590
 
 
 
 
 
 
 
 
 
591
  c2w_init = (
592
  torch.tensor(
593
  [
594
+ [-1.0, 0.0, 0.0, 0],
595
+ [0.0, 1.0, 0.0, 0],
596
+ [0.0, 0.0, -1.0, 0],
597
  [0.0, 0.0, 0.0, 1.0],
598
  ]
599
  ).to(opts.device).unsqueeze(0)
600
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
 
602
  if opts.camera == 'target':
603
  dtheta, dphi, dr, dx, dy = opts.target_pose
604
  poses = generate_traj_specified(
605
+ c2w_init, dtheta, dphi, dr * radius, dx, dy, num_frames, opts.device, opts
606
  )
607
  elif opts.camera == 'target_fast':
608
  dtheta, dphi, dr, dx, dy = opts.target_pose
inference/v2v_data/models/utils.py CHANGED
@@ -180,14 +180,20 @@ def sphere2pose(c2ws_input, theta, phi, r, device, x=None, y=None):
180
  return c2ws
181
 
182
 
183
- def generate_traj_specified(c2ws_anchor, theta, phi, d_r, d_x, d_y, frame, device):
184
  # Initialize a camera.
 
 
 
 
 
185
  thetas = np.linspace(0, theta, frame)
186
  phis = np.linspace(0, phi, frame)
187
- rs = np.linspace(0, d_r, frame)
188
- xs = np.linspace(0, d_x, frame)
189
- ys = np.linspace(0, d_y, frame)
190
-
 
191
  c2ws_list = []
192
  for th, ph, r, x, y in zip(thetas, phis, rs, xs, ys):
193
  c2w_new = sphere2pose(
 
180
  return c2ws
181
 
182
 
183
+ def generate_traj_specified(c2ws_anchor, theta, phi, d_r, d_x, d_y, frame, device, opts):
184
  # Initialize a camera.
185
+
186
+ camera_x = getattr(opts, "init_dx", 0.0)
187
+ camera_y = getattr(opts, "init_dy", 0.0)
188
+ camera_z = getattr(opts, "init_dz", 0.0)
189
+
190
  thetas = np.linspace(0, theta, frame)
191
  phis = np.linspace(0, phi, frame)
192
+
193
+ rs = np.linspace(0, d_r, frame)+camera_z
194
+ xs = np.linspace(0, d_x, frame)+camera_x
195
+ ys = np.linspace(0, d_y, frame)+camera_y
196
+ # manipulate the above ones
197
  c2ws_list = []
198
  for th, ph, r, x, y in zip(thetas, phis, rs, xs, ys):
199
  c2w_new = sphere2pose(