refactored Trajectory: split into Trajectory and TrajectoryFrustums)
authorAnatoly Baksheev <no@email>
Sun, 8 Dec 2013 14:07:16 +0000 (18:07 +0400)
committerAnatoly Baksheev <no@email>
Sun, 19 Jan 2014 14:38:39 +0000 (18:38 +0400)
modules/viz/doc/widget.rst
modules/viz/include/opencv2/viz/widgets.hpp
modules/viz/src/shape_widgets.cpp

index 90147e4..a629b7b 100644 (file)
@@ -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<Affine3f> &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<Affine3f> &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<Affine3f> &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white());
-
-    private:
-        /* hidden */
+        WTrajectory(const std::vector<Affine3f> &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<Affine3f> &path, int display_mode = WTrajectory::PATH, const Color &color = Color::white(), float scale = 1.0)
+.. ocv:function:: WTrajectory(const std::vector<Affine3f> &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<Affine3f> &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<Affine3f> &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<Affine3f> &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<Affine3f> &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<Affine3f> &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white())
+.. ocv:function:: WTrajectoryFrustums(const std::vector<Affine3f> &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).
index fb2783b..cb2dae2 100644 (file)
@@ -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<Affine3f> &path, int display_mode = WTrajectory::PATH, const Color &color = Color::white(), float scale = 1.f);
+            WTrajectory(const std::vector<Affine3f> &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<Affine3f> &path, const Matx33f &K, float scale = 1.f, const Color &color = Color::white());
+            explicit WTrajectoryFrustums(const std::vector<Affine3f> &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<Affine3f> &path, const Vec2f &fov, float scale = 1.f, const Color &color = Color::white());
+            explicit WTrajectoryFrustums(const std::vector<Affine3f> &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<WImage3D>();
         template<> CV_EXPORTS WCameraPosition Widget::cast<WCameraPosition>();
         template<> CV_EXPORTS WTrajectory Widget::cast<WTrajectory>();
+        template<> CV_EXPORTS WTrajectoryFrustums Widget::cast<WTrajectoryFrustums>();
         template<> CV_EXPORTS WTrajectorySpheres Widget::cast<WTrajectorySpheres>();
         template<> CV_EXPORTS WCloud Widget::cast<WCloud>();
         template<> CV_EXPORTS WCloudCollection Widget::cast<WCloudCollection>();
index 8d226ff..3a2ba58 100644 (file)
@@ -1235,7 +1235,7 @@ namespace cv { namespace viz { namespace
     };
 }}}
 
-cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display_mode, const Color &color, float scale)
+cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display_mode, float scale, const Color &color)
 {
     vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
 
@@ -1331,7 +1331,16 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display
     WidgetAccessor::setProp(*this, actor);
 }
 
-cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Matx33f &K, float scale, const Color &color)
+template<> cv::viz::WTrajectory cv::viz::Widget::cast<cv::viz::WTrajectory>()
+{
+    Widget3D widget = this->cast<Widget3D>();
+    return static_cast<WTrajectory&>(widget);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+/// WTrajectoryFrustums widget implementation
+
+cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3f> &path, const Matx33f &K, float scale, const Color &color)
 {
     vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
     float f_x = K(0,0);
@@ -1375,7 +1384,7 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Matx3
     setColor(color);
 }
 
-cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, float scale, const Color &color)
+cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3f> &path, const Vec2f &fov, float scale, const Color &color)
 {
     vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
 
@@ -1415,14 +1424,14 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Vec2f
     setColor(color);
 }
 
-template<> cv::viz::WTrajectory cv::viz::Widget::cast<cv::viz::WTrajectory>()
+template<> cv::viz::WTrajectoryFrustums cv::viz::Widget::cast<cv::viz::WTrajectoryFrustums>()
 {
     Widget3D widget = this->cast<Widget3D>();
-    return static_cast<WTrajectory&>(widget);
+    return static_cast<WTrajectoryFrustums&>(widget);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
-/// spheres trajectory widget implementation
+/// WTrajectorySpheres widget implementation
 
 cv::viz::WTrajectorySpheres::WTrajectorySpheres(const std::vector<Affine3f> &path, float line_length, float init_sphere_radius, float sphere_radius,
                                                           const Color &line_color, const Color &sphere_color)