fix field of view formula in camera class, implement get camera
This commit is contained in:
@@ -192,7 +192,7 @@ void cv::viz::Camera2::setWindowSize(const Size &window_size)
|
|||||||
float aspect_ratio_new = window_size.width / window_size.height;
|
float aspect_ratio_new = window_size.width / window_size.height;
|
||||||
|
|
||||||
if (principal_point_[0] < 0.0f)
|
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
|
else
|
||||||
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0])) * 180 / CV_PI;
|
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0])) * 180 / CV_PI;
|
||||||
}
|
}
|
||||||
|
@@ -603,6 +603,16 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera2 &camera)
|
|||||||
window_->SetSize (static_cast<int> (camera.getWindowSize().width), static_cast<int> (camera.getWindowSize().height));
|
window_->SetSize (static_cast<int> (camera.getWindowSize().width), static_cast<int> (camera.getWindowSize().height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
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)
|
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
|
@@ -111,6 +111,7 @@ public:
|
|||||||
// and 'Camera' class itself with various constructors/fields
|
// and 'Camera' class itself with various constructors/fields
|
||||||
|
|
||||||
void setCamera(const Camera2 &camera);
|
void setCamera(const Camera2 &camera);
|
||||||
|
void getCamera(Camera2 &camera);
|
||||||
|
|
||||||
void initCameraParameters (); /** \brief Initialize camera parameters with some default values. */
|
void initCameraParameters (); /** \brief Initialize camera parameters with some default values. */
|
||||||
bool cameraParamsSet () const; /** \brief Checks whether the camera parameters were manually loaded from file.*/
|
bool cameraParamsSet () const; /** \brief Checks whether the camera parameters were manually loaded from file.*/
|
||||||
|
Reference in New Issue
Block a user