( wasm: Pick<WasmReconstructionWrapper, 'getAllCameras' | 'getAllImageInfos'> )
| 103 | } |
| 104 | |
| 105 | export function buildWasmCameraImageMaps( |
| 106 | wasm: Pick<WasmReconstructionWrapper, 'getAllCameras' | 'getAllImageInfos'> |
| 107 | ): { cameras: Map<number, Camera>; images: Map<number, Image> } { |
| 108 | const cameras = new Map<number, Camera>(); |
| 109 | for (const camera of Object.values(wasm.getAllCameras())) { |
| 110 | cameras.set(camera.cameraId, { |
| 111 | cameraId: camera.cameraId, |
| 112 | modelId: parseCameraModelId(camera.modelId, `WASM camera ${camera.cameraId}`), |
| 113 | width: camera.width, |
| 114 | height: camera.height, |
| 115 | params: camera.params, |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | const images = new Map<number, Image>(); |
| 120 | for (const info of wasm.getAllImageInfos()) { |
| 121 | const q = info.quaternion ?? [1, 0, 0, 0]; |
| 122 | const t = info.translation ?? [0, 0, 0]; |
| 123 | images.set(info.imageId, { |
| 124 | imageId: info.imageId, |
| 125 | qvec: [q[0], q[1], q[2], q[3]], |
| 126 | tvec: [t[0], t[1], t[2]], |
| 127 | cameraId: info.cameraId, |
| 128 | name: info.name, |
| 129 | points2D: [], |
| 130 | }); |
| 131 | } |
| 132 | |
| 133 | return { cameras, images }; |
| 134 | } |
| 135 | |
| 136 | function isNodeColmapWasmFactory(value: unknown): value is NodeColmapWasmFactory { |
| 137 | return typeof value === 'function'; |
no test coverage detected