Recover a camera intrinsic matrix (K) from a corresponding lookup table (LUT) through numerical optimization.
- Load LUT from
.bin
files - Generate LUT from K
- Generate pixel-ray correspondences
- Formulate problem statement
- Implement naive solution
- LUT sanity check
- Random K generator
- Implement numerical solutions
- Optional: recover distortion coefficients
Certain AR/MR devices do not provide intrinsic values directly for their cameras. Instead, high-level functions exist to project 3D points to their corresponding 2D pixels and backproject 2D pixels to their corresponding rays (e.g. HoloLens2 Research Mode API has MapImagePointToCameraUnitPlane
and MapImagePointToCameraUnitPlane
).
Most popular computer vision libraries (e.g. OpenCV) require a 3x3 intrinsic matrix for their functions. Rewriting these functions to accomodate the high-level 2D-3D mapping functions from the aforementioned devices is an extremely tedious task.
We intend to recover these intrinsic parameters by sampling pixel-ray correspondences obtained from these high-level functions and use them to solve for the 4 intrinsic parameters
Ultimately, this problem can be formulated as two systems of linear equations
where
In theory, only 2 pixel-ray correspondences are needed to solve for all 4 intrinsic parameters. We may choose to use all pixel-ray correspondences from a LUT, resulting in two overdetermined systems of linear equations.
The first system of linear equations can be solved to obtain
Methods to solve for the intrinsic parameters can be categorized into either direct computation, or numerical optimization.
To use the solvers, your LUT must be a numpy array
from utils import pixAndRay
from solver import leastSquares
coords_2d, rays_3d = pixAndRay(lut)
K_approx = leastSquares(coords_2d, rays_3d)
A demo_lstsq.py
script is provided that solves 4 different LUTs using direct least-squares computation.
Given an overdetermined system of linear equations