### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- viz. 3D Visualizer »

# Widget

In this section, the widget framework is explained. Widgets represent 2D or 3D objects, varying from simple ones such as lines to complex one such as point clouds and meshes.

Widgets are implicitly shared. Therefore, one can add a widget to the scene, and modify the widget without re-adding the widget.

    ...
    /// Create a cloud widget
    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.
    cw.setColor(viz::Color::yellow());
    ...

## viz::Widget

class `Widget`

Base class of all widgets. Widget is implicitly shared.

    class CV_EXPORTS Widget
    {
    public:
        Widget();
        Widget(const Widget& other);
        Widget& operator=(const Widget& other);
        ~Widget();

        //! Create a widget directly from ply file
        static Widget fromPlyFile(const String &file_name);

        //! Rendering properties of this particular widget
        void setRenderingProperty(int property, double value);
        double getRenderingProperty(int property) const;

        //! Casting between widgets
        template<typename _W> _W cast();
    private:
        /* hidden */
    };

## viz::Widget::fromPlyFile

Creates a widget from ply file.

C++:`` static Widget `fromPlyFile`(const String& file_name)

  Parameters: | file_name – Ply file name.

## viz::Widget::setRenderingProperty

Sets rendering property of the widget.

C++:`` void `setRenderingProperty`(int property, double value)

  Parameters: | property – Property that will be modified. value – The new value of the property.

  Rendering property can be one of the following:

  - POINT_SIZE

  - OPACITY

  - LINE_WIDTH

  - FONT_SIZE

  - REPRESENTATION: Expected values are
      - REPRESENTATION_POINTS
      - REPRESENTATION_WIREFRAME
      - REPRESENTATION_SURFACE
  - IMMEDIATE_RENDERING:
      - Turn on immediate rendering by setting the value to `1`.
      - Turn off immediate rendering by setting the value to `0`.
  - SHADING: Expected values are
      - SHADING_FLAT
      - SHADING_GOURAUD
      - SHADING_PHONG

## viz::Widget::getRenderingProperty

Returns rendering property of the widget.

C++:`` double `getRenderingProperty`(int property)`const`

  Parameters: | property – Property.

  Rendering property can be one of the following:

  - POINT_SIZE

  - OPACITY

  - LINE_WIDTH

  - FONT_SIZE

  - REPRESENTATION: Expected values are
      - REPRESENTATION_POINTS
      - REPRESENTATION_WIREFRAME
      - REPRESENTATION_SURFACE
  - IMMEDIATE_RENDERING:
      - Turn on immediate rendering by setting the value to `1`.
      - Turn off immediate rendering by setting the value to `0`.
  - SHADING: Expected values are
      - SHADING_FLAT
      - SHADING_GOURAUD
      - SHADING_PHONG

## viz::Widget::cast

Casts a widget to another.

C++:`` template<typename _W> _W `cast`()

    // Create a sphere widget
    viz::WSphere sw(Point3f(0.0f,0.0f,0.0f), 0.5f);
    // Cast sphere widget to cloud widget
    viz::WCloud cw = sw.cast<viz::WCloud>();

Note

3D Widgets can only be cast to 3D Widgets. 2D Widgets can only be cast to 2D Widgets.

## viz::WidgetAccessor

class `WidgetAccessor`

This class is for users who want to develop their own widgets using VTK library API.

    struct CV_EXPORTS WidgetAccessor
    {
        static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
        static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
    };

## viz::WidgetAccessor::getProp

Returns `vtkProp` of a given widget.

C++:`` static vtkSmartPointer<vtkProp> `getProp`(const Widget& widget)

  Parameters: | widget – Widget whose `vtkProp` is to be returned.

Note

vtkProp has to be down cast appropriately to be modified.

    vtkActor * actor = vtkActor::SafeDownCast(viz::WidgetAccessor::getProp(widget));

## viz::WidgetAccessor::setProp

Sets `vtkProp` of a given widget.

