({
camerasFile,
imagesFile,
points3DFile,
rigsFile,
framesFile,
parsers = defaultParsers,
addNotification,
log = appLogger.info,
}: ParseColmapFilesOptions)
| 60 | }; |
| 61 | |
| 62 | export async function parseColmapFiles({ |
| 63 | camerasFile, |
| 64 | imagesFile, |
| 65 | points3DFile, |
| 66 | rigsFile, |
| 67 | framesFile, |
| 68 | parsers = defaultParsers, |
| 69 | addNotification, |
| 70 | log = appLogger.info, |
| 71 | }: ParseColmapFilesOptions): Promise<ColmapParseResult> { |
| 72 | log('[Parser] Attempting WASM parser (memory-optimized)...'); |
| 73 | const wasmResult = await parsers.parseWithWasm( |
| 74 | camerasFile, |
| 75 | imagesFile, |
| 76 | points3DFile, |
| 77 | rigsFile, |
| 78 | framesFile |
| 79 | ); |
| 80 | |
| 81 | if (wasmResult) { |
| 82 | addNotification( |
| 83 | 'info', |
| 84 | `Loaded ${wasmResult.wasmWrapper.pointCount.toLocaleString()} points`, |
| 85 | 5000 |
| 86 | ); |
| 87 | |
| 88 | return { |
| 89 | cameras: wasmResult.cameras, |
| 90 | images: wasmResult.images, |
| 91 | wasmRigData: wasmResult.rigData, |
| 92 | wasmWrapper: wasmResult.wasmWrapper, |
| 93 | usedWasmPath: true, |
| 94 | }; |
| 95 | } |
| 96 | |
| 97 | log('[Parser] WASM failed, falling back to JS parser (without 2D points)'); |
| 98 | const useLiteImages = imagesFile.name.endsWith('.bin'); |
| 99 | |
| 100 | // Unknown-model cameras in cameras.txt are skipped (partial loads stay |
| 101 | // useful); collect them so we can surface a single aggregate notification. |
| 102 | const skippedCameras: SkippedCameraRecord[] = []; |
| 103 | |
| 104 | const [cameras, images, points3D] = await Promise.all([ |
| 105 | camerasFile.name.endsWith('.bin') |
| 106 | ? camerasFile.arrayBuffer().then(parsers.parseCamerasBinary) |
| 107 | : camerasFile.text().then(text => |
| 108 | parsers.parseCamerasText(text, { onSkip: record => skippedCameras.push(record) }) |
| 109 | ), |
| 110 | imagesFile.name.endsWith('.bin') |
| 111 | ? imagesFile.arrayBuffer().then(buf => parsers.parseImagesBinary(buf, true)) |
| 112 | : imagesFile.text().then(parsers.parseImagesText), |
| 113 | points3DFile.name.endsWith('.bin') |
| 114 | ? points3DFile.arrayBuffer().then(parsers.parsePoints3DBinary) |
| 115 | : points3DFile.name.toLowerCase().endsWith('.ply') |
| 116 | ? points3DFile.arrayBuffer().then(parsers.parsePointCloudPlyBuffer) |
| 117 | : points3DFile.text().then(parsers.parsePoints3DText), |
| 118 | ]); |
| 119 |
no outgoing calls
no test coverage detected