@thethingteam/colmap-wasm
v0.1.0
Published
COLMAP binary/text file parser compiled to WASM
Maintainers
Readme
@thethingteam/colmap-wasm
Parse COLMAP binary and text reconstruction files directly in the browser using WebAssembly.
Install
pnpm add @thethingteam/colmap-wasmUsage
import { parseColmap } from '@thethingteam/colmap-wasm';
const [camBuf, imgBuf, ptsBuf] = await Promise.all([
fetch('/path/to/cameras.bin').then(r => r.arrayBuffer()),
fetch('/path/to/images.bin').then(r => r.arrayBuffer()),
fetch('/path/to/points3D.bin').then(r => r.arrayBuffer()),
]);
const { cameras, images, points3d } = await parseColmap({
cameras: camBuf,
images: imgBuf,
points3d: ptsBuf,
});Accepts ArrayBuffer (binary .bin) or string (text .txt) for each file.
API
parseColmap({ cameras, images, points3d? })→ColmapResultparseCameras(data)→Camera[]parseImages(data)→Image[]parsePoints3D(data)→Point3D[]init(wasmUrl?)— optional: pre-load WASM
Types
interface Camera {
id: number;
model: string; // e.g. 'PINHOLE', 'SIMPLE_RADIAL'
width: number;
height: number;
params: number[]; // length depends on model
}
interface Image {
id: number;
qvec: [number, number, number, number]; // quaternion [w, x, y, z]
tvec: [number, number, number];
cameraId: number;
name: string;
}
interface Point3D {
id: number;
xyz: [number, number, number];
rgb: [number, number, number];
error: number;
}Development
Prerequisites: Rust, wasm-pack, Node.js 20+, pnpm
# Clone and install
git clone <repo>
cd colmap-wasm
pnpm install # installs JS deps (run after wasm-pack build)Build
# Build WASM + JS (full)
pnpm run build:all
# Individually
pnpm run build:wasm # wasm-pack build --target bundler → pkg/
pnpm run build:js # vite build → dist/Test
# All tests (Rust + JS)
pnpm test
# Rust unit tests only
pnpm run test:rust # cargo test
# JS integration tests only
pnpm run test:js # vitest runCargo (Rust only)
cargo test # run all Rust tests
cargo test binary::cameras # run a specific module's tests
cargo check # type-check without building
cargo build # native build (not WASM)
wasm-pack build --target bundler # WASM build → pkg/License
MIT
