mirror of
https://github.com/graphdeco-inria/gaussian-splatting
synced 2024-11-22 08:18:17 +00:00
Fix conversion from Blender to COLMAP coords in NeRF camera import. (#111)
Co-authored-by: Jakub Červený <jakub.cerveny@melowntech.com>
This commit is contained in:
parent
073775efbd
commit
0f125cbd5f
@ -187,10 +187,15 @@ def readCamerasFromTransforms(path, transformsfile, white_background, extension=
|
|||||||
for idx, frame in enumerate(frames):
|
for idx, frame in enumerate(frames):
|
||||||
cam_name = os.path.join(path, frame["file_path"] + extension)
|
cam_name = os.path.join(path, frame["file_path"] + extension)
|
||||||
|
|
||||||
matrix = np.linalg.inv(np.array(frame["transform_matrix"]))
|
# NeRF 'transform_matrix' is a camera-to-world transform
|
||||||
R = -np.transpose(matrix[:3,:3])
|
c2w = np.array(frame["transform_matrix"])
|
||||||
R[:,0] = -R[:,0]
|
# change from OpenGL/Blender camera axes (Y up, Z back) to COLMAP (Y down, Z forward)
|
||||||
T = -matrix[:3, 3]
|
c2w[:3, 1:3] *= -1
|
||||||
|
|
||||||
|
# get the world-to-camera transform and set R, T
|
||||||
|
w2c = np.linalg.inv(c2w)
|
||||||
|
R = np.transpose(w2c[:3,:3]) # R is stored transposed due to 'glm' in CUDA code
|
||||||
|
T = w2c[:3, 3]
|
||||||
|
|
||||||
image_path = os.path.join(path, cam_name)
|
image_path = os.path.join(path, cam_name)
|
||||||
image_name = Path(cam_name).stem
|
image_name = Path(cam_name).stem
|
||||||
|
Loading…
Reference in New Issue
Block a user