C++:`` static void `setProp`(Widget& widget, vtkSmartPointer<vtkProp> prop)

  Parameters: | widget – Widget whose `vtkProp` is to be set. prop – A `vtkProp`.

## viz::Widget3D

class `Widget3D`

Base class of all 3D widgets.

    class CV_EXPORTS Widget3D : public Widget
    {
    public:
        Widget3D() {}

        //! widget position manipulation, i.e. place where it is rendered.
        void setPose(const Affine3d &pose);
        void updatePose(const Affine3d &pose);
        Affine3d getPose() const;

        //! updates internal widget data, i.e. points, normals, etc.
        void applyTransform(const Affine3d &transform);

        void setColor(const Color &color);

    };

## viz::Widget3D::setPose

Sets pose of the widget.

C++:`` void `setPose`(const Affine3d& pose)

  Parameters: | pose – The new pose of the widget.

## viz::Widget3D::updateWidgetPose

Updates pose of the widget by pre-multiplying its current pose.

C++:`` void `updateWidgetPose`(const Affine3d& pose)

  Parameters: | pose – The pose that the current pose of the widget will be pre-multiplied by.

## viz::Widget3D::getPose

Returns the current pose of the widget.

C++:`` Affine3d `getWidgetPose`()`const`

## viz::Widget3D::applyTransform

Transforms internal widget data (i.e. points, normals) using the given transform.

C++:`` void `applyTransform`(const Affine3d& transform)

  Parameters: | transform – Specified transformation to apply.

## viz::Widget3D::setColor

Sets the color of the widget.

C++:`` void `setColor`(const Color& color)

  Parameters: | color – color of type `Color`

## viz::Widget2D

class `Widget2D`

Base class of all 2D widgets.

    class CV_EXPORTS Widget2D : public Widget
    {
    public:
        Widget2D() {}

        void setColor(const Color &color);
    };

## viz::Widget2D::setColor

Sets the color of the widget.

C++:`` void `setColor`(const Color& color)

  Parameters: | color – color of type `Color`

## viz::WLine

class `WLine`

This 3D Widget defines a finite line.

    class CV_EXPORTS WLine : public Widget3D
    {
    public:
        WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
    };

## viz::WLine::WLine

Constructs a WLine.

C++:`` `WLine`(const Point3f& pt1, const Point3f& pt2, const Color& color=Color::white())

  Parameters: | pt1 – Start point of the line. pt2 – End point of the line. color – `Color` of the line.

## viz::WPlane

class `WPlane`

This 3D Widget defines a finite plane.

    class CV_EXPORTS WPlane : public Widget3D
    {
    public:
        //! created default plane with center point at origin and normal oriented along z-axis
        WPlane(const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());

        //! repositioned plane
        WPlane(const Point3d& center, const Vec3d& normal, const Vec3d& new_plane_yaxis,const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());
    };

## viz::WPlane::WPlane

Constructs a default plane with center point at origin and normal oriented along z-axis.

C++:`` `WPlane`(const Size2d& size=Size2d(1.0, 1.0), const Color& color=Color::white())

  Parameters: | size – Size of the plane color – `Color` of the plane.

## viz::WPlane::WPlane

Constructs a repositioned plane

C++:`` `WPlane`(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis, const Size2d& size=Size2d(1.0, 1.0), const Color& color=Color::white())

  Parameters: | center – Center of the plane normal – Plane normal orientation new_yaxis – Up-vector. New orientation of plane y-axis. color – `Color` of the plane.

## viz::WSphere

class `WSphere`

This 3D Widget defines a sphere.

    class CV_EXPORTS WSphere : public Widget3D
    {
    public:
        WSphere(const cv::Point3f &center, double radius, int sphere_resolution = 10, const Color &color = Color::white())
    };

## viz::WSphere::WSphere

Constructs a WSphere.

C++:`` `WSphere`(const cv::Point3f& center, double radius, int sphere_resolution=10, const Color& color=Color::white())

  Parameters: | center – Center of the sphere. radius – Radius of the sphere. sphere_resolution – Resolution of the sphere. color – `Color` of the sphere.

