float aspect_ratio_new = window_size.width / window_size.height;
if (principal_point_[0] < 0.0f)
- fov_[0] = 2 * atan2(tan(fov_[0] * 0.5), aspect_ratio_new); // This assumes that the lens is symmetric!
+ fov_[0] = 2 * atan2(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;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
+void cv::viz::Viz3d::VizImpl::getCamera(viz::Camera2 &camera)
+{
+ vtkCamera& active_camera = *renderer_->GetActiveCamera();
+ camera.setFov(Vec2f(0.0, active_camera.GetViewAngle() * CV_PI / 180.0f));
+ camera.setClip(Vec2d(active_camera.GetClippingRange()));
+ camera.setWindowSize(Size(renderer_->GetRenderWindow()->GetSize()[0],
+ renderer_->GetRenderWindow()->GetSize()[1]));
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
{
vtkCamera& camera = *renderer_->GetActiveCamera ();
// and 'Camera' class itself with various constructors/fields
void setCamera(const Camera2 &camera);
+ void getCamera(Camera2 &camera);
void initCameraParameters (); /** \brief Initialize camera parameters with some default values. */
bool cameraParamsSet () const; /** \brief Checks whether the camera parameters were manually loaded from file.*/