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

Function unprojectPoint

src/utils/cameraModelProjection.ts:54–65  ·  view source on GitHub ↗

* Unproject a pixel coordinate to undistorted pinhole-normalised coordinates * (X/Z, Y/Z) by delegating distortion removal to the canonical * `undistortNormalized` from `cameraUndistortion.ts`. * * Returns null when the ray falls outside the representable domain (e.g. a * fisheye ray past ~90°,

(
  camera: Camera,
  px: number,
  py: number
)

Source from the content-addressed store, hash-verified

52 * fisheye ray past ~90°, or a FOV ray past the tangent singularity).
53 */
54function unprojectPoint(
55 camera: Camera,
56 px: number,
57 py: number
58): { x: number; y: number } | null {
59 const i = getCameraIntrinsics(camera);
60 const xd = (px - i.cx) / i.fx;
61 const yd = (py - i.cy) / i.fy;
62 const result = undistortNormalized({ x: xd, y: yd }, i, camera.modelId);
63 if (!result.valid) return null;
64 return { x: result.x, y: result.y };
65}
66
67/**
68 * Project undistorted pinhole-normalised coordinates (X/Z, Y/Z) to pixel

Calls 2

getCameraIntrinsicsFunction · 0.90
undistortNormalizedFunction · 0.90

Tested by

no test coverage detected