Skip to content

Commit

Permalink
camera utils
Browse files Browse the repository at this point in the history
  • Loading branch information
goulustis committed Aug 22, 2024
1 parent 6c0e371 commit 31911a4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions camera_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,34 @@ def make_camera_json(ext_mtx, intr_mtx, dist, img_size):
}

return new_camera

def create_interpolated_cams(interp_ts, ctrl_ts, ctrl_extrns):
"""
input:
interp_ts (np.array): ts to be interpolated
ctrl_ts (np.array): control point times
ctrl_extrns (np.array): control point extrinsics
returns:
ecams_int (np.array): interpolated extrinsic positions
"""

def split_extrnx(w2cs):
Rs = w2cs[:,:3,:3]
ts = w2cs[:,:3, 3]
return Rs, ts

Rs, ts = split_extrnx(ctrl_extrns)
cam_spline = CameraSpline(ctrl_ts, Rs, ts)
# cam_spline = LanczosSpline(triggers, Rs, ts)
int_ts, int_Rs = cam_spline.interpolate(interp_ts)

if len(int_ts.shape) == 2:
int_ts = int_ts[..., None]

int_cams = np.concatenate([int_Rs, int_ts], axis=-1)
bot = np.zeros((4,))
bot[-1] = 1
bot = bot[None, None]
int_cams = np.concatenate([int_cams, np.concatenate([bot]*len(int_cams))], axis = -2)
return int_cams

0 comments on commit 31911a4

Please sign in to comment.