Commit 8ed1945c authored by Pavel Rojtberg's avatar Pavel Rojtberg

calibrationMatrixValues: consider principalPoint in FOV computation

The FOV depends on the principal point location. Use formula of
viz::Camera.
parent 86959310
......@@ -3356,8 +3356,10 @@ void cv::calibrationMatrixValues( InputArray _cameraMatrix, Size imageSize,
}
/* Calculate fovx and fovy. */
fovx = 2 * atan(imageSize.width / (2 * K(0, 0))) * 180.0 / CV_PI;
fovy = 2 * atan(imageSize.height / (2 * K(1, 1))) * 180.0 / CV_PI;
fovx = atan2(K(0, 2), K(0, 0)) + atan2(imageSize.width - K(0, 2), K(0, 0));
fovy = atan2(K(1, 2), K(1, 1)) + atan2(imageSize.height - K(1, 2), K(1, 1));
fovx *= 180.0 / CV_PI;
fovy *= 180.0 / CV_PI;
/* Calculate focal length. */
focalLength = K(0, 0) / mx;
......
......@@ -875,8 +875,8 @@ void CV_CalibrationMatrixValuesTest::run(int)
ny = goodAspectRatio;
}
goodFovx = 2 * atan( imageSize.width / (2 * fx)) * 180.0 / CV_PI;
goodFovy = 2 * atan( imageSize.height / (2 * fy)) * 180.0 / CV_PI;
goodFovx = (atan2(cx, fx) + atan2(imageSize.width - cx, fx)) * 180.0 / CV_PI;
goodFovy = (atan2(cy, fy) + atan2(imageSize.height - cy, fy)) * 180.0 / CV_PI;
goodFocalLength = fx / nx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment