Skip to content

Commit

Permalink
fix manual camera
Browse files Browse the repository at this point in the history
  • Loading branch information
Gengshan Yang committed May 30, 2024
1 parent ca75de1 commit f96d66a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions preprocess/scripts/manual_cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ def load_fig(track):

def caminfo_to_rotation(track):
caminfo = track.fig.layout.scene.camera
final_R = np.zeros((4, 4))
final_R[2, 3] = 3
final_R[3, 3] = 1
final_R = np.eye(4)
eye = np.asarray([caminfo.eye.x, caminfo.eye.y, caminfo.eye.z])
center = np.asarray([caminfo.center.x, caminfo.center.y, caminfo.center.z])
up = np.asarray([caminfo.up.x, caminfo.up.y, caminfo.up.z])
Expand All @@ -329,9 +327,18 @@ def caminfo_to_rotation(track):
s = np.cross(L, up)
s = s / np.linalg.norm(s)
u = np.cross(s, L)
cam_R = np.array([s, u, -L])
final_R[0:3, 0:3] = cam_R @ track.R
final_R[0:3, 0:3] = final_R[0:3, 0:3].T # field to camera
final_R[:3, :3] = np.array([s, u, -L]).T # camera x/y/z coordinate
final_R[:3, 3] = eye # camera center
final_R = np.linalg.inv(final_R) # object to camera

# user input adjustment
final_R[:3, :3] = final_R[:3, :3] @ track.R

# gl to cv camera coordinate
final_R[1:3, :] *= -1
# # gl to cv object coordinate
# final_R[:3,1:3] *= -1

# debug_format(cam_R @ track.R)

track.se3_dict[int(track.curr_frame)] = final_R.tolist()
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def run_extract_priors(seqname, outdir, obj_class_cam):
from preprocess.scripts.manual_cameras import manual_camera_interface

mesh_path = "database/mesh-templates/cat-pikachu-remeshed.obj"
manual_camera_interface(vidname, use_manual_segment, mesh_path)
manual_camera_interface(vidname, mesh_path)

# extract flow/depth/camera/etc
gpu_map(run_extract_priors, prior_args, gpus=gpulist)
Expand Down

0 comments on commit f96d66a

Please sign in to comment.