MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / computeCenterAtOrigin

Function computeCenterAtOrigin

src/utils/sim3dNormalization.ts:19–39  ·  view source on GitHub ↗
(reconstruction: Reconstruction)

Source from the content-addressed store, hash-verified

17 * Uses median of camera positions for robustness to outliers.
18 */
19export function computeCenterAtOrigin(reconstruction: Reconstruction): Sim3d {
20 const positions: THREE.Vector3[] = [];
21
22 for (const image of reconstruction.images.values()) {
23 positions.push(getImageWorldPosition(image));
24 }
25
26 if (positions.length === 0) {
27 return identitySim3d();
28 }
29
30 const centerX = median(positions.map((p) => p.x));
31 const centerY = median(positions.map((p) => p.y));
32 const centerZ = median(positions.map((p) => p.z));
33
34 return {
35 scale: 1,
36 rotation: new THREE.Quaternion(),
37 translation: new THREE.Vector3(-centerX, -centerY, -centerZ),
38 };
39}
40
41/**
42 * Compute transform to normalize scale (fit scene to specified extent).

Callers 2

applyTransformPresetFunction · 0.85

Calls 4

getImageWorldPositionFunction · 0.90
medianFunction · 0.90
identitySim3dFunction · 0.70
valuesMethod · 0.65

Tested by

no test coverage detected