MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / camera_to_JSON

Function camera_to_JSON

utils/camera_utils.py:79–99  ·  view source on GitHub ↗
(id, camera : Camera)

Source from the content-addressed store, hash-verified

77 return camera_list
78
79def camera_to_JSON(id, camera : Camera):
80 Rt = np.zeros((4, 4))
81 Rt[:3, :3] = camera.R.transpose()
82 Rt[:3, 3] = camera.T
83 Rt[3, 3] = 1.0
84
85 W2C = np.linalg.inv(Rt)
86 pos = W2C[:3, 3]
87 rot = W2C[:3, :3]
88 serializable_array_2d = [x.tolist() for x in rot]
89 camera_entry = {
90 'id' : id,
91 'img_name' : camera.image_name,
92 'width' : camera.width,
93 'height' : camera.height,
94 'position': pos.tolist(),
95 'rotation': serializable_array_2d,
96 'fy' : fov2focal(camera.FovY, camera.height),
97 'fx' : fov2focal(camera.FovX, camera.width)
98 }
99 return camera_entry

Callers 1

__init__Method · 0.90

Calls 1

fov2focalFunction · 0.90

Tested by

no test coverage detected