initial setCamera implementation
This commit is contained in:
@@ -39,6 +39,7 @@ namespace cv
|
|||||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
|
||||||
|
void setCamera(const Camera2 &camera);
|
||||||
Affine3f getViewerPose();
|
Affine3f getViewerPose();
|
||||||
void setViewerPose(const Affine3f &pose);
|
void setViewerPose(const Affine3f &pose);
|
||||||
|
|
||||||
|
@@ -167,7 +167,7 @@ cv::viz::Camera2::Camera2(const Vec2f &fov, const Size &window_size)
|
|||||||
setClip(Vec2d(0.01, 1000.01)); // Default clipping
|
setClip(Vec2d(0.01, 1000.01)); // Default clipping
|
||||||
window_size_ = window_size;
|
window_size_ = window_size;
|
||||||
fov_ = fov;
|
fov_ = fov;
|
||||||
principal_point_ = Vec2f(-1.0f, -1.0f); // Symmetric lens
|
principal_point_ = Vec2f(-1.0f, -1.0f); // Default symmetric lens
|
||||||
focal_ = Vec2f(-1.0f, -1.0f);
|
focal_ = Vec2f(-1.0f, -1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,5 +46,6 @@ void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose) { imp
|
|||||||
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose) { impl_->updateWidgetPose(id, pose); }
|
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose) { impl_->updateWidgetPose(id, pose); }
|
||||||
cv::Affine3f cv::viz::Viz3d::getWidgetPose(const String &id) const { return impl_->getWidgetPose(id); }
|
cv::Affine3f cv::viz::Viz3d::getWidgetPose(const String &id) const { return impl_->getWidgetPose(id); }
|
||||||
|
|
||||||
|
void cv::viz::Viz3d::setCamera(const Camera2 &camera) { impl_->setCamera(camera); }
|
||||||
void cv::viz::Viz3d::setViewerPose(const Affine3f &pose) { impl_->setViewerPose(pose); }
|
void cv::viz::Viz3d::setViewerPose(const Affine3f &pose) { impl_->setViewerPose(pose); }
|
||||||
cv::Affine3f cv::viz::Viz3d::getViewerPose() { return impl_->getViewerPose(); }
|
cv::Affine3f cv::viz::Viz3d::getViewerPose() { return impl_->getViewerPose(); }
|
||||||
|
@@ -591,6 +591,18 @@ void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
|
|||||||
camera.window_pos = cv::Vec2d::all(0);
|
camera.window_pos = cv::Vec2d::all(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void cv::viz::Viz3d::VizImpl::setCamera(const Camera2 &camera)
|
||||||
|
{
|
||||||
|
vtkCamera& active_camera = *renderer_->GetActiveCamera();
|
||||||
|
|
||||||
|
// Set the intrinsic parameters of the camera
|
||||||
|
active_camera.SetUseHorizontalViewAngle (0); // Horizontal view angle is set based on the window size
|
||||||
|
active_camera.SetViewAngle (camera.getFov()[1] * 180.0f / CV_PI);
|
||||||
|
active_camera.SetClippingRange (camera.getClip()[0], camera.getClip()[1]);
|
||||||
|
window_->SetSize (static_cast<int> (camera.getWindowSize().width), static_cast<int> (camera.getWindowSize().height));
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
|
@@ -109,6 +109,8 @@ public:
|
|||||||
// ////////////////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////////////////
|
||||||
// All camera methods to refactor into set/getViewwerPose, setCamera()
|
// All camera methods to refactor into set/getViewwerPose, setCamera()
|
||||||
// and 'Camera' class itself with various constructors/fields
|
// and 'Camera' class itself with various constructors/fields
|
||||||
|
|
||||||
|
void setCamera(const 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