Ported camera calibration code.