/////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::initCameraParameters ()
{
- Camera camera_temp;
- // Set default camera parameters to something meaningful
- camera_temp.clip = Vec2d(0.01, 1000.01);
-
- // Look straight along the z-axis
- camera_temp.focal = Vec3d(0.0, 0.0, 1.0);
-
- // Position the camera at the origin
- camera_temp.pos = Vec3d(0.0, 0.0, 0.0);
-
- // Set the up-vector of the camera to be the y-axis
- camera_temp.view_up = Vec3d(0.0, 1.0, 0.0);
-
- // Set the camera field of view to about
- camera_temp.fovy = 0.8575;
- camera_temp.window_size = Vec2i(window_->GetScreenSize()) / 2;
- camera_temp.window_pos = Vec2i(0, 0);
-
- setCameraParameters (camera_temp);
+ Vec2i window_size(window_->GetScreenSize());
+ window_size /= 2;
+
+ Camera2 camera_temp(Vec2f(0.0,0.8575), Size(window_size[0], window_size[1]));
+ setCamera(camera_temp);
+ setViewerPose(makeCameraPose(Vec3f(0.0f,0.0f,0.0f), Vec3f(0.0f, 0.0f, 1.0f), Vec3f(0.0f, 1.0f, 0.0f)));
}
/////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
-{
- vtkCamera* active_camera = renderer_->GetActiveCamera ();
-
- camera.pos = cv::Vec3d(active_camera->GetPosition());
- camera.focal = cv::Vec3d(active_camera->GetFocalPoint());
- camera.clip = cv::Vec2d(active_camera->GetClippingRange());
- camera.view_up = cv::Vec3d(active_camera->GetViewUp());
-
- camera.fovy = active_camera->GetViewAngle()/ 180.0 * CV_PI;
- camera.window_size = cv::Vec2i(renderer_->GetRenderWindow()->GetSize());
- camera.window_pos = cv::Vec2d::all(0);
-}
+// void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
+// {
+// vtkCamera* active_camera = renderer_->GetActiveCamera ();
+//
+// camera.pos = cv::Vec3d(active_camera->GetPosition());
+// camera.focal = cv::Vec3d(active_camera->GetFocalPoint());
+// camera.clip = cv::Vec2d(active_camera->GetClippingRange());
+// camera.view_up = cv::Vec3d(active_camera->GetViewUp());
+//
+// camera.fovy = active_camera->GetViewAngle()/ 180.0 * CV_PI;
+// camera.window_size = cv::Vec2i(renderer_->GetRenderWindow()->GetSize());
+// camera.window_pos = cv::Vec2d::all(0);
+// }
/////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setCamera(const Camera2 &camera)
}
/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up)
-{
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetPosition (pos[0], pos[1], pos[2]);
- cam->SetFocalPoint (view[0], view[1], view[2]);
- cam->SetViewUp (up[0], up[1], up[2]);
- renderer_->Render ();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z)
-{
- //rens_->InitTraversal ();
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetPosition (pos_x, pos_y, pos_z);
- cam->SetViewUp (up_x, up_y, up_z);
- renderer_->Render ();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraParameters (const cv::Matx33f& intrinsics, const cv::Affine3f& extrinsics)
-{
- // Position = extrinsic translation
- cv::Vec3f pos_vec = extrinsics.translation();
-
-
- // Rotate the view vector
- cv::Matx33f rotation = extrinsics.rotation();
- cv::Vec3f y_axis (0.f, 1.f, 0.f);
- cv::Vec3f up_vec (rotation * y_axis);
-
- // Compute the new focal point
- cv::Vec3f z_axis (0.f, 0.f, 1.f);
- cv::Vec3f focal_vec = pos_vec + rotation * z_axis;
-
- // Get the width and height of the image - assume the calibrated centers are at the center of the image
- Eigen::Vector2i window_size;
- window_size[0] = static_cast<int> (intrinsics(0, 2));
- window_size[1] = static_cast<int> (intrinsics(1, 2));
-
- // Compute the vertical field of view based on the focal length and image heigh
- double fovy = 2 * atan (window_size[1] / (2. * intrinsics (1, 1))) * 180.0 / M_PI;
-
- //rens_->InitTraversal ();
-
-
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetPosition (pos_vec[0], pos_vec[1], pos_vec[2]);
- cam->SetFocalPoint (focal_vec[0], focal_vec[1], focal_vec[2]);
- cam->SetViewUp (up_vec[0], up_vec[1], up_vec[2]);
- cam->SetUseHorizontalViewAngle (0);
- cam->SetViewAngle (fovy);
- cam->SetClippingRange (0.01, 1000.01);
- window_->SetSize (window_size[0], window_size[1]);
-
- renderer_->Render ();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraParameters (const cv::viz::Camera &camera)
-{
- //rens_->InitTraversal ();
-
-
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetPosition (camera.pos[0], camera.pos[1], camera.pos[2]);
- cam->SetFocalPoint (camera.focal[0], camera.focal[1], camera.focal[2]);
- cam->SetViewUp (camera.view_up[0], camera.view_up[1], camera.view_up[2]);
- cam->SetClippingRange (camera.clip.val);
- cam->SetUseHorizontalViewAngle (0);
- cam->SetViewAngle (camera.fovy * 180.0 / M_PI);
-
- window_->SetSize (static_cast<int> (camera.window_size[0]), static_cast<int> (camera.window_size[1]));
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraClipDistances (double near, double far)
-{
- //rens_->InitTraversal ();
-
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetClippingRange (near, far);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-void cv::viz::Viz3d::VizImpl::setCameraFieldOfView (double fovy)
-{
- //rens_->InitTraversal ();
-
- vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
- cam->SetUseHorizontalViewAngle (0);
- cam->SetViewAngle (fovy * 180.0 / M_PI);
-
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
{
+ // TODO Cloud actor is not used
vtkSmartPointer<vtkMatrix4x4> camera_pose;
static CloudActorMap::iterator it = cloud_actor_map_->find (id);
if (it != cloud_actor_map_->end ())
/** \brief Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
* \param[in] id the point cloud object id (default: cloud) */
void resetCameraViewpoint (const String& id = "cloud");
- /** \brief Set the camera pose given by position, viewpoint and up vector
- * \param[in] pos camera location
- * \param[in] view the view point of the camera
- * \param[in] up the view up direction of the camera */
- void setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up);
-
- /** \brief Set the camera location and viewup according to the given arguments
- * \param[in] pos_x,y,z the x,y,z coordinate of the camera location
- * \param[in] up_x,y,z the x,y,z component of the view up direction of the camera */
- void setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z);
-
- /** \brief Set the camera parameters via an intrinsics and and extrinsics matrix
- * \note This assumes that the pixels are square and that the center of the image is at the center of the sensor.
- * \param[in] intrinsics the intrinsics that will be used to compute the VTK camera parameters
- * \param[in] extrinsics the extrinsics that will be used to compute the VTK camera parameters */
- void setCameraParameters (const cv::Matx33f& intrinsics, const Affine3f& extrinsics);
- void setCameraParameters (const Camera &camera);
- void setCameraClipDistances (double near, double far);
- void setCameraFieldOfView (double fovy);
- void getCameras (Camera& camera);
-
+
//to implement Viz3d set/getViewerPose()
void setViewerPose(const Affine3f &pose);
Affine3f getViewerPose();