From f6e1a093cd401ced065f9b50b325be5d6d166319 Mon Sep 17 00:00:00 2001 From: ozantonkal Date: Sat, 24 Aug 2013 12:18:42 +0200 Subject: [PATCH] implement window relevant methods in Viz3d --- modules/viz/include/opencv2/viz/viz3d.hpp | 8 +++-- modules/viz/src/viz3d.cpp | 7 +++-- modules/viz/src/viz3d_impl.cpp | 30 ------------------ modules/viz/src/viz3d_impl.hpp | 38 +++++------------------ 4 files changed, 18 insertions(+), 65 deletions(-) diff --git a/modules/viz/include/opencv2/viz/viz3d.hpp b/modules/viz/include/opencv2/viz/viz3d.hpp index 16e4911447..89e1841dbb 100644 --- a/modules/viz/include/opencv2/viz/viz3d.hpp +++ b/modules/viz/include/opencv2/viz/viz3d.hpp @@ -24,8 +24,6 @@ namespace cv Viz3d& operator=(const Viz3d&); ~Viz3d(); - void setBackgroundColor(const Color& color = Color::black()); - void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity()); void removeWidget(const String &id); Widget getWidget(const String &id) const; @@ -45,8 +43,12 @@ namespace cv Size getWindowSize() const; void setWindowSize(const Size &window_size); - String getWindowName() const; + void saveScreenshot (const String &file); + void setWindowPosition (int x, int y); + void setFullScreen (bool mode); + void setWindowName (const String &name); + void setBackgroundColor(const Color& color = Color::black()); void spin(); void spinOnce(int time = 1, bool force_redraw = false); diff --git a/modules/viz/src/viz3d.cpp b/modules/viz/src/viz3d.cpp index 8f1d12c89b..5a2ae0531c 100644 --- a/modules/viz/src/viz3d.cpp +++ b/modules/viz/src/viz3d.cpp @@ -42,8 +42,6 @@ void cv::viz::Viz3d::release() } } -void cv::viz::Viz3d::setBackgroundColor(const Color& color) { impl_->setBackgroundColor(color); } - void cv::viz::Viz3d::spin() { impl_->spin(); } void cv::viz::Viz3d::spinOnce (int time, bool force_redraw) { impl_->spinOnce(time, force_redraw); } bool cv::viz::Viz3d::wasStopped() const { return impl_->wasStopped(); } @@ -73,6 +71,11 @@ void cv::viz::Viz3d::converTo3DRay(const Point3d &window_coord, Point3d &origin, cv::Size cv::viz::Viz3d::getWindowSize() const { return impl_->getWindowSize(); } void cv::viz::Viz3d::setWindowSize(const Size &window_size) { impl_->setWindowSize(window_size.width, window_size.height); } cv::String cv::viz::Viz3d::getWindowName() const { return impl_->getWindowName(); } +void cv::viz::Viz3d::saveScreenshot (const String &file) { impl_->saveScreenshot(file); } +void cv::viz::Viz3d::setWindowPosition (int x, int y) { impl_->setWindowPosition(x,y); } +void cv::viz::Viz3d::setFullScreen (bool mode) { impl_->setFullScreen(mode); } +void cv::viz::Viz3d::setWindowName (const String &name) { impl_->setWindowName(name); } +void cv::viz::Viz3d::setBackgroundColor(const Color& color) { impl_->setBackgroundColor(color); } void cv::viz::Viz3d::setRenderingProperty(int property, double value, const String &id) { getWidget(id).setRenderingProperty(property, value); } double cv::viz::Viz3d::getRenderingProperty(int property, const String &id) { return getWidget(id).getRenderingProperty(property); } diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index 880224799b..1c35216fca 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -249,30 +249,6 @@ void cv::viz::Viz3d::VizImpl::setBackgroundColor (const Color& color) renderer_->SetBackground (c.val); } -///////////////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::initCameraParameters () -{ - Vec2i window_size(window_->GetScreenSize()); - window_size /= 2; - - Camera 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))); -} - -///////////////////////////////////////////////////////////////////////////////////////////// -bool cv::viz::Viz3d::VizImpl::cameraParamsSet () const { return (camera_set_); } - -///////////////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::updateCamera () -{ - std::cout << "[cv::viz::PCLVisualizer::updateCamera()] This method was deprecated, just re-rendering all scenes now." << std::endl; - //rens_->InitTraversal (); - // Update the camera parameters - - renderer_->Render (); -} - ///////////////////////////////////////////////////////////////////////////////////////////// void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera) { @@ -379,12 +355,6 @@ void cv::viz::Viz3d::VizImpl::converTo3DRay(const Point3d &window_coord, Point3d direction = normalize(Vec3d(world_pt.val) - cam_pos); } -///////////////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::resetCamera () -{ - renderer_->ResetCamera (); -} - ///////////////////////////////////////////////////////////////////////////////////////////// void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id) { diff --git a/modules/viz/src/viz3d_impl.hpp b/modules/viz/src/viz3d_impl.hpp index 7bb008a3a8..67f7c27017 100644 --- a/modules/viz/src/viz3d_impl.hpp +++ b/modules/viz/src/viz3d_impl.hpp @@ -16,8 +16,15 @@ public: VizImpl (const String &name); virtual ~VizImpl (); - + + void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity()); + void removeWidget(const String &id); + Widget getWidget(const String &id) const; void removeAllWidgets(); + + void setWidgetPose(const String &id, const Affine3f &pose); + void updateWidgetPose(const String &id, const Affine3f &pose); + Affine3f getWidgetPose(const String &id) const; void setRenderingProperty(int property, double value, const String &id); double getRenderingProperty(int property, const String &id); @@ -51,29 +58,16 @@ public: void setCamera(const Camera &camera); Camera getCamera() const; - void initCameraParameters (); /** \brief Initialize camera parameters with some default values. */ - bool cameraParamsSet () const; /** \brief Checks whether the camera parameters were manually loaded from file.*/ - void updateCamera (); /** \brief Update camera parameters and render. */ - void resetCamera (); /** \brief Reset camera parameters and render. */ - /** \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"); - //to implement Viz3d set/getViewerPose() void setViewerPose(const Affine3f &pose); Affine3f getViewerPose(); void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord); void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction); - - - - - - - //to implemnt in Viz3d void saveScreenshot (const String &file); void setWindowPosition (int x, int y); Size getWindowSize() const; @@ -89,22 +83,6 @@ public: void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0); void registerMouseCallback(MouseCallback callback, void* cookie = 0); - - - - - - - - //declare above (to move to up) - void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity()); - void removeWidget(const String &id); - Widget getWidget(const String &id) const; - - void setWidgetPose(const String &id, const Affine3f &pose); - void updateWidgetPose(const String &id, const Affine3f &pose); - Affine3f getWidgetPose(const String &id) const; - private: vtkSmartPointer interactor_;