From: Anatoly Baksheev Date: Sun, 8 Dec 2013 14:07:16 +0000 (+0400) Subject: refactored Trajectory: split into Trajectory and TrajectoryFrustums) X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~714^2~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31d42ce18f55f4f42388eaa52e106a8733a099de;p=profile%2Fivi%2Fopencv.git refactored Trajectory: split into Trajectory and TrajectoryFrustums) --- diff --git a/modules/viz/doc/widget.rst b/modules/viz/doc/widget.rst index 90147e4..a629b7b 100644 --- a/modules/viz/doc/widget.rst +++ b/modules/viz/doc/widget.rst @@ -732,26 +732,19 @@ This 3D Widget represents a trajectory. :: enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH}; //! Displays trajectory of the given path either by coordinate frames or polyline - WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, const Color &color = Color::white(), float scale = 1.0); - //! Displays trajectory of the given path by frustums - WTrajectory(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()); - //! Displays trajectory of the given path by frustums - WTrajectory(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()); - - private: - /* hidden */ + WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, float scale = 1.f, const Color &color = Color::white(),; }; viz::WTrajectory::WTrajectory ----------------------------- Constructs a WTrajectory. -.. ocv:function:: WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, const Color &color = Color::white(), float scale = 1.0) +.. ocv:function:: WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, float scale = 1.f, const Color &color = Color::white()) :param path: List of poses on a trajectory. :param display_mode: Display mode. This can be PATH, FRAMES, and BOTH. - :param color: :ocv:class:`Color` of the polyline that represents path. Frames are not affected. :param scale: Scale of the frames. Polyline is not affected. + :param color: :ocv:class:`Color` of the polyline that represents path. Frames are not affected. Displays trajectory of the given path as follows: @@ -759,7 +752,26 @@ Constructs a WTrajectory. * FRAMES : Displays coordinate frames at each pose. * PATH & FRAMES : Displays both poly line and coordinate frames. -.. ocv:function:: WTrajectory(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()) +viz::WTrajectoryFrustums +---------------- +.. ocv:class:: WTrajectoryFrustums + +This 3D Widget represents a trajectory. :: + + class CV_EXPORTS WTrajectoryFrustums : public Widget3D + { + public: + //! Displays trajectory of the given path by frustums + WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()); + //! Displays trajectory of the given path by frustums + WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()); + }; + +viz::WTrajectoryFrustums::WTrajectoryFrustums +----------------------------- +Constructs a WTrajectoryFrustums. + +.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()) :param path: List of poses on a trajectory. :param K: Intrinsic matrix of the camera. @@ -768,7 +780,7 @@ Constructs a WTrajectory. Displays frustums at each pose of the trajectory. -.. ocv:function:: WTrajectory(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()) +.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()) :param path: List of poses on a trajectory. :param fov: Field of view of the camera (horizontal, vertical). diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index fb2783b..cb2dae2 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -245,13 +245,13 @@ namespace cv //! Creates camera coordinate frame (axes) at the origin WCameraPosition(float scale = 1.f); //! Creates frustum based on the intrinsic marix K at the origin - WCameraPosition(const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); + explicit WCameraPosition(const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); //! Creates frustum based on the field of view at the origin - WCameraPosition(const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); + explicit WCameraPosition(const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - WCameraPosition(const Matx33f &K, const Mat &img, float scale = 1.f, const Color &color = Color::white()); + explicit WCameraPosition(const Matx33f &K, const Mat &img, float scale = 1.f, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - WCameraPosition(const Vec2f &fov, const Mat &img, float scale = 1.f, const Color &color = Color::white()); + explicit WCameraPosition(const Vec2f &fov, const Mat &img, float scale = 1.f, const Color &color = Color::white()); }; class CV_EXPORTS WTrajectory : public Widget3D @@ -260,11 +260,16 @@ namespace cv enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH }; //! Displays trajectory of the given path either by coordinate frames or polyline - WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, const Color &color = Color::white(), float scale = 1.f); + WTrajectory(const std::vector &path, int display_mode = WTrajectory::PATH, float scale = 1.f, const Color &color = Color::white()); + }; + + class CV_EXPORTS WTrajectoryFrustums : public Widget3D + { + public: //! Displays trajectory of the given path by frustums - WTrajectory(const std::vector &path, const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); + explicit WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); //! Displays trajectory of the given path by frustums - WTrajectory(const std::vector &path, const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); + explicit WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); }; class CV_EXPORTS WTrajectorySpheres: public Widget3D @@ -330,6 +335,7 @@ namespace cv template<> CV_EXPORTS WImage3D Widget::cast(); template<> CV_EXPORTS WCameraPosition Widget::cast(); template<> CV_EXPORTS WTrajectory Widget::cast(); + template<> CV_EXPORTS WTrajectoryFrustums Widget::cast(); template<> CV_EXPORTS WTrajectorySpheres Widget::cast(); template<> CV_EXPORTS WCloud Widget::cast(); template<> CV_EXPORTS WCloudCollection Widget::cast(); diff --git a/modules/viz/src/shape_widgets.cpp b/modules/viz/src/shape_widgets.cpp index 8d226ff..3a2ba58 100644 --- a/modules/viz/src/shape_widgets.cpp +++ b/modules/viz/src/shape_widgets.cpp @@ -1235,7 +1235,7 @@ namespace cv { namespace viz { namespace }; }}} -cv::viz::WTrajectory::WTrajectory(const std::vector &path, int display_mode, const Color &color, float scale) +cv::viz::WTrajectory::WTrajectory(const std::vector &path, int display_mode, float scale, const Color &color) { vtkSmartPointer appendFilter = vtkSmartPointer::New(); @@ -1331,7 +1331,16 @@ cv::viz::WTrajectory::WTrajectory(const std::vector &path, int display WidgetAccessor::setProp(*this, actor); } -cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Matx33f &K, float scale, const Color &color) +template<> cv::viz::WTrajectory cv::viz::Widget::cast() +{ + Widget3D widget = this->cast(); + return static_cast(widget); +} + +/////////////////////////////////////////////////////////////////////////////////////////////// +/// WTrajectoryFrustums widget implementation + +cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); float f_x = K(0,0); @@ -1375,7 +1384,7 @@ cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Matx3 setColor(color); } -cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Vec2f &fov, float scale, const Color &color) +cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); @@ -1415,14 +1424,14 @@ cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Vec2f setColor(color); } -template<> cv::viz::WTrajectory cv::viz::Widget::cast() +template<> cv::viz::WTrajectoryFrustums cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// -/// spheres trajectory widget implementation +/// WTrajectorySpheres widget implementation cv::viz::WTrajectorySpheres::WTrajectorySpheres(const std::vector &path, float line_length, float init_sphere_radius, float sphere_radius, const Color &line_color, const Color &sphere_color)