fix field of view computation in setWindowSize

This commit is contained in:
ozantonkal 2013-08-05 16:06:02 +02:00
parent 119d97f1f6
commit f8ad3c0204

View File

@ -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<float>(window_size.width) / static_cast<float>(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;