Skip to content

transforms.json to base_cam.json #490

Answered by 0xiNach
kajc10 asked this question in Q&A
Apr 18, 2022 · 3 comments · 10 replies
Discussion options

You must be logged in to vote

Hope this helps!

import json
import numpy as np
from scipy.spatial.transform import Rotation as R

def nerf_to_ngp(xf):
    mat = np.copy(xf)
    mat = mat[:-1,:]
    mat[:,1] *= -1 # flip axis
    mat[:,2] *= -1
    mat[:,3] *= 0.33 #scale
    mat[:,3] += [0.5, 0.5, 0.5] #offset
    
    mat = mat[[1,2,0], :] # swap axis
    
    rm = R.from_matrix(mat[:,:3]) 
    
    # quaternion (x, y, z, w) and translation
    return rm.as_quat(), mat[:,3] + 0.025

def smooth_camera_path(path_to_transforms, ):
    out = {"path":[], "time":1.0}
    with open(path_to_transforms + '/transforms.json') as f:
        data = json.load(f)
    
    n_frames = len(data['frames'])
    
    xforms = {}
    for i…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Tom94
Comment options

@kajc10
Comment options

Comment options

You must be logged in to vote
8 replies
@PascalHbr
Comment options

@0xiNach
Comment options

@SummerpanKing
Comment options

@0xiNach
Comment options

@SummerpanKing
Comment options

Answer selected by kajc10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants