From f96d66afedd008976fdfc18fb50b4984bb454195 Mon Sep 17 00:00:00 2001 From: Gengshan Yang Date: Thu, 30 May 2024 03:07:25 -0400 Subject: [PATCH] fix manual camera --- preprocess/scripts/manual_cameras.py | 19 +++++++++++++------ scripts/run_preprocess.py | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/preprocess/scripts/manual_cameras.py b/preprocess/scripts/manual_cameras.py index 53451e9..ea4e71c 100644 --- a/preprocess/scripts/manual_cameras.py +++ b/preprocess/scripts/manual_cameras.py @@ -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]) @@ -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() diff --git a/scripts/run_preprocess.py b/scripts/run_preprocess.py index b06ba07..aa5f339 100644 --- a/scripts/run_preprocess.py +++ b/scripts/run_preprocess.py @@ -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)