## viz::WArrow

class `WArrow`

This 3D Widget defines an arrow.

    class CV_EXPORTS WArrow : public Widget3D
    {
    public:
        WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white());
    };

## viz::WArrow::WArrow

Constructs an WArrow.

C++:`` `WArrow`(const Point3f& pt1, const Point3f& pt2, double thickness=0.03, const Color& color=Color::white())

  Parameters: | pt1 – Start point of the arrow. pt2 – End point of the arrow. thickness – Thickness of the arrow. Thickness of arrow head is also adjusted accordingly. color – `Color` of the arrow.

Arrow head is located at the end point of the arrow.

## viz::WCircle

class `WCircle`

This 3D Widget defines a circle.

    class CV_EXPORTS WCircle : public Widget3D
    {
    public:
        //! creates default planar circle centred at origin with plane normal along z-axis
        WCircle(double radius, double thickness = 0.01, const Color &color = Color::white());

        //! creates repositioned circle
        WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
    };

## viz::WCircle::WCircle

Constructs default planar circle centred at origin with plane normal along z-axis

C++:`` `WCircle`(double radius, double thickness=0.01, const Color& color=Color::white())

  Parameters: | radius – Radius of the circle. thickness – Thickness of the circle. color – `Color` of the circle.

## viz::WCircle::WCircle

Constructs repositioned planar circle.

C++:`` `WCircle`(double radius, const Point3d& center, const Vec3d& normal, double thickness=0.01, const Color& color=Color::white())

  Parameters: | radius – Radius of the circle. center – Center of the circle. normal – Normal of the plane in which the circle lies. thickness – Thickness of the circle. color – `Color` of the circle.

## viz::WCone

class `WCone`

This 3D Widget defines a cone.

    class CV_EXPORTS WCone : public Widget3D
    {
    public:
        //! create default cone, oriented along x-axis with center of its base located at origin
        WCone(double length, double radius, int resolution = 6.0, const Color &color = Color::white());

        //! creates repositioned cone
        WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
    };

## viz::WCone::WCone

Constructs default cone oriented along x-axis with center of its base located at origin

C++:`` `WCone`(double length, double radius, int resolution=6.0, const Color& color=Color::white())

  Parameters: | length – Length of the cone. radius – Radius of the cone. resolution – Resolution of the cone. color – `Color` of the cone.

## viz::WCone::WCone

Constructs repositioned planar cone.

C++:`` `WCone`(double radius, const Point3d& center, const Point3d& tip, int resolution=6.0, const Color& color=Color::white())

  Parameters: | radius – Radius of the cone. center – Center of the cone base. tip – Tip of the cone. resolution – Resolution of the cone. color – `Color` of the cone.

## viz::WCylinder

class `WCylinder`

This 3D Widget defines a cylinder.

    class CV_EXPORTS WCylinder : public Widget3D
    {
    public:
        WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides = 30, const Color &color = Color::white());
    };

## viz::WCylinder::WCylinder

Constructs a WCylinder.

C++:`` `WCylinder`(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides=30, const Color& color=Color::white())

  Parameters: | axis_point1 – A point1 on the axis of the cylinder. axis_point2 – A point2 on the axis of the cylinder. radius – Radius of the cylinder. numsides – Resolution of the cylinder. color – `Color` of the cylinder.

## viz::WCube

class `WCube`

This 3D Widget defines a cube.

    class CV_EXPORTS WCube : public Widget3D
    {
    public:
        WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
    };

## viz::WCube::WCube

Constructs a WCube.

C++:`` `WCube`(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame=true, const Color& color=Color::white())

  Parameters: | pt_min – Specifies minimum point of the bounding box. pt_max – Specifies maximum point of the bounding box. wire_frame – If true, cube is represented as wireframe. color – `Color` of the cube.

## viz::WCoordinateSystem

class `WCoordinateSystem`

