MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / camera_to_JSON

Function camera_to_JSON

examples/helper/STG/camera_utils.py:285–305  ·  view source on GitHub ↗
(id, camera : Camera)

Source from the content-addressed store, hash-verified

283 return camera_list
284
285def camera_to_JSON(id, camera : Camera):
286 Rt = np.zeros((4, 4))
287 Rt[:3, :3] = camera.R.transpose()
288 Rt[:3, 3] = camera.T
289 Rt[3, 3] = 1.0
290
291 W2C = np.linalg.inv(Rt)
292 pos = W2C[:3, 3]
293 rot = W2C[:3, :3]
294 serializable_array_2d = [x.tolist() for x in rot]
295 camera_entry = {
296 'id' : id,
297 'img_name' : camera.image_name,
298 'width' : camera.width,
299 'height' : camera.height,
300 'position': pos.tolist(),
301 'rotation': serializable_array_2d,
302 'fy' : fov2focal(camera.FovY, camera.height),
303 'fx' : fov2focal(camera.FovX, camera.width)
304 }
305 return camera_entry
306
307
308

Callers

nothing calls this directly

Calls 1

fov2focalFunction · 0.85

Tested by

no test coverage detected