diff --git a/modules/viz/src/types.cpp b/modules/viz/src/types.cpp index a7ec893cf9..9de385ce0f 100644 --- a/modules/viz/src/types.cpp +++ b/modules/viz/src/types.cpp @@ -189,10 +189,10 @@ void cv::viz::Camera::setWindowSize(const Size &window_size) // Vertical field of view is fixed! // Horizontal field of view is expandable based on the aspect ratio - float aspect_ratio_new = window_size.width / window_size.height; + float aspect_ratio_new = static_cast(window_size.width) / static_cast(window_size.height); if (principal_point_[0] < 0.0f) - fov_[0] = 2 * atan2(tan(fov_[1] * 0.5), aspect_ratio_new); // This assumes that the lens is symmetric! + fov_[0] = 2.f * atan(tan(fov_[1] * 0.5) * aspect_ratio_new); // This assumes that the lens is symmetric! else fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0])) * 180 / CV_PI;