This 3D Widget represents a coordinate system.

    class CV_EXPORTS WCoordinateSystem : public Widget3D
    {
    public:
        WCoordinateSystem(double scale = 1.0);
    };

## viz::WCoordinateSystem::WCoordinateSystem

Constructs a WCoordinateSystem.

C++:`` `WCoordinateSystem`(double scale=1.0)

  Parameters: | scale – Determines the size of the axes.

## viz::WPolyLine

class `WPolyLine`

This 3D Widget defines a poly line.

    class CV_EXPORTS WPolyLine : public Widget3D
    {
    public:
        WPolyLine(InputArray points, const Color &color = Color::white());
    };

## viz::WPolyLine::WPolyLine

Constructs a WPolyLine.

C++:`` `WPolyLine`(InputArray points, const Color& color=Color::white())

  Parameters: | points – Point set. color – `Color` of the poly line.

## viz::WGrid

class `WGrid`

This 3D Widget defines a grid.

    class CV_EXPORTS WGrid : public Widget3D
    {
    public:
        //! Creates grid at the origin and normal oriented along z-axis
        WGrid(const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());

        //! Creates repositioned grid
        WGrid(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis,
              const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());
    };

## viz::WGrid::WGrid

Constructs a WGrid.

C++:`` `WGrid`(const Vec2i& cells=Vec2i::all(10), const Vec2d& cells_spacing=Vec2d::all(1.0), const Color& color=Color::white())

  Parameters: | cells – Number of cell columns and rows, respectively. cells_spacing – Size of each cell, respectively. color – `Color` of the grid.

## viz::WText3D

class `WText3D`

This 3D Widget represents 3D text. The text always faces the camera.

    class CV_EXPORTS WText3D : public Widget3D
    {
    public:
        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;
    };

## viz::WText3D::WText3D

Constructs a WText3D.

C++:`` `WText3D`(const String& text, const Point3f& position, double text_scale=1.0, bool face_camera=true, const Color& color=Color::white())

  Parameters: | text – Text content of the widget. position – Position of the text. text_scale – Size of the text. face_camera – If true, text always faces the camera. color – `Color` of the text.

## viz::WText3D::setText

Sets the text content of the widget.

C++:`` void `setText`(const String& text)

  Parameters: | text – Text content of the widget.

## viz::WText3D::getText

Returns the current text content of the widget.

C++:`` String `getText`()`const`

## viz::WText

class `WText`

This 2D Widget represents text overlay.

    class CV_EXPORTS WText : public Widget2D
    {
    public:
        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::WText::WText

Constructs a WText.

C++:`` `WText`(const String& text, const Point2i& pos, int font_size=10, const Color& color=Color::white())

  Parameters: | text – Text content of the widget. pos – Position of the text. font_size – Font size. color – `Color` of the text.

## viz::WText::setText

Sets the text content of the widget.

C++:`` void `setText`(const String& text)

  Parameters: | text – Text content of the widget.

## viz::WText::getText

Returns the current text content of the widget.

C++:`` String `getText`()`const`

## viz::WImageOverlay

class `WImageOverlay`

This 2D Widget represents an image overlay.

    class CV_EXPORTS WImageOverlay : public Widget2D
    {
    public:
        WImageOverlay(InputArray image, const Rect &rect);

        void setImage(InputArray image);
    };

## viz::WImageOverlay::WImageOverlay

Constructs an WImageOverlay.

C++:`` `WImageOverlay`(InputArray image, const Rect& rect)

  Parameters: | image – BGR or Gray-Scale image. rect – Image is scaled and positioned based on rect.

## viz::WImageOverlay::setImage

Sets the image content of the widget.

C++:`` void `setImage`(InputArray image)

  Parameters: | image – BGR or Gray-Scale image.

## viz::WImage3D

class `WImage3D`

This 3D Widget represents an image in 3D space.

    class CV_EXPORTS WImage3D : public Widget3D
    {
    public:
        //! Creates 3D image at the origin
        WImage3D(InputArray image, const Size2d &size);
        //! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
        WImage3D(InputArray image, const Size2d &size, const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector);

        void setImage(InputArray image);
    };

## viz::WImage3D::WImage3D

Constructs an WImage3D.

C++:`` `WImage3D`(InputArray image, const Size2d& size)

  Parameters: | image – BGR or Gray-Scale image. size – Size of the image.

C++:`` `WImage3D`(InputArray image, const Size2d& size, const Vec3d& position, const Vec3d& normal, const Vec3d& up_vector)

  Parameters: | position – Position of the image. normal – Normal of the plane that represents the image. up_vector – Determines orientation of the image. image – BGR or Gray-Scale image. size – Size of the image.

## viz::WImage3D::setImage

Sets the image content of the widget.

C++:`` void `setImage`(InputArray image)

  Parameters: | image – BGR or Gray-Scale image.

## viz::WCameraPosition

class `WCameraPosition`

This 3D Widget represents camera position in a scene by its axes or viewing frustum.

    class CV_EXPORTS WCameraPosition : public Widget3D
    {
    public:
        //! Creates camera coordinate frame (axes) at the origin
        WCameraPosition(double scale = 1.0);
        //! Creates frustum based on the intrinsic marix K at the origin
        WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
        //! Creates frustum based on the field of view at the origin
        WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
        //! Creates frustum and display given image at the far plane
        WCameraPosition(const Matx33d &K, InputArray image, double scale = 1.0, const Color &color = Color::white());
        //! Creates frustum and display given image at the far plane
        WCameraPosition(const Vec2d &fov, InputArray image, double scale = 1.0, const Color &color = Color::white());
    };

## viz::WCameraPosition::WCameraPosition

Constructs a WCameraPosition.

- Display camera coordinate frame.

  > C++:`` `WCameraPosition`(double scale=1.0)

  >   Creates camera coordinate frame at the origin.

- Display the viewing frustum.

  > C++:`` `WCameraPosition`(const Matx33d& K, double scale=1.0, const Color& color=Color::white())

  >   Parameters: | K – Intrinsic matrix of the camera. scale – Scale of the frustum. color – `Color` of the frustum.

  >   Creates viewing frustum of the camera based on its intrinsic matrix K.

  > C++:`` `WCameraPosition`(const Vec2d& fov, double scale=1.0, const Color& color=Color::white())

  >   Parameters: | fov – Field of view of the camera (horizontal, vertical). scale – Scale of the frustum. color – `Color` of the frustum.

  >   Creates viewing frustum of the camera based on its field of view fov.

- Display image on the far plane of the viewing frustum.

  > C++:`` `WCameraPosition`(const Matx33d& K, InputArray image, double scale=1.0, const Color& color=Color::white())

  >   Parameters: | K – Intrinsic matrix of the camera. img – BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. scale – Scale of the frustum and image. color – `Color` of the frustum.

  >   Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.

  > C++:`` `WCameraPosition`(const Vec2d& fov, InputArray image, double scale=1.0, const Color& color=Color::white())

  >   Parameters: | fov – Field of view of the camera (horizontal, vertical). img – BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. scale – Scale of the frustum and image. color – `Color` of the frustum.

  >   Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.

## viz::WTrajectory

class `WTrajectory`

This 3D Widget represents a trajectory.

    class CV_EXPORTS WTrajectory : public Widget3D
    {
    public:
        enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH};

        //! Displays trajectory of the given path either by coordinate frames or polyline
        WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.0, const Color &color = Color::white(),;
    };

## viz::WTrajectory::WTrajectory

Constructs a WTrajectory.

C++:`` `WTrajectory`(InputArray path, int display_mode=WTrajectory::PATH, double scale=1.0, const Color& color=Color::white())

  Parameters: | path – List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double] display_mode – Display mode. This can be PATH, FRAMES, and BOTH. scale – Scale of the frames. Polyline is not affected. color – `Color` of the polyline that represents path. Frames are not affected.

  Displays trajectory of the given path as follows:

  - PATH : Displays a poly line that represents the path.
  - FRAMES : Displays coordinate frames at each pose.
  - PATH & FRAMES : Displays both poly line and coordinate frames.

