From c31fb8ffff9b5ec033124f5ea9a821d86ff66623 Mon Sep 17 00:00:00 2001 From: Ozan Tonkal Date: Sun, 15 Sep 2013 16:26:53 +0200 Subject: [PATCH] rename widgets from *Widgets to W* --- doc/tutorials/viz/creating_widgets.rst | 18 +- doc/tutorials/viz/transformations.rst | 14 +- doc/tutorials/viz/widget_pose.rst | 20 +- modules/viz/doc/widget.rst | 432 ++++++++++----------- modules/viz/include/opencv2/viz/widgets.hpp | 146 +++---- modules/viz/src/cloud_widgets.cpp | 38 +- modules/viz/src/shape_widgets.cpp | 146 +++---- modules/viz/test/test_viz3d.cpp | 303 +++++---------- samples/cpp/tutorial_code/viz/creating_widgets.cpp | 8 +- samples/cpp/tutorial_code/viz/transformations.cpp | 8 +- samples/cpp/tutorial_code/viz/widget_pose.cpp | 6 +- 11 files changed, 514 insertions(+), 625 deletions(-) diff --git a/doc/tutorials/viz/creating_widgets.rst b/doc/tutorials/viz/creating_widgets.rst index 59f1fdc..fd002a8 100644 --- a/doc/tutorials/viz/creating_widgets.rst +++ b/doc/tutorials/viz/creating_widgets.rst @@ -37,19 +37,19 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ using namespace std; /** - * @class TriangleWidget + * @class WTriangle * @brief Defining our own 3D Triangle widget */ - class TriangleWidget : public viz::Widget3D + class WTriangle : public viz::Widget3D { public: - TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); + WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); }; /** - * @function TriangleWidget::TriangleWidget + * @function WTriangle::WTriangle */ - TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color) + WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color) { // Create a triangle vtkSmartPointer points = vtkSmartPointer::New(); @@ -99,7 +99,7 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ viz::Viz3d myWindow("Creating Widgets"); /// Create a triangle widget - TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); + WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); /// Show widget in the visualizer window myWindow.showWidget("TRIANGLE", tw); @@ -119,10 +119,10 @@ Here is the general structure of the program: .. code-block:: cpp - class TriangleWidget : public viz::Widget3D + class WTriangle : public viz::Widget3D { public: - TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); + WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); }; * Assign a VTK actor to the widget. @@ -144,7 +144,7 @@ Here is the general structure of the program: .. code-block:: cpp /// Create a triangle widget - TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); + WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); /// Show widget in the visualizer window myWindow.showWidget("TRIANGLE", tw); diff --git a/doc/tutorials/viz/transformations.rst b/doc/tutorials/viz/transformations.rst index 0639a0d..0bcc7db 100644 --- a/doc/tutorials/viz/transformations.rst +++ b/doc/tutorials/viz/transformations.rst @@ -67,7 +67,7 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ viz::Viz3d myWindow("Coordinate Frame"); /// Add coordinate axes - myWindow.showWidget("Coordinate Widget", viz::CoordinateSystemWidget()); + myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem()); /// Let's assume camera has the following properties Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f); @@ -81,7 +81,7 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ /// Create a cloud widget. Mat bunny_cloud = cvcloud_load(); - viz::CloudWidget cloud_widget(bunny_cloud, viz::Color::green()); + viz::WCloud cloud_widget(bunny_cloud, viz::Color::green()); /// Pose of the widget in camera frame Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f)); @@ -91,8 +91,8 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ /// Visualize camera frame if (!camera_pov) { - viz::CameraPositionWidget cpw(0.5); // Coordinate axes - viz::CameraPositionWidget cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum + viz::WCameraPosition cpw(0.5); // Coordinate axes + viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum myWindow.showWidget("CPW", cpw, cam_pose); myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose); } @@ -147,7 +147,7 @@ Here is the general structure of the program: /// Create a cloud widget. Mat bunny_cloud = cvcloud_load(); - viz::CloudWidget cloud_widget(bunny_cloud, viz::Color::green()); + viz::WCloud cloud_widget(bunny_cloud, viz::Color::green()); * Given the pose in camera coordinate system, estimate the global pose. @@ -165,8 +165,8 @@ Here is the general structure of the program: /// Visualize camera frame if (!camera_pov) { - viz::CameraPositionWidget cpw(0.5); // Coordinate axes - viz::CameraPositionWidget cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum + viz::WCameraPosition cpw(0.5); // Coordinate axes + viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum myWindow.showWidget("CPW", cpw, cam_pose); myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose); } diff --git a/doc/tutorials/viz/widget_pose.rst b/doc/tutorials/viz/widget_pose.rst index 22dfb28..a0cb00f 100644 --- a/doc/tutorials/viz/widget_pose.rst +++ b/doc/tutorials/viz/widget_pose.rst @@ -37,16 +37,16 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ viz::Viz3d myWindow("Coordinate Frame"); /// Add coordinate axes - myWindow.showWidget("Coordinate Widget", viz::CoordinateSystemWidget()); + myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem()); /// Add line to represent (1,1,1) axis - viz::LineWidget axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); - axis.setRenderingProperty(viz::VIZ_LINE_WIDTH, 4.0); + viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); + axis.setRenderingProperty(viz::LINE_WIDTH, 4.0); myWindow.showWidget("Line Widget", axis); /// Construct a cube widget - viz::CubeWidget cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); - cube_widget.setRenderingProperty(viz::VIZ_LINE_WIDTH, 4.0); + viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); + cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0); /// Display widget (update if already displayed) myWindow.showWidget("Cube Widget", cube_widget); @@ -97,15 +97,15 @@ Here is the general structure of the program: .. code-block:: cpp /// Add coordinate axes - myWindow.showWidget("Coordinate Widget", viz::CoordinateSystemWidget()); + myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem()); * Display a line representing the axis (1,1,1). .. code-block:: cpp /// Add line to represent (1,1,1) axis - viz::LineWidget axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); - axis.setRenderingProperty(viz::VIZ_LINE_WIDTH, 4.0); + viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); + axis.setRenderingProperty(viz::LINE_WIDTH, 4.0); myWindow.showWidget("Line Widget", axis); * Construct a cube. @@ -113,8 +113,8 @@ Here is the general structure of the program: .. code-block:: cpp /// Construct a cube widget - viz::CubeWidget cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); - cube_widget.setRenderingProperty(viz::VIZ_LINE_WIDTH, 4.0); + viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); + cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0); myWindow.showWidget("Cube Widget", cube_widget); * Create rotation matrix from rodrigues vector diff --git a/modules/viz/doc/widget.rst b/modules/viz/doc/widget.rst index ef1e828..e133eb1 100644 --- a/modules/viz/doc/widget.rst +++ b/modules/viz/doc/widget.rst @@ -14,7 +14,7 @@ and modify the widget without re-adding the widget. ... /// Create a cloud widget - viz::CloudWidget cw(cloud, viz::Color::red()); + viz::WCloud cw(cloud, viz::Color::red()); /// Display it in a window myWindow.showWidget("CloudWidget1", cw); /// Modify it, and it will be modified in the window. @@ -118,9 +118,9 @@ Casts a widget to another. .. code-block:: cpp // Create a sphere widget - viz::SphereWidget sw(Point3f(0.0f,0.0f,0.0f), 0.5f); + viz::WSphere sw(Point3f(0.0f,0.0f,0.0f), 0.5f); // Cast sphere widget to cloud widget - viz::CloudWidget cw = sw.cast(); + viz::WCloud cw = sw.cast(); .. note:: 3D Widgets can only be cast to 3D Widgets. 2D Widgets can only be cast to 2D Widgets. @@ -231,100 +231,100 @@ Sets the color of the widget. :param color: color of type :ocv:class:`Color` -viz::LineWidget ---------------- -.. ocv:class:: LineWidget +viz::WLine +---------- +.. ocv:class:: WLine This 3D Widget defines a finite line. :: - class CV_EXPORTS LineWidget : public Widget3D + class CV_EXPORTS WLine : public Widget3D { public: - LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); + WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); }; -viz::LineWidget::LineWidget ---------------------------- -Constructs a LineWidget. +viz::WLine::WLine +----------------- +Constructs a WLine. -.. ocv:function:: LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()) +.. ocv:function:: WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()) :param pt1: Start point of the line. :param pt2: End point of the line. :param color: :ocv:class:`Color` of the line. -viz::PlaneWidget ----------------- -.. ocv:class:: PlaneWidget +viz::WPlane +----------- +.. ocv:class:: WPlane This 3D Widget defines a finite plane. :: - class CV_EXPORTS PlaneWidget : public Widget3D + class CV_EXPORTS WPlane : public Widget3D { public: - PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()); - PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()); + WPlane(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()); + WPlane(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()); private: /* hidden */ }; -viz::PlaneWidget::PlaneWidget ------------------------------ -Constructs a PlaneWidget. +viz::WPlane::WPlane +------------------- +Constructs a WPlane. -.. ocv:function:: PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()) +.. ocv:function:: WPlane(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()) :param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param size: Size of the plane. :param color: :ocv:class:`Color` of the plane. -.. ocv:function:: PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()) +.. ocv:function:: WPlane(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()) :param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param pt: Position of the plane. :param size: Size of the plane. :param color: :ocv:class:`Color` of the plane. -viz::SphereWidget ------------------ -.. ocv:class:: SphereWidget +viz::WSphere +------------ +.. ocv:class:: WSphere This 3D Widget defines a sphere. :: - class CV_EXPORTS SphereWidget : public Widget3D + class CV_EXPORTS WSphere : public Widget3D { public: - SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) + WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) }; -viz::SphereWidget::SphereWidget -------------------------------- -Constructs a SphereWidget. +viz::WSphere::WSphere +--------------------- +Constructs a WSphere. -.. ocv:function:: SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) +.. ocv:function:: WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) :param center: Center of the sphere. :param radius: Radius of the sphere. :param sphere_resolution: Resolution of the sphere. :param color: :ocv:class:`Color` of the sphere. -viz::ArrowWidget +viz::WArrow ---------------- -.. ocv:class:: ArrowWidget +.. ocv:class:: WArrow This 3D Widget defines an arrow. :: - class CV_EXPORTS ArrowWidget : public Widget3D + class CV_EXPORTS WArrow : public Widget3D { public: - ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); + WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); }; -viz::ArrowWidget::ArrowWidget +viz::WArrow::WArrow ----------------------------- -Constructs an ArrowWidget. +Constructs an WArrow. -.. ocv:function:: ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()) +.. ocv:function:: WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()) :param pt1: Start point of the arrow. :param pt2: End point of the arrow. @@ -333,46 +333,46 @@ Constructs an ArrowWidget. Arrow head is located at the end point of the arrow. -viz::CircleWidget +viz::WCircle ----------------- -.. ocv:class:: CircleWidget +.. ocv:class:: WCircle This 3D Widget defines a circle. :: - class CV_EXPORTS CircleWidget : public Widget3D + class CV_EXPORTS WCircle : public Widget3D { public: - CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()); + WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()); }; -viz::CircleWidget::CircleWidget +viz::WCircle::WCircle ------------------------------- -Constructs a CircleWidget. +Constructs a WCircle. -.. ocv:function:: CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()) +.. ocv:function:: WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()) :param pt: Center of the circle. :param radius: Radius of the circle. :param thickness: Thickness of the circle. :param color: :ocv:class:`Color` of the circle. -viz::CylinderWidget -------------------- -.. ocv:class:: CylinderWidget +viz::WCylinder +-------------- +.. ocv:class:: WCylinder This 3D Widget defines a cylinder. :: - class CV_EXPORTS CylinderWidget : public Widget3D + class CV_EXPORTS WCylinder : public Widget3D { public: - CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); + WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); }; -viz::CylinderWidget::CylinderWidget +viz::WCylinder::WCylinder ----------------------------------- -Constructs a CylinderWidget. +Constructs a WCylinder. -.. ocv:function:: CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()) +.. ocv:function:: WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()) :param pt_on_axis: A point on the axis of the cylinder. :param axis_direction: Direction of the axis of the cylinder. @@ -380,23 +380,23 @@ Constructs a CylinderWidget. :param numsides: Resolution of the cylinder. :param color: :ocv:class:`Color` of the cylinder. -viz::CubeWidget ---------------- -.. ocv:class:: CubeWidget +viz::WCube +---------- +.. ocv:class:: WCube This 3D Widget defines a cube. :: - class CV_EXPORTS CubeWidget : public Widget3D + class CV_EXPORTS WCube : public Widget3D { public: - CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); + WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); }; -viz::CubeWidget::CubeWidget +viz::WCube::WCube --------------------------- -Constructs a CudeWidget. +Constructs a WCube. -.. ocv:function:: CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()) +.. ocv:function:: WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()) :param pt_min: Specifies minimum point of the bounding box. :param pt_max: Specifies maximum point of the bounding box. @@ -407,104 +407,104 @@ Constructs a CudeWidget. :alt: Cube Widget :align: center -viz::CoordinateSystemWidget ---------------------------- -.. ocv:class:: CoordinateSystemWidget +viz::WCoordinateSystem +---------------------- +.. ocv:class:: WCoordinateSystem This 3D Widget represents a coordinate system. :: - class CV_EXPORTS CoordinateSystemWidget : public Widget3D + class CV_EXPORTS WCoordinateSystem : public Widget3D { public: - CoordinateSystemWidget(double scale = 1.0); + WCoordinateSystem(double scale = 1.0); }; -viz::CoordinateSystemWidget::CoordinateSystemWidget +viz::WCoordinateSystem::WCoordinateSystem --------------------------------------------------- -Constructs a CoordinateSystemWidget. +Constructs a WCoordinateSystem. -.. ocv:function:: CoordinateSystemWidget(double scale = 1.0) +.. ocv:function:: WCoordinateSystem(double scale = 1.0) :param scale: Determines the size of the axes. -viz::PolyLineWidget -------------------- -.. ocv:class:: PolyLineWidget +viz::WPolyLine +-------------- +.. ocv:class:: WPolyLine This 3D Widget defines a poly line. :: - class CV_EXPORTS PolyLineWidget : public Widget3D + class CV_EXPORTS WPolyLine : public Widget3D { public: - PolyLineWidget(InputArray points, const Color &color = Color::white()); + WPolyLine(InputArray points, const Color &color = Color::white()); private: /* hidden */ }; -viz::PolyLineWidget::PolyLineWidget +viz::WPolyLine::WPolyLine ----------------------------------- -Constructs a PolyLineWidget. +Constructs a WPolyLine. -.. ocv:function:: PolyLineWidget(InputArray points, const Color &color = Color::white()) +.. ocv:function:: WPolyLine(InputArray points, const Color &color = Color::white()) :param points: Point set. :param color: :ocv:class:`Color` of the poly line. -viz::GridWidget ---------------- -.. ocv:class:: GridWidget +viz::WGrid +---------- +.. ocv:class:: WGrid This 3D Widget defines a grid. :: - class CV_EXPORTS GridWidget : public Widget3D + class CV_EXPORTS WGrid : public Widget3D { public: //! Creates grid at the origin - GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); + WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); //! Creates grid based on the plane equation - GridWidget(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); + WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); private: /* hidden */ }; -viz::GridWidget::GridWidget +viz::WGrid::WGrid --------------------------- -Constructs a GridWidget. +Constructs a WGrid. -.. ocv:function:: GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) +.. ocv:function:: WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) :param dimensions: Number of columns and rows, respectively. :param spacing: Size of each column and row, respectively. :param color: :ocv:class:`Color` of the grid. -.. ocv:function: GridWidget(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) +.. ocv:function: WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) :param coeffs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param dimensions: Number of columns and rows, respectively. :param spacing: Size of each column and row, respectively. :param color: :ocv:class:`Color` of the grid. -viz::Text3DWidget ------------------ -.. ocv:class:: Text3DWidget +viz::WText3D +------------ +.. ocv:class:: WText3D This 3D Widget represents 3D text. The text always faces the camera. :: - class CV_EXPORTS Text3DWidget : public Widget3D + class CV_EXPORTS WText3D : public Widget3D { public: - Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, double face_camera = true, const Color &color = Color::white()); + WText3D(const String &text, const Point3f &position, double text_scale = 1.0, double face_camera = true, const Color &color = Color::white()); void setText(const String &text); String getText() const; }; -viz::Text3DWidget::Text3DWidget +viz::WText3D::WText3D ------------------------------- -Constructs a Text3DWidget. +Constructs a WText3D. -.. ocv:function:: Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, double face_camera = true, const Color &color = Color::white()) +.. ocv:function:: WText3D(const String &text, const Point3f &position, double text_scale = 1.0, double face_camera = true, const Color &color = Color::white()) :param text: Text content of the widget. :param position: Position of the text. @@ -512,118 +512,118 @@ Constructs a Text3DWidget. :param face_camera: If true, text always faces the camera. :param color: :ocv:class:`Color` of the text. -viz::Text3DWidget::setText --------------------------- +viz::WText3D::setText +--------------------- Sets the text content of the widget. .. ocv:function:: void setText(const String &text) :param text: Text content of the widget. -viz::Text3DWidget::getText --------------------------- +viz::WText3D::getText +--------------------- Returns the current text content of the widget. .. ocv:function:: String getText() const -viz::TextWidget ---------------- -.. ocv:class:: TextWidget +viz::WText +---------- +.. ocv:class:: WText This 2D Widget represents text overlay. :: - class CV_EXPORTS TextWidget : public Widget2D + class CV_EXPORTS WText : public Widget2D { public: - TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()); + WText(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()); void setText(const String &text); String getText() const; }; -viz::TextWidget::TextWidget ---------------------------- -Constructs a TextWidget. +viz::WText::WText +----------------- +Constructs a WText. -.. ocv:function:: TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()) +.. ocv:function:: WText(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()) :param text: Text content of the widget. :param pos: Position of the text. :param font_size: Font size. :param color: :ocv:class:`Color` of the text. -viz::TextWidget::setText ------------------------- +viz::WText::setText +------------------- Sets the text content of the widget. .. ocv:function:: void setText(const String &text) :param text: Text content of the widget. -viz::TextWidget::getText ------------------------- +viz::WText::getText +------------------- Returns the current text content of the widget. .. ocv:function:: String getText() const -viz::ImageOverlayWidget ------------------------ -.. ocv:class:: ImageOverlayWidget +viz::WImageOverlay +------------------ +.. ocv:class:: WImageOverlay This 2D Widget represents an image overlay. :: - class CV_EXPORTS ImageOverlayWidget : public Widget2D + class CV_EXPORTS WImageOverlay : public Widget2D { public: - ImageOverlayWidget(const Mat &image, const Rect &rect); + WImageOverlay(const Mat &image, const Rect &rect); void setImage(const Mat &image); }; -viz::ImageOverlayWidget::ImageOverlayWidget -------------------------------------------- -Constructs an ImageOverlayWidget. +viz::WImageOverlay::WImageOverlay +--------------------------------- +Constructs an WImageOverlay. -.. ocv:function:: ImageOverlayWidget(const Mat &image, const Rect &rect) +.. ocv:function:: WImageOverlay(const Mat &image, const Rect &rect) :param image: BGR or Gray-Scale image. :param rect: Image is scaled and positioned based on rect. -viz::ImageOverlayWidget::setImage ---------------------------------- +viz::WImageOverlay::setImage +---------------------------- Sets the image content of the widget. .. ocv:function:: void setImage(const Mat &image) :param image: BGR or Gray-Scale image. -viz::Image3DWidget ------------------- -.. ocv:class:: Image3DWidget +viz::WImage3D +------------- +.. ocv:class:: WImage3D This 3D Widget represents an image in 3D space. :: - class CV_EXPORTS Image3DWidget : public Widget3D + class CV_EXPORTS WImage3D : public Widget3D { public: //! Creates 3D image at the origin - Image3DWidget(const Mat &image, const Size &size); + WImage3D(const Mat &image, const Size &size); //! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation - Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); + WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); void setImage(const Mat &image); }; -viz::Image3DWidget::Image3DWidget ---------------------------------- -Constructs an Image3DWidget. +viz::WImage3D::WImage3D +----------------------- +Constructs an WImage3D. -.. ocv:function:: Image3DWidget(const Mat &image, const Size &size) +.. ocv:function:: WImage3D(const Mat &image, const Size &size) :param image: BGR or Gray-Scale image. :param size: Size of the image. -.. ocv:function:: Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) +.. ocv:function:: WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) :param position: Position of the image. :param normal: Normal of the plane that represents the image. @@ -631,42 +631,42 @@ Constructs an Image3DWidget. :param image: BGR or Gray-Scale image. :param size: Size of the image. -viz::Image3DWidget::setImage ----------------------------- +viz::WImage3D::setImage +----------------------- Sets the image content of the widget. .. ocv:function:: void setImage(const Mat &image) :param image: BGR or Gray-Scale image. -viz::CameraPositionWidget -------------------------- -.. ocv:class:: CameraPositionWidget +viz::WCameraPosition +-------------------- +.. ocv:class:: WCameraPosition This 3D Widget represents camera position in a scene by its axes or viewing frustum. :: - class CV_EXPORTS CameraPositionWidget : public Widget3D + class CV_EXPORTS WCameraPosition : public Widget3D { public: //! Creates camera coordinate frame (axes) at the origin - CameraPositionWidget(double scale = 1.0); + WCameraPosition(double scale = 1.0); //! Creates frustum based on the intrinsic marix K at the origin - CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum based on the field of view at the origin - CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - CameraPositionWidget(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()); }; -viz::CameraPositionWidget::CameraPositionWidget ------------------------------------------------ -Constructs a CameraPositionWidget. +viz::WCameraPosition::WCameraPosition +------------------------------------- +Constructs a WCameraPosition. - **Display camera coordinate frame.** - .. ocv:function:: CameraPositionWidget(double scale = 1.0) + .. ocv:function:: WCameraPosition(double scale = 1.0) Creates camera coordinate frame at the origin. @@ -676,7 +676,7 @@ Constructs a CameraPositionWidget. - **Display the viewing frustum.** - .. ocv:function:: CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()) + .. ocv:function:: WCameraPosition(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()) :param K: Intrinsic matrix of the camera. :param scale: Scale of the frustum. @@ -684,7 +684,7 @@ Constructs a CameraPositionWidget. Creates viewing frustum of the camera based on its intrinsic matrix K. - .. ocv:function:: CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()) + .. ocv:function:: WCameraPosition(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()) :param fov: Field of view of the camera (horizontal, vertical). :param scale: Scale of the frustum. @@ -698,7 +698,7 @@ Constructs a CameraPositionWidget. - **Display image on the far plane of the viewing frustum.** - .. ocv:function:: CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()) + .. ocv:function:: WCameraPosition(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()) :param K: Intrinsic matrix of the camera. :param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. @@ -707,7 +707,7 @@ Constructs a CameraPositionWidget. Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane. - .. ocv:function:: CameraPositionWidget(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()) + .. ocv:function:: WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()) :param fov: Field of view of the camera (horizontal, vertical). :param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. @@ -720,33 +720,33 @@ Constructs a CameraPositionWidget. :alt: Camera viewing frustum with image :align: center -viz::TrajectoryWidget ---------------------- -.. ocv:class:: TrajectoryWidget +viz::WTrajectory +---------------- +.. ocv:class:: WTrajectory This 3D Widget represents a trajectory. :: - class CV_EXPORTS TrajectoryWidget : public Widget3D + class CV_EXPORTS WTrajectory : public Widget3D { public: enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2}; //! Displays trajectory of the given path either by coordinate frames or polyline - TrajectoryWidget(const std::vector &path, int display_mode = TrajectoryWidget::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0); + WTrajectory(const std::vector &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0); //! Displays trajectory of the given path by frustums - TrajectoryWidget(const std::vector &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); + WTrajectory(const std::vector &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); //! Displays trajectory of the given path by frustums - TrajectoryWidget(const std::vector &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); + WTrajectory(const std::vector &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); private: /* hidden */ }; -viz::TrajectoryWidget::TrajectoryWidget ---------------------------------------- -Constructs a TrajectoryWidget. +viz::WTrajectory::WTrajectory +----------------------------- +Constructs a WTrajectory. -.. ocv:function:: TrajectoryWidget(const std::vector &path, int display_mode = TrajectoryWidget::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0) +.. ocv:function:: WTrajectory(const std::vector &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0) :param path: List of poses on a trajectory. :param display_mode: Display mode. This can be DISPLAY_PATH, DISPLAY_FRAMES, DISPLAY_PATH & DISPLAY_FRAMES. @@ -759,7 +759,7 @@ Constructs a TrajectoryWidget. * DISPLAY_FRAMES : Displays coordinate frames at each pose. * DISPLAY_PATH & DISPLAY_FRAMES : Displays both poly line and coordinate frames. -.. ocv:function:: TrajectoryWidget(const std::vector &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()) +.. ocv:function:: WTrajectory(const std::vector &path, const Matx33f &K, double 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 +768,7 @@ Constructs a TrajectoryWidget. Displays frustums at each pose of the trajectory. -.. ocv:function:: TrajectoryWidget(const std::vector &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()) +.. ocv:function:: WTrajectory(const std::vector &path, const Vec2f &fov, double 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). @@ -777,26 +777,26 @@ Constructs a TrajectoryWidget. Displays frustums at each pose of the trajectory. -viz::SpheresTrajectoryWidget ----------------------------- -.. ocv:class:: SpheresTrajectoryWidget +viz::WSpheresTrajectory +----------------------- +.. ocv:class:: WSpheresTrajectory This 3D Widget represents a trajectory using spheres and lines, where spheres represent the positions of the camera, and lines represent the direction from previous position to the current. :: - class CV_EXPORTS SpheresTrajectoryWidget : public Widget3D + class CV_EXPORTS WSpheresTrajectory : public Widget3D { public: - SpheresTrajectoryWidget(const std::vector &path, float line_length = 0.05f, + WSpheresTrajectory(const std::vector &path, float line_length = 0.05f, double init_sphere_radius = 0.021, sphere_radius = 0.007, Color &line_color = Color::white(), const Color &sphere_color = Color::white()); }; -viz::SpheresTrajectoryWidget::SpheresTrajectoryWidget ------------------------------------------------------ -Constructs a SpheresTrajectoryWidget. +viz::WSpheresTrajectory::WSpheresTrajectory +------------------------------------------- +Constructs a WSpheresTrajectory. -.. ocv:function:: SpheresTrajectoryWidget(const std::vector &path, float line_length = 0.05f, double init_sphere_radius = 0.021, double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()) +.. ocv:function:: WSpheresTrajectory(const std::vector &path, float line_length = 0.05f, double init_sphere_radius = 0.021, double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()) :param path: List of poses on a trajectory. :param line_length: Length of the lines. @@ -805,36 +805,36 @@ Constructs a SpheresTrajectoryWidget. :param line_color: :ocv:class:`Color` of the lines. :param sphere_color: :ocv:class:`Color` of the spheres. -viz::CloudWidget ----------------- -.. ocv:class:: CloudWidget +viz::WCloud +----------- +.. ocv:class:: WCloud This 3D Widget defines a point cloud. :: - class CV_EXPORTS CloudWidget : public Widget3D + class CV_EXPORTS WCloud : public Widget3D { public: //! Each point in cloud is mapped to a color in colors - CloudWidget(InputArray cloud, InputArray colors); + WCloud(InputArray cloud, InputArray colors); //! All points in cloud have the same color - CloudWidget(InputArray cloud, const Color &color = Color::white()); + WCloud(InputArray cloud, const Color &color = Color::white()); private: /* hidden */ }; -viz::CloudWidget::CloudWidget ------------------------------ -Constructs a CloudWidget. +viz::WCloud::WCloud +------------------- +Constructs a WCloud. -.. ocv:function:: CloudWidget(InputArray cloud, InputArray colors) +.. ocv:function:: WCloud(InputArray cloud, InputArray colors) :param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. :param colors: Set of colors. It has to be of the same size with cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). -.. ocv:function:: CloudWidget(InputArray cloud, const Color &color = Color::white()) +.. ocv:function:: WCloud(InputArray cloud, const Color &color = Color::white()) :param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. :param color: A single :ocv:class:`Color` for the whole cloud. @@ -843,16 +843,16 @@ Constructs a CloudWidget. .. note:: In case there are four channels in the cloud, fourth channel is ignored. -viz::CloudCollectionWidget --------------------------- -.. ocv:class:: CloudCollectionWidget +viz::WCloudCollection +--------------------- +.. ocv:class:: WCloudCollection This 3D Widget defines a collection of clouds. :: - class CV_EXPORTS CloudCollectionWidget : public Widget3D + class CV_EXPORTS WCloudCollection : public Widget3D { public: - CloudCollectionWidget(); + WCloudCollection(); //! Each point in cloud is mapped to a color in colors void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity()); @@ -863,14 +863,14 @@ This 3D Widget defines a collection of clouds. :: /* hidden */ }; -viz::CloudCollectionWidget::CloudCollectionWidget -------------------------------------------------- -Constructs a CloudCollectionWidget. +viz::WCloudCollection::WCloudCollection +--------------------------------------- +Constructs a WCloudCollection. -.. ocv:function:: CloudCollectionWidget() +.. ocv:function:: WCloudCollection() -viz::CloudCollectionWidget::addCloud ------------------------------------- +viz::WCloudCollection::addCloud +------------------------------- Adds a cloud to the collection. .. ocv:function:: void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity()) @@ -891,26 +891,26 @@ Adds a cloud to the collection. .. note:: In case there are four channels in the cloud, fourth channel is ignored. -viz::CloudNormalsWidget ------------------------ -.. ocv:class:: CloudNormalsWidget +viz::WCloudNormals +------------------ +.. ocv:class:: WCloudNormals This 3D Widget represents normals of a point cloud. :: - class CV_EXPORTS CloudNormalsWidget : public Widget3D + class CV_EXPORTS WCloudNormals : public Widget3D { public: - CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); + WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); private: /* hidden */ }; -viz::CloudNormalsWidget::CloudNormalsWidget -------------------------------------------- -Constructs a CloudNormalsWidget. +viz::WCloudNormals::WCloudNormals +--------------------------------- +Constructs a WCloudNormals. -.. ocv:function:: CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()) +.. ocv:function:: WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()) :param cloud: Point set which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. :param normals: A set of normals that has to be of same type with cloud. @@ -920,26 +920,26 @@ Constructs a CloudNormalsWidget. .. note:: In case there are four channels in the cloud, fourth channel is ignored. -viz::MeshWidget ---------------- -.. ocv:class:: MeshWidget +viz::WMesh +---------- +.. ocv:class:: WMesh This 3D Widget defines a mesh. :: - class CV_EXPORTS MeshWidget : public Widget3D + class CV_EXPORTS WMesh : public Widget3D { public: - MeshWidget(const Mesh3d &mesh); + WMesh(const Mesh3d &mesh); private: /* hidden */ }; -viz::MeshWidget::MeshWidget ---------------------------- -Constructs a MeshWidget. +viz::WMesh::WMesh +----------------- +Constructs a WMesh. -.. ocv:function:: MeshWidget(const Mesh3d &mesh) +.. ocv:function:: WMesh(const Mesh3d &mesh) :param mesh: :ocv:class:`Mesh3d` object that will be displayed. diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index e96022c..4d12b7a 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -134,173 +134,173 @@ namespace cv void setColor(const Color &color); }; - class CV_EXPORTS LineWidget : public Widget3D + class CV_EXPORTS WLine : public Widget3D { public: - LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); + WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); }; - class CV_EXPORTS PlaneWidget : public Widget3D + class CV_EXPORTS WPlane : public Widget3D { public: - PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()); - PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()); + WPlane(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()); + WPlane(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()); private: struct SetSizeImpl; }; - class CV_EXPORTS SphereWidget : public Widget3D + class CV_EXPORTS WSphere : public Widget3D { public: - SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()); + WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()); }; - class CV_EXPORTS ArrowWidget : public Widget3D + class CV_EXPORTS WArrow : public Widget3D { public: - ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); + WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); }; - class CV_EXPORTS CircleWidget : public Widget3D + class CV_EXPORTS WCircle : public Widget3D { public: - CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()); + WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()); }; - class CV_EXPORTS CylinderWidget : public Widget3D + class CV_EXPORTS WCylinder : public Widget3D { public: - CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); + WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); }; - class CV_EXPORTS CubeWidget : public Widget3D + class CV_EXPORTS WCube : public Widget3D { public: - CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); + WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); }; - class CV_EXPORTS CoordinateSystemWidget : public Widget3D + class CV_EXPORTS WCoordinateSystem : public Widget3D { public: - CoordinateSystemWidget(double scale = 1.0); + WCoordinateSystem(double scale = 1.0); }; - class CV_EXPORTS PolyLineWidget : public Widget3D + class CV_EXPORTS WPolyLine : public Widget3D { public: - PolyLineWidget(InputArray points, const Color &color = Color::white()); + WPolyLine(InputArray points, const Color &color = Color::white()); private: struct CopyImpl; }; - class CV_EXPORTS GridWidget : public Widget3D + class CV_EXPORTS WGrid : public Widget3D { public: //! Creates grid at the origin - GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); + WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); //! Creates grid based on the plane equation - GridWidget(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); + WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); private: struct GridImpl; }; - class CV_EXPORTS Text3DWidget : public Widget3D + class CV_EXPORTS WText3D : public Widget3D { public: - Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, bool face_camera = true, const Color &color = Color::white()); + WText3D(const String &text, const Point3f &position, double text_scale = 1.0, bool face_camera = true, const Color &color = Color::white()); void setText(const String &text); String getText() const; }; - class CV_EXPORTS TextWidget : public Widget2D + class CV_EXPORTS WText : public Widget2D { public: - TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()); + WText(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()); void setText(const String &text); String getText() const; }; - class CV_EXPORTS ImageOverlayWidget : public Widget2D + class CV_EXPORTS WImageOverlay : public Widget2D { public: - ImageOverlayWidget(const Mat &image, const Rect &rect); + WImageOverlay(const Mat &image, const Rect &rect); void setImage(const Mat &image); }; - class CV_EXPORTS Image3DWidget : public Widget3D + class CV_EXPORTS WImage3D : public Widget3D { public: //! Creates 3D image at the origin - Image3DWidget(const Mat &image, const Size &size); + WImage3D(const Mat &image, const Size &size); //! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation - Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); + WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); void setImage(const Mat &image); }; - class CV_EXPORTS CameraPositionWidget : public Widget3D + class CV_EXPORTS WCameraPosition : public Widget3D { public: //! Creates camera coordinate frame (axes) at the origin - CameraPositionWidget(double scale = 1.0); + WCameraPosition(double scale = 1.0); //! Creates frustum based on the intrinsic marix K at the origin - CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum based on the field of view at the origin - CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()); //! Creates frustum and display given image at the far plane - CameraPositionWidget(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()); + WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white()); private: struct ProjectImage; }; - class CV_EXPORTS TrajectoryWidget : public Widget3D + class CV_EXPORTS WTrajectory : public Widget3D { public: enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2}; //! Displays trajectory of the given path either by coordinate frames or polyline - TrajectoryWidget(const std::vector &path, int display_mode = TrajectoryWidget::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0); + WTrajectory(const std::vector &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0); //! Displays trajectory of the given path by frustums - TrajectoryWidget(const std::vector &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); + WTrajectory(const std::vector &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); //! Displays trajectory of the given path by frustums - TrajectoryWidget(const std::vector &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); + WTrajectory(const std::vector &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); private: struct ApplyPath; }; - class CV_EXPORTS SpheresTrajectoryWidget : public Widget3D + class CV_EXPORTS WSpheresTrajectory: public Widget3D { public: - SpheresTrajectoryWidget(const std::vector &path, float line_length = 0.05f, double init_sphere_radius = 0.021, + WSpheresTrajectory(const std::vector &path, float line_length = 0.05f, double init_sphere_radius = 0.021, double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()); }; - class CV_EXPORTS CloudWidget : public Widget3D + class CV_EXPORTS WCloud: public Widget3D { public: //! Each point in cloud is mapped to a color in colors - CloudWidget(InputArray cloud, InputArray colors); + WCloud(InputArray cloud, InputArray colors); //! All points in cloud have the same color - CloudWidget(InputArray cloud, const Color &color = Color::white()); + WCloud(InputArray cloud, const Color &color = Color::white()); private: struct CreateCloudWidget; }; - class CV_EXPORTS CloudCollectionWidget : public Widget3D + class CV_EXPORTS WCloudCollection : public Widget3D { public: - CloudCollectionWidget(); + WCloudCollection(); //! Each point in cloud is mapped to a color in colors void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity()); @@ -311,19 +311,19 @@ namespace cv struct CreateCloudWidget; }; - class CV_EXPORTS CloudNormalsWidget : public Widget3D + class CV_EXPORTS WCloudNormals : public Widget3D { public: - CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); + WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); private: struct ApplyCloudNormals; }; - class CV_EXPORTS MeshWidget : public Widget3D + class CV_EXPORTS WMesh : public Widget3D { public: - MeshWidget(const Mesh3d &mesh); + WMesh(const Mesh3d &mesh); private: struct CopyImpl; @@ -331,27 +331,27 @@ namespace cv template<> CV_EXPORTS Widget2D Widget::cast(); template<> CV_EXPORTS Widget3D Widget::cast(); - template<> CV_EXPORTS LineWidget Widget::cast(); - template<> CV_EXPORTS PlaneWidget Widget::cast(); - template<> CV_EXPORTS SphereWidget Widget::cast(); - template<> CV_EXPORTS CylinderWidget Widget::cast(); - template<> CV_EXPORTS ArrowWidget Widget::cast(); - template<> CV_EXPORTS CircleWidget Widget::cast(); - template<> CV_EXPORTS CubeWidget Widget::cast(); - template<> CV_EXPORTS CoordinateSystemWidget Widget::cast(); - template<> CV_EXPORTS PolyLineWidget Widget::cast(); - template<> CV_EXPORTS GridWidget Widget::cast(); - template<> CV_EXPORTS Text3DWidget Widget::cast(); - template<> CV_EXPORTS TextWidget Widget::cast(); - template<> CV_EXPORTS ImageOverlayWidget Widget::cast(); - template<> CV_EXPORTS Image3DWidget Widget::cast(); - template<> CV_EXPORTS CameraPositionWidget Widget::cast(); - template<> CV_EXPORTS TrajectoryWidget Widget::cast(); - template<> CV_EXPORTS SpheresTrajectoryWidget Widget::cast(); - template<> CV_EXPORTS CloudWidget Widget::cast(); - template<> CV_EXPORTS CloudCollectionWidget Widget::cast(); - template<> CV_EXPORTS CloudNormalsWidget Widget::cast(); - template<> CV_EXPORTS MeshWidget Widget::cast(); + template<> CV_EXPORTS WLine Widget::cast(); + template<> CV_EXPORTS WPlane Widget::cast(); + template<> CV_EXPORTS WSphere Widget::cast(); + template<> CV_EXPORTS WCylinder Widget::cast(); + template<> CV_EXPORTS WArrow Widget::cast(); + template<> CV_EXPORTS WCircle Widget::cast(); + template<> CV_EXPORTS WCube Widget::cast(); + template<> CV_EXPORTS WCoordinateSystem Widget::cast(); + template<> CV_EXPORTS WPolyLine Widget::cast(); + template<> CV_EXPORTS WGrid Widget::cast(); + template<> CV_EXPORTS WText3D Widget::cast(); + template<> CV_EXPORTS WText Widget::cast(); + template<> CV_EXPORTS WImageOverlay Widget::cast(); + template<> CV_EXPORTS WImage3D Widget::cast(); + template<> CV_EXPORTS WCameraPosition Widget::cast(); + template<> CV_EXPORTS WTrajectory Widget::cast(); + template<> CV_EXPORTS WSpheresTrajectory Widget::cast(); + template<> CV_EXPORTS WCloud Widget::cast(); + template<> CV_EXPORTS WCloudCollection Widget::cast(); + template<> CV_EXPORTS WCloudNormals Widget::cast(); + template<> CV_EXPORTS WMesh Widget::cast(); } /* namespace viz */ } /* namespace cv */ diff --git a/modules/viz/src/cloud_widgets.cpp b/modules/viz/src/cloud_widgets.cpp index ec6c203..0149f90 100644 --- a/modules/viz/src/cloud_widgets.cpp +++ b/modules/viz/src/cloud_widgets.cpp @@ -59,7 +59,7 @@ namespace cv /////////////////////////////////////////////////////////////////////////////////////////////// /// Point Cloud Widget implementation -struct cv::viz::CloudWidget::CreateCloudWidget +struct cv::viz::WCloud::CreateCloudWidget { static inline vtkSmartPointer create(const Mat &cloud, vtkIdType &nr_points) { @@ -146,7 +146,7 @@ struct cv::viz::CloudWidget::CreateCloudWidget } }; -cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors) +cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors) { Mat cloud = _cloud.getMat(); Mat colors = _colors.getMat(); @@ -201,7 +201,7 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors) WidgetAccessor::setProp(*this, actor); } -cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color) +cv::viz::WCloud::WCloud(InputArray _cloud, const Color &color) { Mat cloud = _cloud.getMat(); CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4); @@ -233,16 +233,16 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color) setColor(color); } -template<> cv::viz::CloudWidget cv::viz::Widget::cast() +template<> cv::viz::WCloud cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// Cloud Collection Widget implementation -struct cv::viz::CloudCollectionWidget::CreateCloudWidget +struct cv::viz::WCloudCollection::CreateCloudWidget { static inline vtkSmartPointer create(const Mat &cloud, vtkIdType &nr_points) { @@ -376,14 +376,14 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget } }; -cv::viz::CloudCollectionWidget::CloudCollectionWidget() +cv::viz::WCloudCollection::WCloudCollection() { // Just create the actor vtkSmartPointer actor = vtkSmartPointer::New(); WidgetAccessor::setProp(*this, actor); } -void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _colors, const Affine3f &pose) +void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors, const Affine3f &pose) { Mat cloud = _cloud.getMat(); Mat colors = _colors.getMat(); @@ -432,7 +432,7 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _col CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax); } -void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &color, const Affine3f &pose) +void cv::viz::WCloudCollection::addCloud(InputArray _cloud, const Color &color, const Affine3f &pose) { Mat cloud = _cloud.getMat(); CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4); @@ -471,16 +471,16 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &co CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax); } -template<> cv::viz::CloudCollectionWidget cv::viz::Widget::cast() +template<> cv::viz::WCloudCollection cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// Cloud Normals Widget implementation -struct cv::viz::CloudNormalsWidget::ApplyCloudNormals +struct cv::viz::WCloudNormals::ApplyCloudNormals { template struct Impl @@ -555,7 +555,7 @@ struct cv::viz::CloudNormalsWidget::ApplyCloudNormals } }; -cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _normals, int level, float scale, const Color &color) +cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, int level, float scale, const Color &color) { Mat cloud = _cloud.getMat(); Mat normals = _normals.getMat(); @@ -610,16 +610,16 @@ cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _n setColor(color); } -template<> cv::viz::CloudNormalsWidget cv::viz::Widget::cast() +template<> cv::viz::WCloudNormals cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// Mesh Widget implementation -struct cv::viz::MeshWidget::CopyImpl +struct cv::viz::WMesh::CopyImpl { template static Vec<_Tp, 3> * copy(const Mat &source, Vec<_Tp, 3> *output, int *look_up, const Mat &nan_mask) @@ -648,7 +648,7 @@ struct cv::viz::MeshWidget::CopyImpl } }; -cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh) +cv::viz::WMesh::WMesh(const Mesh3d &mesh) { CV_Assert(mesh.cloud.rows == 1 && (mesh.cloud.type() == CV_32FC3 || mesh.cloud.type() == CV_64FC3 || mesh.cloud.type() == CV_32FC4 || mesh.cloud.type() == CV_64FC4)); CV_Assert(mesh.colors.empty() || (mesh.colors.type() == CV_8UC3 && mesh.cloud.size() == mesh.colors.size())); @@ -766,8 +766,8 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh) WidgetAccessor::setProp(*this, actor); } -template<> CV_EXPORTS cv::viz::MeshWidget cv::viz::Widget::cast() +template<> CV_EXPORTS cv::viz::WMesh cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } diff --git a/modules/viz/src/shape_widgets.cpp b/modules/viz/src/shape_widgets.cpp index 45a653d..b253237 100644 --- a/modules/viz/src/shape_widgets.cpp +++ b/modules/viz/src/shape_widgets.cpp @@ -58,7 +58,7 @@ namespace cv /////////////////////////////////////////////////////////////////////////////////////////////// /// line widget implementation -cv::viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color) +cv::viz::WLine::WLine(const Point3f &pt1, const Point3f &pt2, const Color &color) { vtkSmartPointer line = vtkSmartPointer::New(); line->SetPoint1(pt1.x, pt1.y, pt1.z); @@ -75,16 +75,16 @@ cv::viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Co setColor(color); } -template<> cv::viz::LineWidget cv::viz::Widget::cast() +template<> cv::viz::WLine cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// plane widget implementation -struct cv::viz::PlaneWidget::SetSizeImpl +struct cv::viz::WPlane::SetSizeImpl { template static vtkSmartPointer setSize(const Vec<_Tp, 3> ¢er, vtkSmartPointer poly_data_port, double size) @@ -104,7 +104,7 @@ struct cv::viz::PlaneWidget::SetSizeImpl } }; -cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color) +cv::viz::WPlane::WPlane(const Vec4f& coefs, double size, const Color &color) { vtkSmartPointer plane = vtkSmartPointer::New(); plane->SetNormal(coefs[0], coefs[1], coefs[2]); @@ -124,7 +124,7 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color & setColor(color); } -cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color) +cv::viz::WPlane::WPlane(const Vec4f& coefs, const Point3f& pt, double size, const Color &color) { vtkSmartPointer plane = vtkSmartPointer::New(); Point3f coefs3(coefs[0], coefs[1], coefs[2]); @@ -145,16 +145,16 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double setColor(color); } -template<> cv::viz::PlaneWidget cv::viz::Widget::cast() +template<> cv::viz::WPlane cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// sphere widget implementation -cv::viz::SphereWidget::SphereWidget(const Point3f ¢er, float radius, int sphere_resolution, const Color &color) +cv::viz::WSphere::WSphere(const Point3f ¢er, float radius, int sphere_resolution, const Color &color) { vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetRadius(radius); @@ -174,16 +174,16 @@ cv::viz::SphereWidget::SphereWidget(const Point3f ¢er, float radius, int sph setColor(color); } -template<> cv::viz::SphereWidget cv::viz::Widget::cast() +template<> cv::viz::WSphere cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// arrow widget implementation -cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness, const Color &color) +cv::viz::WArrow::WArrow(const Point3f& pt1, const Point3f& pt2, double thickness, const Color &color) { vtkSmartPointer arrowSource = vtkSmartPointer::New(); arrowSource->SetShaftRadius(thickness); @@ -247,16 +247,16 @@ cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, double setColor(color); } -template<> cv::viz::ArrowWidget cv::viz::Widget::cast() +template<> cv::viz::WArrow cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// circle widget implementation -cv::viz::CircleWidget::CircleWidget(const Point3f& pt, double radius, double thickness, const Color& color) +cv::viz::WCircle::WCircle(const Point3f& pt, double radius, double thickness, const Color& color) { vtkSmartPointer disk = vtkSmartPointer::New(); // Maybe the resolution should be lower e.g. 50 or 25 @@ -283,16 +283,16 @@ cv::viz::CircleWidget::CircleWidget(const Point3f& pt, double radius, double thi setColor(color); } -template<> cv::viz::CircleWidget cv::viz::Widget::cast() +template<> cv::viz::WCircle cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// cylinder widget implementation -cv::viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color) +cv::viz::WCylinder::WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color) { const Point3f pt2 = pt_on_axis + axis_direction; vtkSmartPointer line = vtkSmartPointer::New(); @@ -314,16 +314,16 @@ cv::viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f setColor(color); } -template<> cv::viz::CylinderWidget cv::viz::Widget::cast() +template<> cv::viz::WCylinder cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// cylinder widget implementation -cv::viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color) +cv::viz::WCube::WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color) { vtkSmartPointer mapper = vtkSmartPointer::New(); if (wire_frame) @@ -346,16 +346,16 @@ cv::viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bo setColor(color); } -template<> cv::viz::CubeWidget cv::viz::Widget::cast() +template<> cv::viz::WCube cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// coordinate system widget implementation -cv::viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale) +cv::viz::WCoordinateSystem::WCoordinateSystem(double scale) { vtkSmartPointer axes = vtkSmartPointer::New(); axes->SetOrigin(0, 0, 0); @@ -397,16 +397,16 @@ cv::viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale) WidgetAccessor::setProp(*this, actor); } -template<> cv::viz::CoordinateSystemWidget cv::viz::Widget::cast() +template<> cv::viz::WCoordinateSystem cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// polyline widget implementation -struct cv::viz::PolyLineWidget::CopyImpl +struct cv::viz::WPolyLine::CopyImpl { template static void copy(const Mat& source, Vec<_Tp, 3> *output, vtkSmartPointer polyLine) @@ -426,7 +426,7 @@ struct cv::viz::PolyLineWidget::CopyImpl } }; -cv::viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &color) +cv::viz::WPolyLine::WPolyLine(InputArray _pointData, const Color &color) { Mat pointData = _pointData.getMat(); CV_Assert(pointData.type() == CV_32FC3 || pointData.type() == CV_32FC4 || pointData.type() == CV_64FC3 || pointData.type() == CV_64FC4); @@ -477,16 +477,16 @@ cv::viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &colo setColor(color); } -template<> cv::viz::PolyLineWidget cv::viz::Widget::cast() +template<> cv::viz::WPolyLine cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// grid widget implementation -struct cv::viz::GridWidget::GridImpl +struct cv::viz::WGrid::GridImpl { static vtkSmartPointer createGrid(const Vec2i &dimensions, const Vec2d &spacing) { @@ -513,7 +513,7 @@ struct cv::viz::GridWidget::GridImpl } }; -cv::viz::GridWidget::GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color) +cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color) { vtkSmartPointer grid = GridImpl::createGrid(dimensions, spacing); @@ -531,7 +531,7 @@ cv::viz::GridWidget::GridWidget(const Vec2i &dimensions, const Vec2d &spacing, c setColor(color); } -cv::viz::GridWidget::GridWidget(const Vec4f &coefs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color) +cv::viz::WGrid::WGrid(const Vec4f &coefs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color) { vtkSmartPointer grid = GridImpl::createGrid(dimensions, spacing); @@ -584,16 +584,16 @@ cv::viz::GridWidget::GridWidget(const Vec4f &coefs, const Vec2i &dimensions, con setColor(color); } -template<> cv::viz::GridWidget cv::viz::Widget::cast() +template<> cv::viz::WGrid cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// text3D widget implementation -cv::viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, double text_scale, bool face_camera, const Color &color) +cv::viz::WText3D::WText3D(const String &text, const Point3f &position, double text_scale, bool face_camera, const Color &color) { vtkSmartPointer textSource = vtkSmartPointer::New(); textSource->SetText(text.c_str()); @@ -622,7 +622,7 @@ cv::viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, setColor(color); } -void cv::viz::Text3DWidget::setText(const String &text) +void cv::viz::WText3D::setText(const String &text) { vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this)); CV_Assert("This widget does not support text." && actor); @@ -636,7 +636,7 @@ void cv::viz::Text3DWidget::setText(const String &text) textSource->Update(); } -cv::String cv::viz::Text3DWidget::getText() const +cv::String cv::viz::WText3D::getText() const { vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this)); CV_Assert("This widget does not support text." && actor); @@ -648,16 +648,16 @@ cv::String cv::viz::Text3DWidget::getText() const return textSource->GetText(); } -template<> cv::viz::Text3DWidget cv::viz::Widget::cast() +template<> cv::viz::WText3D cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// text widget implementation -cv::viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font_size, const Color &color) +cv::viz::WText::WText(const String &text, const Point2i &pos, int font_size, const Color &color) { vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetPosition(pos.x, pos.y); @@ -675,20 +675,20 @@ cv::viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font WidgetAccessor::setProp(*this, actor); } -template<> cv::viz::TextWidget cv::viz::Widget::cast() +template<> cv::viz::WText cv::viz::Widget::cast() { Widget2D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } -void cv::viz::TextWidget::setText(const String &text) +void cv::viz::WText::setText(const String &text) { vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this)); CV_Assert("This widget does not support text." && actor); actor->SetInput(text.c_str()); } -cv::String cv::viz::TextWidget::getText() const +cv::String cv::viz::WText::getText() const { vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this)); CV_Assert("This widget does not support text." && actor); @@ -698,7 +698,7 @@ cv::String cv::viz::TextWidget::getText() const /////////////////////////////////////////////////////////////////////////////////////////////// /// image overlay widget implementation -cv::viz::ImageOverlayWidget::ImageOverlayWidget(const Mat &image, const Rect &rect) +cv::viz::WImageOverlay::WImageOverlay(const Mat &image, const Rect &rect) { CV_Assert(!image.empty() && image.depth() == CV_8U); @@ -739,7 +739,7 @@ cv::viz::ImageOverlayWidget::ImageOverlayWidget(const Mat &image, const Rect &re WidgetAccessor::setProp(*this, actor); } -void cv::viz::ImageOverlayWidget::setImage(const Mat &image) +void cv::viz::WImageOverlay::setImage(const Mat &image) { CV_Assert(!image.empty() && image.depth() == CV_8U); @@ -766,16 +766,16 @@ void cv::viz::ImageOverlayWidget::setImage(const Mat &image) mapper->SetInputConnection(flipFilter->GetOutputPort()); } -template<> cv::viz::ImageOverlayWidget cv::viz::Widget::cast() +template<> cv::viz::WImageOverlay cv::viz::Widget::cast() { Widget2D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// image 3D widget implementation -cv::viz::Image3DWidget::Image3DWidget(const Mat &image, const Size &size) +cv::viz::WImage3D::WImage3D(const Mat &image, const Size &size) { CV_Assert(!image.empty() && image.depth() == CV_8U); @@ -827,7 +827,7 @@ cv::viz::Image3DWidget::Image3DWidget(const Mat &image, const Size &size) WidgetAccessor::setProp(*this, actor); } -cv::viz::Image3DWidget::Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) +cv::viz::WImage3D::WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) { CV_Assert(!image.empty() && image.depth() == CV_8U); @@ -901,7 +901,7 @@ cv::viz::Image3DWidget::Image3DWidget(const Vec3f &position, const Vec3f &normal WidgetAccessor::setProp(*this, actor); } -void cv::viz::Image3DWidget::setImage(const Mat &image) +void cv::viz::WImage3D::setImage(const Mat &image) { CV_Assert(!image.empty() && image.depth() == CV_8U); @@ -929,16 +929,16 @@ void cv::viz::Image3DWidget::setImage(const Mat &image) actor->SetTexture(texture); } -template<> cv::viz::Image3DWidget cv::viz::Widget::cast() +template<> cv::viz::WImage3D cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// camera position widget implementation -struct cv::viz::CameraPositionWidget::ProjectImage +struct cv::viz::WCameraPosition::ProjectImage { static void projectImage(float fovy, float far_end_height, const Mat &image, double scale, const Color &color, vtkSmartPointer actor) @@ -1032,7 +1032,7 @@ struct cv::viz::CameraPositionWidget::ProjectImage } }; -cv::viz::CameraPositionWidget::CameraPositionWidget(double scale) +cv::viz::WCameraPosition::WCameraPosition(double scale) { vtkSmartPointer axes = vtkSmartPointer::New(); axes->SetOrigin(0, 0, 0); @@ -1074,7 +1074,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(double scale) WidgetAccessor::setProp(*this, actor); } -cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double scale, const Color &color) +cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); float f_x = K(0,0); @@ -1116,7 +1116,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca } -cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double scale, const Color &color) +cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); @@ -1154,7 +1154,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double sca setColor(color); } -cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, const Mat &image, double scale, const Color &color) +cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, const Mat &image, double scale, const Color &color) { CV_Assert(!image.empty() && image.depth() == CV_8U); float f_y = K(1,1); @@ -1168,7 +1168,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, const Mat WidgetAccessor::setProp(*this, actor); } -cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, const Mat &image, double scale, const Color &color) +cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, const Mat &image, double scale, const Color &color) { CV_Assert(!image.empty() && image.depth() == CV_8U); float fovy = fov[1] * 180.0f / CV_PI; @@ -1179,16 +1179,16 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, const Mat WidgetAccessor::setProp(*this, actor); } -template<> cv::viz::CameraPositionWidget cv::viz::Widget::cast() +template<> cv::viz::WCameraPosition cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// trajectory widget implementation -struct cv::viz::TrajectoryWidget::ApplyPath +struct cv::viz::WTrajectory::ApplyPath { static void applyPath(vtkSmartPointer poly_data, vtkSmartPointer append_filter, const std::vector &path) { @@ -1220,12 +1220,12 @@ struct cv::viz::TrajectoryWidget::ApplyPath } }; -cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, int display_mode, const Color &color, double scale) +cv::viz::WTrajectory::WTrajectory(const std::vector &path, int display_mode, const Color &color, double scale) { vtkSmartPointer appendFilter = vtkSmartPointer::New(); // Bitwise and with 3 in order to limit the domain to 2 bits - if ((~display_mode & 3) ^ TrajectoryWidget::DISPLAY_PATH) + if ((~display_mode & 3) ^ WTrajectory::DISPLAY_PATH) { // Create a poly line along the path vtkIdType nr_points = path.size(); @@ -1269,7 +1269,7 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, i #endif } - if ((~display_mode & 3) ^ TrajectoryWidget::DISPLAY_FRAMES) + if ((~display_mode & 3) ^ WTrajectory::DISPLAY_FRAMES) { // Create frames and transform along the path vtkSmartPointer axes = vtkSmartPointer::New(); @@ -1316,7 +1316,7 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, i WidgetAccessor::setProp(*this, actor); } -cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, const Matx33f &K, double scale, const Color &color) +cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Matx33f &K, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); float f_x = K(0,0); @@ -1360,7 +1360,7 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, c setColor(color); } -cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, const Vec2f &fov, double scale, const Color &color) +cv::viz::WTrajectory::WTrajectory(const std::vector &path, const Vec2f &fov, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); @@ -1400,16 +1400,16 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector &path, c setColor(color); } -template<> cv::viz::TrajectoryWidget cv::viz::Widget::cast() +template<> cv::viz::WTrajectory cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } /////////////////////////////////////////////////////////////////////////////////////////////// /// spheres trajectory widget implementation -cv::viz::SpheresTrajectoryWidget::SpheresTrajectoryWidget(const std::vector &path, float line_length, double init_sphere_radius, double sphere_radius, +cv::viz::WSpheresTrajectory::WSpheresTrajectory(const std::vector &path, float line_length, double init_sphere_radius, double sphere_radius, const Color &line_color, const Color &sphere_color) { vtkSmartPointer appendFilter = vtkSmartPointer::New(); @@ -1490,8 +1490,8 @@ cv::viz::SpheresTrajectoryWidget::SpheresTrajectoryWidget(const std::vector cv::viz::SpheresTrajectoryWidget cv::viz::Widget::cast() +template<> cv::viz::WSpheresTrajectory cv::viz::Widget::cast() { Widget3D widget = this->cast(); - return static_cast(widget); + return static_cast(widget); } diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp index 5e9d13c..94804a9 100644 --- a/modules/viz/test/test_viz3d.cpp +++ b/modules/viz/test/test_viz3d.cpp @@ -41,15 +41,9 @@ //M*/ #include "test_precomp.hpp" #include -#include -#include #include -#include - -#include #include -#include using namespace cv; cv::Mat cvcloud_load() @@ -68,226 +62,121 @@ cv::Mat cvcloud_load() return cloud; } -TEST(Viz_viz3d, accuracy) -{ - cv::Mat cloud = cvcloud_load(); - cv::Mat colors(cloud.size(), CV_8UC3, cv::Scalar(0, 255, 0)); - cv::Mat normals(cloud.size(), cloud.type(), cv::Scalar(0, 10, 0)); - //cv::viz::Mesh3d::Ptr mesh = cv::viz::Mesh3d::mesh_load("/Users/nerei/horse.ply"); +bool constant_cam = true; +cv::viz::Widget cam_1, cam_coordinates; - const Vec4d data[] = { Vec4d(0.0, 0.0, 0.0, 0.0), Vec4d(1.0, 1.0, 1.0, 1.0), cv::Vec4d(0.0, 2.0, 0.0, 0.0), cv::Vec4d(3.0, 4.0, 1.0, 1.0) }; - cv::Mat points(1, sizeof(data)/sizeof(data[0]), CV_64FC4, (void*)data); - points = points.reshape(4, 2); +void keyboard_callback(const viz::KeyboardEvent & event, void * cookie) +{ + if (event.keyDown()) + { + if (event.getKeySym() == "space") + { + viz::Viz3d &viz = *((viz::Viz3d *) cookie); + constant_cam = !constant_cam; + if (constant_cam) + { + viz.showWidget("cam_1", cam_1); + viz.showWidget("cam_coordinate", cam_coordinates); + viz.showWidget("cam_text", viz::WText("Global View", Point2i(5,5), 28)); + viz.resetCamera(); + } + else + { + viz.showWidget("cam_text", viz::WText("Cam View", Point2i(5,5), 28)); + viz.removeWidget("cam_1"); + viz.removeWidget("cam_coordinate"); + } + } + } +} +TEST(Viz_viz3d, accuracy) +{ cv::viz::Viz3d viz("abc"); - viz.setBackgroundColor(); - - Vec3f angle = Vec3f::all(0); - Vec3f pos = Vec3f::all(0); - //viz.addPolygonMesh(*mesh, "pq"); + cv::viz::Mesh3d bunny_mesh = cv::viz::Mesh3d::loadMesh("bunny.ply"); + cv::viz::WMesh bunny_widget(bunny_mesh); + bunny_widget.setColor(cv::viz::Color::cyan()); - viz::Color color = viz::Color::black(); + cam_1 = cv::viz::WCameraPosition(cv::Vec2f(0.6, 0.4), 0.2, cv::viz::Color::green()); + cam_coordinates = cv::viz::WCameraPosition(0.2); - viz::LineWidget lw(Point3f(0, 0, 0), Point3f(4.f, 4.f,4.f), viz::Color::green()); - viz::PlaneWidget pw(Vec4f(0.0,1.0,2.0,3.0)); - viz::PlaneWidget pw2(Vec4f(0.0,1.0,2.0,3.0), 2.0, viz::Color::red()); - viz::PlaneWidget pw3(Vec4f(0.0,1.0,2.0,3.0), 3.0, viz::Color::blue()); - viz::SphereWidget sw(Point3f(0, 0, 0), 0.2); - viz::ArrowWidget aw(Point3f(0, 0, 0), Point3f(1, 1, 1), 0.01, viz::Color::red()); - viz::CircleWidget cw(Point3f(0, 0, 0), 0.5, 0.01, viz::Color::green()); - viz::CylinderWidget cyw(Point3f(0, 0, 0), Point3f(-1, -1, -1), 0.5, 30, viz::Color::green()); - viz::CubeWidget cuw(Point3f(-2, -2, -2), Point3f(-1, -1, -1)); - viz::CoordinateSystemWidget csw; - viz::TextWidget tw("TEST", Point(100, 100), 20); - viz::CloudWidget pcw(cloud, colors); -// pcw.setRenderingProperty(VIZ_LINE_WIDTH)); - viz::CloudWidget pcw2(cloud, viz::Color::magenta()); - -// viz.showWidget("line", lw); - viz.showWidget("plane", pw); - viz.showWidget("plane2", pw2); - viz.showWidget("plane3", pw3); -// viz.showWidget("sphere", sw); -// viz.showWidget("arrow", aw); -// viz.showWidget("circle", cw); -// viz.showWidget("cylinder", cyw); -// viz.showWidget("cube", cuw); - viz.showWidget("coordinateSystem", csw); -// viz.showWidget("coordinateSystem2", viz::CoordinateSystemWidget(2.0), Affine3f().translate(Vec3f(2, 0, 0))); -// viz.showWidget("text",tw); -// viz.showWidget("pcw",pcw); -// viz.showWidget("pcw2",pcw2); - -// viz::LineWidget lw2 = lw; -// v.showPointCloud("cld",cloud, colors); + viz.showWidget("bunny", bunny_widget); + viz.showWidget("cam_1", cam_1, viz::makeCameraPose(Point3f(1.0,0.0,0.0), Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0))); + viz.showWidget("cam_coordinate", cam_coordinates, viz::makeCameraPose(Point3f(1.0,0.0,0.0), Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0))); -// v.addPointCloudNormals(cloud, normals, 100, 0.02, "n"); - //viz::CloudNormalsWidget cnw(cloud, normals); - //v.showWidget("n", cnw); + std::vector cam_path; + for (int i = 0, j = 0; i <= 360; ++i, j+=5) + { + cam_path.push_back(viz::makeCameraPose(Point3f(0.5*cos(double(i)*CV_PI/180.0), 0.5*sin(double(j)*CV_PI/180.0), 0.5*sin(double(i)*CV_PI/180.0)), + Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0))); + } + + int path_counter = 0; + int cam_path_size = cam_path.size(); + + // OTHER WIDGETS + cv::Mat img = imread("opencv.png"); -// lw = v.getWidget("n").cast(); -// pw = v.getWidget("n").cast(); - - - viz::PolyLineWidget plw(points, viz::Color::green()); -// viz.showWidget("polyline", plw); -// lw = v.getWidget("polyline").cast(); - - viz::Mesh3d mesh = cv::viz::Mesh3d::loadMesh("/Users/nerei/horse.ply"); - -// viz::MeshWidget mw(mesh); -// viz.showWidget("mesh", mw); - - Mat img = imread("opencv.png"); -// resize(img, img, Size(50,50)); -// viz.showWidget("img", viz::ImageOverlayWidget(img, Point2i(50,50))); - - Matx33f K(657, 0, 320, - 0, 657, 240, - 0, 0, 1); - - //viz::CameraPositionWidget cpw(Vec3f(0.5, 0.5, 3.0), Vec3f(0.0,0.0,0.0), Vec3f(0.0,-1.0,0.0), 0.5); - viz::CameraPositionWidget cpw2(0.5); - viz::CameraPositionWidget frustum(K, 2.0, viz::Color::green()); -// viz::CameraPositionWidget frustum2(K, 4.0, viz::Color::red()); - viz::CameraPositionWidget frustum2(K, 4.0, viz::Color::red()); - viz::CameraPositionWidget frustum3(Vec2f(CV_PI, CV_PI/2), 4.0); - viz::Text3DWidget t3w1("Camera1", Point3f(0.4, 0.6, 3.0), 0.1); - viz::Text3DWidget t3w2("Camera2", Point3f(0,0,0), 0.1); - -// viz.showWidget("CameraPositionWidget", cpw); -// viz.showWidget("CameraPositionWidget2", cpw2, Affine3f(0.524, 0, 0, Vec3f(-1.0, 0.5, 0.5))); -// viz.showWidget("camera_label", t3w1); -// viz.showWidget("camera_label2", t3w2, Affine3f(0.524, 0, 0, Vec3f(-1.0, 0.5, 0.5))); -// viz.showWidget("frustrum", frustum, Affine3f(0.524, 0, 0, Vec3f(-1.0, 0.5, 0.5))); -// viz.showWidget("frustrum2", frustum2, Affine3f(0.524, 0, 0, Vec3f(-1.0, 0.5, 0.5))); -// viz.showWidget("frustum3", frustum3, Affine3f(0.524, 0, 0, Vec3f(-1.0, 0.5, 0.5))); - - std::vector trajectory; - - trajectory.push_back(Affine3f().translate(Vec3f(0.5,0.5,0.5))); - trajectory.push_back(Affine3f().translate(Vec3f(1.0,0.0,0.0))); - trajectory.push_back(Affine3f().translate(Vec3f(2.0,0.5,0.0))); - trajectory.push_back(Affine3f(0.5, 0.0, 0.0, Vec3f(1.0,0.0,1.0))); -// - //viz.showWidget("trajectory1", viz::TrajectoryWidget(trajectory, viz::Color(0,255,255), true, 0.5)); - viz.showWidget("trajectory2", viz::TrajectoryWidget(trajectory, K, 1.0, viz::Color(255,0,255))); - -// cv::Rodrigues2(Vec3f(), Mat()); + int downSample = 4; + int row_max = img.rows/downSample; + int col_max = img.cols/downSample; -// viz.showWidget("trajectory1", viz::TrajectoryWidget(trajectory/*, viz::Color::yellow()*/)); + cv::Mat clouds[img.cols/downSample]; + cv::Mat colors[img.cols/downSample]; -// viz.showWidget("CameraPositionWidget2", cpw2); -// viz.showWidget("CameraPositionWidget3", cpw3); + for (int col = 0; col < col_max; ++col) + { + clouds[col] = Mat::zeros(img.rows/downSample, 1, CV_32FC3); + colors[col] = Mat::zeros(img.rows/downSample, 1, CV_8UC3); + for (int row = 0; row < row_max; ++row) + { + clouds[col].at(row) = Vec3f(downSample * float(col) / img.cols, 1.0-(downSample * float(row) / img.rows), 0.0); + colors[col].at(row) = img.at(row*downSample,col*downSample); + } + } - viz.spin(); - - //viz::GridWidget gw(viz::Vec2i(100,100), viz::Vec2d(1,1)); - //v.showWidget("grid", gw); -// lw = viz.getWidget("grid").cast(); + for (int col = 0; col < col_max; ++col) + { + std::stringstream strstrm; + strstrm << "cloud_" << col; + viz.showWidget(strstrm.str(), viz::WCloud(clouds[col], colors[col])); + viz.getWidget(strstrm.str()).setRenderingProperty(viz::POINT_SIZE, 3.0); + viz.getWidget(strstrm.str()).setRenderingProperty(viz::OPACITY, 0.45); + } - //viz::Text3DWidget t3w("OpenCV", cv::Point3f(0.0, 2.0, 0.0), 1.0, viz::Color(255,255,0)); - //v.showWidget("txt3d", t3w); + viz.showWidget("trajectory", viz::WTrajectory(cam_path, viz::WTrajectory::DISPLAY_PATH, viz::Color::yellow())); + viz.showWidget("cam_text", viz::WText("Global View", Point2i(5,5), 28)); + viz.registerKeyboardCallback(keyboard_callback, (void *) &viz); -// float grid_x_angle = 0.0; - + int angle = 0; while(!viz.wasStopped()) { - // Creating new point cloud with id cloud1 - cv::Affine3f cloudPosition(angle, pos); - cv::Affine3f cloudPosition2(angle, pos + Vec3f(0.2f, 0.2f, 0.2f)); - - lw.setColor(color); -// lw.setLineWidth(pos_x * 10); - - //plw.setColor(viz::Color(col_blue, col_green, col_red)); - -// sw.setPose(cloudPosition); -// pw.setPose(cloudPosition); - aw.setPose(cloudPosition); - cw.setPose(cloudPosition); - cyw.setPose(cloudPosition); - - frustum.setPose(cloudPosition); -// lw.setPose(cloudPosition); -// cpw.updatePose(Affine3f(0.1,0.0,0.0, cv::Vec3f(0.0,0.0,0.0))); -// cpw.setPose(cloudPosition); -// cnw.setPose(cloudPosition); -// v.showWidget("pcw",pcw, cloudPosition); -// v.showWidget("pcw2",pcw2, cloudPosition2); -// v.showWidget("plane", pw, cloudPosition); - -// v.setWidgetPose("n",cloudPosition); -// v.setWidgetPose("pcw2", cloudPosition); - //cnw.setColor(viz::Color(col_blue, col_green, col_red)); - //pcw2.setColor(viz::Color(col_blue, col_green, col_red)); - - //gw.updatePose(viz::Affine3f(0.0, 0.1, 0.0, cv::Vec3f(0.0,0.0,0.0))); + if (path_counter == cam_path_size) + { + path_counter = 0; + } + + if (!constant_cam) + { + viz.setViewerPose(cam_path[path_counter]); + } - angle[0] += 0.1f; - angle[1] -= 0.1f; - angle[2] += 0.1f; - pos[0] = std::sin(angle[0]); - pos[1] = std::sin(angle[1]); - pos[2] = std::sin(angle[2]); + if (angle == 360) angle = 0; - color[0] = int(angle[0] * 10) % 256; - color[1] = int(angle[0] * 20) % 256; - color[2] = int(angle[0] * 30) % 256; - - viz.spinOnce(1, true); + cam_1.cast().setPose(cam_path[path_counter]); + cam_coordinates.cast().setPose(cam_path[path_counter++]); + + for (int i = 0; i < col_max; ++i) + { + std::stringstream strstrm; + strstrm << "cloud_" << i; + viz.setWidgetPose(strstrm.str(), Affine3f().translate(Vec3f(-0.5,0.0, -0.7 + 0.2*sin((angle+i*10)*CV_PI / 180.0)))); + } + angle += 10; + viz.spinOnce(42, true); } - - -// -// -// viz::ModelCoefficients mc; -// mc.values.resize(4); -// mc.values[0] = mc.values[1] = mc.values[2] = mc.values[3] = 1; -// v.addPlane(mc); -// -// -// viz::Mesh3d::Ptr mesh = viz::mesh_load("horse.ply"); -// v.addPolygonMesh(*mesh, "pq"); -// -// v.spinOnce(1000, true); -// -// v.removeCoordinateSystem(); -// -// for(int i = 0; i < mesh->cloud.cols; ++i) -// mesh->cloud.ptr()[i] += cv::Point3f(1, 1, 1); -// -// v.updatePolygonMesh(*mesh, "pq"); -// -// -// for(int i = 0; i < mesh->cloud.cols; ++i) -// mesh->cloud.ptr()[i] -= cv::Point3f(2, 2, 2); -// v.addPolylineFromPolygonMesh(*mesh); -// -// -// v.addText("===Abd sadfljsadlk", 100, 100, cv::Scalar(255, 0, 0), 15); -// for(int i = 0; i < cloud.cols; ++i) -// cloud.ptr()[i].x *=2; -// -// colors.setTo(cv::Scalar(255, 0, 0)); -// -// v.addSphere(cv::Point3f(0, 0, 0), 0.3, viz::Color::blue()); -// -// cv::Mat cvpoly(1, 5, CV_32FC3); -// cv::Point3f* pdata = cvpoly.ptr(); -// pdata[0] = cv::Point3f(0, 0, 0); -// pdata[1] = cv::Point3f(0, 1, 1); -// pdata[2] = cv::Point3f(3, 1, 2); -// pdata[3] = cv::Point3f(0, 2, 4); -// pdata[4] = cv::Point3f(7, 2, 3); -// v.addPolygon(cvpoly, viz::Color::white()); -// -// // Updating cloud1 -// v.showPointCloud("cloud1", cloud, colors); -// v.spin(); } - diff --git a/samples/cpp/tutorial_code/viz/creating_widgets.cpp b/samples/cpp/tutorial_code/viz/creating_widgets.cpp index f5fdd92..6366502 100644 --- a/samples/cpp/tutorial_code/viz/creating_widgets.cpp +++ b/samples/cpp/tutorial_code/viz/creating_widgets.cpp @@ -39,17 +39,17 @@ void help() * @class TriangleWidget * @brief Defining our own 3D Triangle widget */ -class TriangleWidget : public viz::Widget3D +class WTriangle : public viz::Widget3D { public: - TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); + WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white()); }; /** * @function TriangleWidget::TriangleWidget * @brief Constructor */ -TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color) +WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color) { // Create a triangle vtkSmartPointer points = vtkSmartPointer::New(); @@ -101,7 +101,7 @@ int main() viz::Viz3d myWindow("Creating Widgets"); /// Create a triangle widget - TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); + WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red()); /// Show widget in the visualizer window myWindow.showWidget("TRIANGLE", tw); diff --git a/samples/cpp/tutorial_code/viz/transformations.cpp b/samples/cpp/tutorial_code/viz/transformations.cpp index d357f4a..1748cd5 100644 --- a/samples/cpp/tutorial_code/viz/transformations.cpp +++ b/samples/cpp/tutorial_code/viz/transformations.cpp @@ -68,7 +68,7 @@ int main(int argn, char **argv) viz::Viz3d myWindow("Coordinate Frame"); /// Add coordinate axes - myWindow.showWidget("Coordinate Widget", viz::CoordinateSystemWidget()); + myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem()); /// Let's assume camera has the following properties Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f); @@ -82,7 +82,7 @@ int main(int argn, char **argv) /// Create a cloud widget. Mat bunny_cloud = cvcloud_load(); - viz::CloudWidget cloud_widget(bunny_cloud, viz::Color::green()); + viz::WCloud cloud_widget(bunny_cloud, viz::Color::green()); /// Pose of the widget in camera frame Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f)); @@ -92,8 +92,8 @@ int main(int argn, char **argv) /// Visualize camera frame if (!camera_pov) { - viz::CameraPositionWidget cpw(0.5); // Coordinate axes - viz::CameraPositionWidget cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum + viz::WCameraPosition cpw(0.5); // Coordinate axes + viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum myWindow.showWidget("CPW", cpw, cam_pose); myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose); } diff --git a/samples/cpp/tutorial_code/viz/widget_pose.cpp b/samples/cpp/tutorial_code/viz/widget_pose.cpp index d83ac6b..03c8810 100644 --- a/samples/cpp/tutorial_code/viz/widget_pose.cpp +++ b/samples/cpp/tutorial_code/viz/widget_pose.cpp @@ -37,15 +37,15 @@ int main() viz::Viz3d myWindow("Coordinate Frame"); /// Add coordinate axes - myWindow.showWidget("Coordinate Widget", viz::CoordinateSystemWidget()); + myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem()); /// Add line to represent (1,1,1) axis - viz::LineWidget axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); + viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f)); axis.setRenderingProperty(viz::LINE_WIDTH, 4.0); myWindow.showWidget("Line Widget", axis); /// Construct a cube widget - viz::CubeWidget cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); + viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue()); cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0); myWindow.showWidget("Cube Widget", cube_widget); -- 2.7.4