* 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 )
| 52 | * fisheye ray past ~90°, or a FOV ray past the tangent singularity). |
| 53 | */ |
| 54 | function 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 |
no test coverage detected