## viz::WTrajectoryFrustums

class `WTrajectoryFrustums`

This 3D Widget represents a trajectory.

    class CV_EXPORTS WTrajectoryFrustums : public Widget3D
    {
    public:
        //! Displays trajectory of the given path by frustums
        WTrajectoryFrustums(InputArray path, const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
        //! Displays trajectory of the given path by frustums
        WTrajectoryFrustums(InputArray path, const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
    };

## viz::WTrajectoryFrustums::WTrajectoryFrustums

Constructs a WTrajectoryFrustums.

C++:`` `WTrajectoryFrustums`(const std::vector<Affine3d>& path, const Matx33d& K, double scale=1.0, const Color& color=Color::white())

  Parameters: | path – List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double] K – Intrinsic matrix of the camera. scale – Scale of the frustums. color – `Color` of the frustums.

  Displays frustums at each pose of the trajectory.

C++:`` `WTrajectoryFrustums`(const std::vector<Affine3d>& path, const Vec2d& fov, double scale=1.0, const Color& color=Color::white())

  Parameters: | path – List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double] fov – Field of view of the camera (horizontal, vertical). scale – Scale of the frustums. color – `Color` of the frustums.

  Displays frustums at each pose of the trajectory.

## viz::WTrajectorySpheres

class `WTrajectorySpheres`

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 WTrajectorySpheres : public Widget3D
    {
    public:
        WTrajectorySpheres(InputArray path, double line_length = 0.05, double radius = 0.007,
                               const Color &from = Color::red(), const Color &to = Color::white());
    };

## viz::WTrajectorySpheres::WTrajectorySpheres

Constructs a WTrajectorySpheres.

C++:`` `WTrajectorySpheres`(InputArray path, double line_length=0.05, double radius=0.007, const Color& from=Color::red(), const Color& to=Color::white())

  Parameters: | path – List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double] line_length – Max length of the lines which point to previous position sphere_radius – Radius of the spheres. from – `Color` for first sphere. to – `Color` for last sphere. Intermediate spheres will have interpolated color.

## viz::WCloud

class `WCloud`

This 3D Widget defines a point cloud.

    class CV_EXPORTS WCloud : public Widget3D
    {
    public:
        //! Each point in cloud is mapped to a color in colors
        WCloud(InputArray cloud, InputArray colors);
        //! All points in cloud have the same color
        WCloud(InputArray cloud, const Color &color = Color::white());
        //! Each point in cloud is mapped to a color in colors, normals are used for shading
        WCloud(InputArray cloud, InputArray colors, InputArray normals);
        //! All points in cloud have the same color, normals are used for shading
        WCloud(InputArray cloud, const Color &color, InputArray normals);
    };

## viz::WCloud::WCloud

Constructs a WCloud.

C++:`` `WCloud`(InputArray cloud, InputArray colors)

  Parameters: | cloud – Set of points which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. 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).

C++:`` `WCloud`(InputArray cloud, const Color& color=Color::white())

  Parameters: | cloud – Set of points which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. color – A single `Color` for the whole cloud.

  Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).

C++:`` `WCloud`(InputArray cloud, InputArray colors, InputArray normals)

  Parameters: | cloud – Set of points which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. colors – Set of colors. It has to be of the same size with cloud. normals – Normals for each point in cloud. Size and type should match with the cloud parameter.

  Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).

C++:`` `WCloud`(InputArray cloud, const Color& color, InputArray normals)

  Parameters: | cloud – Set of points which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. color – A single `Color` for the whole cloud. normals – Normals for each point in cloud. Size and type should match with the cloud parameter.

  Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).

Note

In case there are four channels in the cloud, fourth channel is ignored.

## viz::WCloudCollection

class `WCloudCollection`

