fix field of view formula in camera class, implement get camera
This commit is contained in:
parent
f445f76213
commit
0bb89e767a
@ -192,7 +192,7 @@ void cv::viz::Camera2::setWindowSize(const Size &window_size)
|
||||
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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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)
|
||||
{
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
// 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.*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user