| 62 | return camera_list |
| 63 | |
| 64 | def camera_to_JSON(id, camera : Camera): |
| 65 | Rt = np.zeros((4, 4)) |
| 66 | Rt[:3, :3] = camera.R.transpose() |
| 67 | Rt[:3, 3] = camera.T |
| 68 | Rt[3, 3] = 1.0 |
| 69 | |
| 70 | W2C = np.linalg.inv(Rt) |
| 71 | pos = W2C[:3, 3] |
| 72 | rot = W2C[:3, :3] |
| 73 | serializable_array_2d = [x.tolist() for x in rot] |
| 74 | # print(camera.FovX, camera.FovY, camera.height, camera.width, flush=True) |
| 75 | camera_entry = { |
| 76 | 'id' : id, |
| 77 | 'img_name' : camera.image_name, |
| 78 | 'width' : camera.width, |
| 79 | 'height' : camera.height, |
| 80 | 'position': pos.tolist(), |
| 81 | 'rotation': serializable_array_2d, |
| 82 | 'fy' : fov2focal(camera.FovY, camera.height), |
| 83 | 'fx' : fov2focal(camera.FovX, camera.width) |
| 84 | } |
| 85 | return camera_entry |
| 86 | |
| 87 | |