This 3D Widget defines a collection of clouds.

    class CV_EXPORTS WCloudCollection : public Widget3D
    {
    public:
        WCloudCollection();

        //! Each point in cloud is mapped to a color in colors
        void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
        //! All points in cloud have the same color
        void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3d &pose = Affine3d::Identity());
        //! Repacks internal structure to single cloud
        void finalize();
    };

## viz::WCloudCollection::WCloudCollection

Constructs a WCloudCollection.

C++:`` `WCloudCollection`()

## viz::WCloudCollection::addCloud

Adds a cloud to the collection.

C++:`` void `addCloud`(InputArray cloud, InputArray colors, const Affine3d& pose=Affine3d::Identity())

  Parameters: | cloud – Point set which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. colors – Set of colors. It has to be of the same size with cloud. pose – Pose of the cloud.

  Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).

C++:`` void `addCloud`(InputArray cloud, const Color& color=Color::white(), const Affine3d& pose=Affine3d::Identity())

  Parameters: | cloud – Point set which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. colors – A single `Color` for the whole cloud. pose – Pose of the cloud.

  Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).

Note

In case there are four channels in the cloud, fourth channel is ignored.

## viz::WCloudCollection::finalize

Finalizes cloud data by repacking to single cloud. Useful for large cloud collections to reduce memory usage

C++:`` void `finalize`()

## viz::WCloudNormals

class `WCloudNormals`

This 3D Widget represents normals of a point cloud.

    class CV_EXPORTS WCloudNormals : public Widget3D
    {
    public:
        WCloudNormals(InputArray cloud, InputArray normals, int level = 100, double scale = 0.02f, const Color &color = Color::white());
    };

## viz::WCloudNormals::WCloudNormals

Constructs a WCloudNormals.

C++:`` `WCloudNormals`(InputArray cloud, InputArray normals, int level=100, double scale=0.02f, const Color& color=Color::white())

  Parameters: | cloud – Point set which can be of type: `CV_32FC3`, `CV_32FC4`, `CV_64FC3`, `CV_64FC4`. normals – A set of normals that has to be of same type with cloud. level – Display only every `level` th normal. scale – Scale of the arrows that represent normals. color – `Color` of the arrows that represent normals.

Note

In case there are four channels in the cloud, fourth channel is ignored.

## viz::WMesh

class `WMesh`

This 3D Widget defines a mesh.

    class CV_EXPORTS WMesh : public Widget3D
    {
    public:
        WMesh(const Mesh &mesh);
        WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
    };

## viz::WMesh::WMesh

Constructs a WMesh.

C++:`` `WMesh`(const Mesh& mesh)

  Parameters: | mesh – `Mesh` object that will be displayed.

C++:`` `WMesh`(InputArray cloud, InputArray polygons, InputArray colors=noArray(), InputArray normals=noArray())

  Parameters: | cloud – Points of the mesh object. polygons – Points of the mesh object. colors – Point colors. normals – Point normals.

## viz::WWidgetMerger

class `WWidgetMerger`

This class allows to merge several widgets to single one. It has quite limited functionality and can’t merge widgets with different attributes. For instance, if widgetA has color array and widgetB has only global color defined, then result of merge won’t have color at all. The class is suitable for merging large amount of similar widgets.

    class CV_EXPORTS WWidgetMerger : public Widget3D
    {
    public:
        WWidgetMerger();

        //! Add widget to merge with optional position change
        void addWidget(const Widget3D& widget, const Affine3d &pose = Affine3d::Identity());

        //! Repacks internal structure to single widget
        void finalize();
    };

## viz::WWidgetMerger::WWidgetMerger

Constructs a WWidgetMerger.

C++:`` `WWidgetMerger`()

## viz::WWidgetMerger::addCloud

Adds a cloud to the collection.

C++:`` void `addWidget`(const Widget3D& widget, const Affine3d& pose=Affine3d::Identity())

  Parameters: | widget – Widget to merge. pose – Pose of the widget.

## viz::WWidgetMerger::finalize

Finalizes merger data and constructs final merged widget

C++:`` void `finalize`()

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- viz. 3D Visualizer »