Home | History | Annotate | Download | only in viz
      1 /*M///////////////////////////////////////////////////////////////////////////////////////
      2 //
      3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
      4 //
      5 //  By downloading, copying, installing or using the software you agree to this license.
      6 //  If you do not agree to this license, do not download, install,
      7 //  copy or use the software.
      8 //
      9 //
     10 //                           License Agreement
     11 //                For Open Source Computer Vision Library
     12 //
     13 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
     14 // Third party copyrights are property of their respective owners.
     15 //
     16 // Redistribution and use in source and binary forms, with or without modification,
     17 // are permitted provided that the following conditions are met:
     18 //
     19 //   * Redistribution's of source code must retain the above copyright notice,
     20 //     this list of conditions and the following disclaimer.
     21 //
     22 //   * Redistribution's in binary form must reproduce the above copyright notice,
     23 //     this list of conditions and the following disclaimer in the documentation
     24 //     and/or other materials provided with the distribution.
     25 //
     26 //   * The name of the copyright holders may not be used to endorse or promote products
     27 //     derived from this software without specific prior written permission.
     28 //
     29 // This software is provided by the copyright holders and contributors "as is" and
     30 // any express or implied warranties, including, but not limited to, the implied
     31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
     32 // In no event shall the Intel Corporation or contributors be liable for any direct,
     33 // indirect, incidental, special, exemplary, or consequential damages
     34 // (including, but not limited to, procurement of substitute goods or services;
     35 // loss of use, data, or profits; or business interruption) however caused
     36 // and on any theory of liability, whether in contract, strict liability,
     37 // or tort (including negligence or otherwise) arising in any way out of
     38 // the use of this software, even if advised of the possibility of such damage.
     39 //
     40 // Authors:
     41 //  * Ozan Tonkal, ozantonkal (at) gmail.com
     42 //  * Anatoly Baksheev, Itseez Inc.  myname.mysurname <> mycompany.com
     43 //
     44 //M*/
     45 
     46 #ifndef __OPENCV_VIZ_WIDGETS_HPP__
     47 #define __OPENCV_VIZ_WIDGETS_HPP__
     48 
     49 #include <opencv2/viz/types.hpp>
     50 
     51 namespace cv
     52 {
     53     namespace viz
     54     {
     55 
     56 //! @addtogroup viz_widget
     57 //! @{
     58 
     59         /////////////////////////////////////////////////////////////////////////////
     60         /// Widget rendering properties
     61         enum RenderingProperties
     62         {
     63             POINT_SIZE,
     64             OPACITY,
     65             LINE_WIDTH,
     66             FONT_SIZE,
     67             REPRESENTATION,
     68             IMMEDIATE_RENDERING,
     69             SHADING
     70         };
     71 
     72         enum RepresentationValues
     73         {
     74             REPRESENTATION_POINTS,
     75             REPRESENTATION_WIREFRAME,
     76             REPRESENTATION_SURFACE
     77         };
     78 
     79         enum ShadingValues
     80         {
     81             SHADING_FLAT,
     82             SHADING_GOURAUD,
     83             SHADING_PHONG
     84         };
     85 
     86         /////////////////////////////////////////////////////////////////////////////
     87 
     88         /** @brief Base class of all widgets. Widget is implicitly shared. :
     89         */
     90         class CV_EXPORTS Widget
     91         {
     92         public:
     93             Widget();
     94             Widget(const Widget& other);
     95             Widget& operator=(const Widget& other);
     96             ~Widget();
     97 
     98             /** @brief Creates a widget from ply file.
     99 
    100             @param file_name Ply file name.
    101              */
    102             static Widget fromPlyFile(const String &file_name);
    103 
    104             /** @brief Sets rendering property of the widget.
    105 
    106             @param property Property that will be modified.
    107             @param value The new value of the property.
    108 
    109             **Rendering property** can be one of the following:
    110             -   **POINT_SIZE**
    111             -   **OPACITY**
    112             -   **LINE_WIDTH**
    113             -   **FONT_SIZE**
    114             -
    115             **REPRESENTATION**: Expected values are
    116             -   **REPRESENTATION_POINTS**
    117             -   **REPRESENTATION_WIREFRAME**
    118             -   **REPRESENTATION_SURFACE**
    119             -
    120             **IMMEDIATE_RENDERING**:
    121             -   Turn on immediate rendering by setting the value to 1.
    122             -   Turn off immediate rendering by setting the value to 0.
    123             -
    124             **SHADING**: Expected values are
    125             -   **SHADING_FLAT**
    126             -   **SHADING_GOURAUD**
    127             -   **SHADING_PHONG**
    128              */
    129             void setRenderingProperty(int property, double value);
    130             /** @brief Returns rendering property of the widget.
    131 
    132             @param property Property.
    133 
    134             **Rendering property** can be one of the following:
    135             -   **POINT_SIZE**
    136             -   **OPACITY**
    137             -   **LINE_WIDTH**
    138             -   **FONT_SIZE**
    139             -
    140             **REPRESENTATION**: Expected values are
    141             :   -   **REPRESENTATION_POINTS**
    142             -   **REPRESENTATION_WIREFRAME**
    143             -   **REPRESENTATION_SURFACE**
    144             -
    145             **IMMEDIATE_RENDERING**:
    146             :   -   Turn on immediate rendering by setting the value to 1.
    147             -   Turn off immediate rendering by setting the value to 0.
    148             -
    149             **SHADING**: Expected values are
    150             :   -   **SHADING_FLAT**
    151             -   **SHADING_GOURAUD**
    152             -   **SHADING_PHONG**
    153              */
    154             double getRenderingProperty(int property) const;
    155 
    156             /** @brief Casts a widget to another.
    157 
    158             @code
    159             // Create a sphere widget
    160             viz::WSphere sw(Point3f(0.0f,0.0f,0.0f), 0.5f);
    161             // Cast sphere widget to cloud widget
    162             viz::WCloud cw = sw.cast<viz::WCloud>();
    163             @endcode
    164 
    165             @note 3D Widgets can only be cast to 3D Widgets. 2D Widgets can only be cast to 2D Widgets.
    166              */
    167             template<typename _W> _W cast();
    168         private:
    169             class Impl;
    170             Impl *impl_;
    171             friend struct WidgetAccessor;
    172         };
    173 
    174         /////////////////////////////////////////////////////////////////////////////
    175 
    176         /** @brief Base class of all 3D widgets.
    177          */
    178         class CV_EXPORTS Widget3D : public Widget
    179         {
    180         public:
    181             Widget3D() {}
    182 
    183             /** @brief Sets pose of the widget.
    184 
    185             @param pose The new pose of the widget.
    186              */
    187             void setPose(const Affine3d &pose);
    188             /** @brief Updates pose of the widget by pre-multiplying its current pose.
    189 
    190             @param pose The pose that the current pose of the widget will be pre-multiplied by.
    191              */
    192             void updatePose(const Affine3d &pose);
    193             /** @brief Returns the current pose of the widget.
    194              */
    195             Affine3d getPose() const;
    196 
    197             /** @brief Transforms internal widget data (i.e. points, normals) using the given transform.
    198 
    199             @param transform Specified transformation to apply.
    200              */
    201             void applyTransform(const Affine3d &transform);
    202 
    203             /** @brief Sets the color of the widget.
    204 
    205             @param color color of type Color
    206              */
    207             void setColor(const Color &color);
    208 
    209         };
    210 
    211         /////////////////////////////////////////////////////////////////////////////
    212 
    213         /** @brief Base class of all 2D widgets.
    214         */
    215         class CV_EXPORTS Widget2D : public Widget
    216         {
    217         public:
    218             Widget2D() {}
    219 
    220             /** @brief Sets the color of the widget.
    221 
    222             @param color color of type Color
    223              */
    224             void setColor(const Color &color);
    225         };
    226 
    227         /////////////////////////////////////////////////////////////////////////////
    228         /// Simple widgets
    229 
    230         /** @brief This 3D Widget defines a finite line.
    231         */
    232         class CV_EXPORTS WLine : public Widget3D
    233         {
    234         public:
    235             /** @brief Constructs a WLine.
    236 
    237             @param pt1 Start point of the line.
    238             @param pt2 End point of the line.
    239             @param color Color of the line.
    240              */
    241             WLine(const Point3d &pt1, const Point3d &pt2, const Color &color = Color::white());
    242         };
    243 
    244         /** @brief This 3D Widget defines a finite plane.
    245         */
    246         class CV_EXPORTS WPlane : public Widget3D
    247         {
    248         public:
    249             /** @brief Constructs a default plane with center point at origin and normal oriented along z-axis.
    250 
    251             @param size Size of the plane
    252             @param color Color of the plane.
    253              */
    254             WPlane(const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());
    255 
    256             /** @brief Constructs a repositioned plane
    257 
    258             @param center Center of the plane
    259             @param normal Plane normal orientation
    260             @param new_yaxis Up-vector. New orientation of plane y-axis.
    261             @param size
    262             @param color Color of the plane.
    263              */
    264             WPlane(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis,
    265                    const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());
    266         };
    267 
    268         /** @brief This 3D Widget defines a sphere. :
    269         */
    270         class CV_EXPORTS WSphere : public Widget3D
    271         {
    272         public:
    273             /** @brief Constructs a WSphere.
    274 
    275             @param center Center of the sphere.
    276             @param radius Radius of the sphere.
    277             @param sphere_resolution Resolution of the sphere.
    278             @param color Color of the sphere.
    279              */
    280             WSphere(const cv::Point3d &center, double radius, int sphere_resolution = 10, const Color &color = Color::white());
    281         };
    282 
    283         /** @brief This 3D Widget defines an arrow.
    284         */
    285         class CV_EXPORTS WArrow : public Widget3D
    286         {
    287         public:
    288             /** @brief Constructs an WArrow.
    289 
    290             @param pt1 Start point of the arrow.
    291             @param pt2 End point of the arrow.
    292             @param thickness Thickness of the arrow. Thickness of arrow head is also adjusted
    293             accordingly.
    294             @param color Color of the arrow.
    295 
    296             Arrow head is located at the end point of the arrow.
    297              */
    298             WArrow(const Point3d& pt1, const Point3d& pt2, double thickness = 0.03, const Color &color = Color::white());
    299         };
    300 
    301         /** @brief This 3D Widget defines a circle.
    302         */
    303         class CV_EXPORTS WCircle : public Widget3D
    304         {
    305         public:
    306             /** @brief Constructs default planar circle centred at origin with plane normal along z-axis
    307 
    308             @param radius Radius of the circle.
    309             @param thickness Thickness of the circle.
    310             @param color Color of the circle.
    311              */
    312             WCircle(double radius, double thickness = 0.01, const Color &color = Color::white());
    313 
    314             /** @brief Constructs repositioned planar circle.
    315 
    316             @param radius Radius of the circle.
    317             @param center Center of the circle.
    318             @param normal Normal of the plane in which the circle lies.
    319             @param thickness Thickness of the circle.
    320             @param color Color of the circle.
    321              */
    322             WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
    323         };
    324 
    325         /** @brief This 3D Widget defines a cone. :
    326         */
    327         class CV_EXPORTS WCone : public Widget3D
    328         {
    329         public:
    330             /** @brief Constructs default cone oriented along x-axis with center of its base located at origin
    331 
    332             @param length Length of the cone.
    333             @param radius Radius of the cone.
    334             @param resolution Resolution of the cone.
    335             @param color Color of the cone.
    336              */
    337             WCone(double length, double radius, int resolution = 6.0, const Color &color = Color::white());
    338 
    339             /** @brief Constructs repositioned planar cone.
    340 
    341             @param radius Radius of the cone.
    342             @param center Center of the cone base.
    343             @param tip Tip of the cone.
    344             @param resolution Resolution of the cone.
    345             @param color Color of the cone.
    346 
    347              */
    348             WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
    349         };
    350 
    351         /** @brief This 3D Widget defines a cylinder. :
    352         */
    353         class CV_EXPORTS WCylinder : public Widget3D
    354         {
    355         public:
    356             /** @brief Constructs a WCylinder.
    357 
    358             @param axis_point1 A point1 on the axis of the cylinder.
    359             @param axis_point2 A point2 on the axis of the cylinder.
    360             @param radius Radius of the cylinder.
    361             @param numsides Resolution of the cylinder.
    362             @param color Color of the cylinder.
    363              */
    364             WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides = 30, const Color &color = Color::white());
    365         };
    366 
    367         /** @brief This 3D Widget defines a cube.
    368          */
    369         class CV_EXPORTS WCube : public Widget3D
    370         {
    371         public:
    372             /** @brief Constructs a WCube.
    373 
    374             @param min_point Specifies minimum point of the bounding box.
    375             @param max_point Specifies maximum point of the bounding box.
    376             @param wire_frame If true, cube is represented as wireframe.
    377             @param color Color of the cube.
    378 
    379             ![Cube Widget](images/cube_widget.png)
    380              */
    381             WCube(const Point3d& min_point = Vec3d::all(-0.5), const Point3d& max_point = Vec3d::all(0.5),
    382                   bool wire_frame = true, const Color &color = Color::white());
    383         };
    384 
    385         /** @brief This 3D Widget defines a poly line. :
    386         */
    387         class CV_EXPORTS WPolyLine : public Widget3D
    388         {
    389         public:
    390             WPolyLine(InputArray points, InputArray colors);
    391             /** @brief Constructs a WPolyLine.
    392 
    393             @param points Point set.
    394             @param color Color of the poly line.
    395              */
    396             WPolyLine(InputArray points, const Color &color = Color::white());
    397         };
    398 
    399         /////////////////////////////////////////////////////////////////////////////
    400         /// Text and image widgets
    401 
    402         /** @brief This 2D Widget represents text overlay.
    403         */
    404         class CV_EXPORTS WText : public Widget2D
    405         {
    406         public:
    407             /** @brief Constructs a WText.
    408 
    409             @param text Text content of the widget.
    410             @param pos Position of the text.
    411             @param font_size Font size.
    412             @param color Color of the text.
    413              */
    414             WText(const String &text, const Point &pos, int font_size = 20, const Color &color = Color::white());
    415 
    416             /** @brief Sets the text content of the widget.
    417 
    418             @param text Text content of the widget.
    419              */
    420             void setText(const String &text);
    421             /** @brief Returns the current text content of the widget.
    422             */
    423             String getText() const;
    424         };
    425 
    426         /** @brief This 3D Widget represents 3D text. The text always faces the camera.
    427         */
    428         class CV_EXPORTS WText3D : public Widget3D
    429         {
    430         public:
    431             /** @brief Constructs a WText3D.
    432 
    433             @param text Text content of the widget.
    434             @param position Position of the text.
    435             @param text_scale Size of the text.
    436             @param face_camera If true, text always faces the camera.
    437             @param color Color of the text.
    438              */
    439             WText3D(const String &text, const Point3d &position, double text_scale = 1., bool face_camera = true, const Color &color = Color::white());
    440 
    441             /** @brief Sets the text content of the widget.
    442 
    443             @param text Text content of the widget.
    444 
    445              */
    446             void setText(const String &text);
    447             /** @brief Returns the current text content of the widget.
    448             */
    449             String getText() const;
    450         };
    451 
    452         /** @brief This 2D Widget represents an image overlay. :
    453         */
    454         class CV_EXPORTS WImageOverlay : public Widget2D
    455         {
    456         public:
    457             /** @brief Constructs an WImageOverlay.
    458 
    459             @param image BGR or Gray-Scale image.
    460             @param rect Image is scaled and positioned based on rect.
    461              */
    462             WImageOverlay(InputArray image, const Rect &rect);
    463             /** @brief Sets the image content of the widget.
    464 
    465             @param image BGR or Gray-Scale image.
    466              */
    467             void setImage(InputArray image);
    468         };
    469 
    470         /** @brief This 3D Widget represents an image in 3D space. :
    471         */
    472         class CV_EXPORTS WImage3D : public Widget3D
    473         {
    474         public:
    475             /** @brief Constructs an WImage3D.
    476 
    477             @param image BGR or Gray-Scale image.
    478             @param size Size of the image.
    479              */
    480             WImage3D(InputArray image, const Size2d &size);
    481 
    482             /** @brief Constructs an WImage3D.
    483 
    484             @param image BGR or Gray-Scale image.
    485             @param size Size of the image.
    486             @param center Position of the image.
    487             @param normal Normal of the plane that represents the image.
    488             @param up_vector Determines orientation of the image.
    489              */
    490             WImage3D(InputArray image, const Size2d &size, const Vec3d &center, const Vec3d &normal, const Vec3d &up_vector);
    491 
    492             /** @brief Sets the image content of the widget.
    493 
    494             @param image BGR or Gray-Scale image.
    495              */
    496             void setImage(InputArray image);
    497         };
    498 
    499         /////////////////////////////////////////////////////////////////////////////
    500         /// Compond widgets
    501 
    502         /** @brief This 3D Widget represents a coordinate system. :
    503         */
    504         class CV_EXPORTS WCoordinateSystem : public Widget3D
    505         {
    506         public:
    507             /** @brief Constructs a WCoordinateSystem.
    508 
    509             @param scale Determines the size of the axes.
    510              */
    511             WCoordinateSystem(double scale = 1.0);
    512         };
    513 
    514         /** @brief This 3D Widget defines a grid. :
    515          */
    516         class CV_EXPORTS WGrid : public Widget3D
    517         {
    518         public:
    519             /** @brief Constructs a WGrid.
    520 
    521             @param cells Number of cell columns and rows, respectively.
    522             @param cells_spacing Size of each cell, respectively.
    523             @param color Color of the grid.
    524              */
    525             WGrid(const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());
    526 
    527             //! Creates repositioned grid
    528             WGrid(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis,
    529                   const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());
    530         };
    531 
    532         /** @brief This 3D Widget represents camera position in a scene by its axes or viewing frustum. :
    533         */
    534         class CV_EXPORTS WCameraPosition : public Widget3D
    535         {
    536         public:
    537             /** @brief Creates camera coordinate frame at the origin.
    538 
    539             ![Camera coordinate frame](images/cpw1.png)
    540              */
    541             WCameraPosition(double scale = 1.0);
    542             /** @brief Display the viewing frustum
    543             @param K Intrinsic matrix of the camera.
    544             @param scale Scale of the frustum.
    545             @param color Color of the frustum.
    546 
    547             Creates viewing frustum of the camera based on its intrinsic matrix K.
    548 
    549             ![Camera viewing frustum](images/cpw2.png)
    550             */
    551             WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
    552             /** @brief Display the viewing frustum
    553             @param fov Field of view of the camera (horizontal, vertical).
    554             @param scale Scale of the frustum.
    555             @param color Color of the frustum.
    556 
    557             Creates viewing frustum of the camera based on its field of view fov.
    558 
    559             ![Camera viewing frustum](images/cpw2.png)
    560              */
    561             WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
    562             /** @brief Display image on the far plane of the viewing frustum
    563 
    564             @param K Intrinsic matrix of the camera.
    565             @param image BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
    566             @param scale Scale of the frustum and image.
    567             @param color Color of the frustum.
    568 
    569             Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on
    570             the far end plane.
    571 
    572             ![Camera viewing frustum with image](images/cpw3.png)
    573              */
    574             WCameraPosition(const Matx33d &K, InputArray image, double scale = 1.0, const Color &color = Color::white());
    575             /** @brief  Display image on the far plane of the viewing frustum
    576 
    577             @param fov Field of view of the camera (horizontal, vertical).
    578             @param image BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
    579             @param scale Scale of the frustum and image.
    580             @param color Color of the frustum.
    581 
    582             Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on
    583             the far end plane.
    584 
    585             ![Camera viewing frustum with image](images/cpw3.png)
    586              */
    587             WCameraPosition(const Vec2d &fov, InputArray image, double scale = 1.0, const Color &color = Color::white());
    588         };
    589 
    590         /////////////////////////////////////////////////////////////////////////////
    591         /// Trajectories
    592 
    593         /** @brief This 3D Widget represents a trajectory. :
    594         */
    595         class CV_EXPORTS WTrajectory : public Widget3D
    596         {
    597         public:
    598             enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH };
    599 
    600             /** @brief Constructs a WTrajectory.
    601 
    602             @param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
    603             @param display_mode Display mode. This can be PATH, FRAMES, and BOTH.
    604             @param scale Scale of the frames. Polyline is not affected.
    605             @param color Color of the polyline that represents path.
    606 
    607             Frames are not affected.
    608             Displays trajectory of the given path as follows:
    609             -   PATH : Displays a poly line that represents the path.
    610             -   FRAMES : Displays coordinate frames at each pose.
    611             -   PATH & FRAMES : Displays both poly line and coordinate frames.
    612              */
    613             WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.0, const Color &color = Color::white());
    614         };
    615 
    616         /** @brief This 3D Widget represents a trajectory. :
    617         */
    618         class CV_EXPORTS WTrajectoryFrustums : public Widget3D
    619         {
    620         public:
    621             /** @brief Constructs a WTrajectoryFrustums.
    622 
    623             @param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
    624             @param K Intrinsic matrix of the camera.
    625             @param scale Scale of the frustums.
    626             @param color Color of the frustums.
    627 
    628             Displays frustums at each pose of the trajectory.
    629              */
    630             WTrajectoryFrustums(InputArray path, const Matx33d &K, double scale = 1., const Color &color = Color::white());
    631 
    632             /** @brief Constructs a WTrajectoryFrustums.
    633 
    634             @param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
    635             @param fov Field of view of the camera (horizontal, vertical).
    636             @param scale Scale of the frustums.
    637             @param color Color of the frustums.
    638 
    639             Displays frustums at each pose of the trajectory.
    640              */
    641             WTrajectoryFrustums(InputArray path, const Vec2d &fov, double scale = 1., const Color &color = Color::white());
    642         };
    643 
    644         /** @brief This 3D Widget represents a trajectory using spheres and lines
    645 
    646         where spheres represent the positions of the camera, and lines represent the direction from
    647         previous position to the current. :
    648          */
    649         class CV_EXPORTS WTrajectorySpheres: public Widget3D
    650         {
    651         public:
    652             /** @brief Constructs a WTrajectorySpheres.
    653 
    654             @param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
    655             @param line_length Max length of the lines which point to previous position
    656             @param radius Radius of the spheres.
    657             @param from Color for first sphere.
    658             @param to Color for last sphere. Intermediate spheres will have interpolated color.
    659              */
    660             WTrajectorySpheres(InputArray path, double line_length = 0.05, double radius = 0.007,
    661                                const Color &from = Color::red(), const Color &to = Color::white());
    662         };
    663 
    664         /////////////////////////////////////////////////////////////////////////////
    665         /// Clouds
    666 
    667         /** @brief This 3D Widget defines a point cloud. :
    668 
    669         @note In case there are four channels in the cloud, fourth channel is ignored.
    670         */
    671         class CV_EXPORTS WCloud: public Widget3D
    672         {
    673         public:
    674             /** @brief Constructs a WCloud.
    675 
    676             @param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    677             @param colors Set of colors. It has to be of the same size with cloud.
    678 
    679             Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    680              */
    681             WCloud(InputArray cloud, InputArray colors);
    682 
    683             /** @brief Constructs a WCloud.
    684             @param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    685             @param color A single Color for the whole cloud.
    686 
    687             Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    688              */
    689             WCloud(InputArray cloud, const Color &color = Color::white());
    690 
    691             /** @brief Constructs a WCloud.
    692             @param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    693             @param colors Set of colors. It has to be of the same size with cloud.
    694             @param normals Normals for each point in cloud. Size and type should match with the cloud parameter.
    695 
    696             Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    697              */
    698             WCloud(InputArray cloud, InputArray colors, InputArray normals);
    699 
    700             /** @brief Constructs a WCloud.
    701             @param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    702             @param color A single Color for the whole cloud.
    703             @param normals Normals for each point in cloud.
    704 
    705             Size and type should match with the cloud parameter.
    706             Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    707              */
    708             WCloud(InputArray cloud, const Color &color, InputArray normals);
    709         };
    710 
    711         class CV_EXPORTS WPaintedCloud: public Widget3D
    712         {
    713         public:
    714             //! Paint cloud with default gradient between cloud bounds points
    715             WPaintedCloud(InputArray cloud);
    716 
    717             //! Paint cloud with default gradient between given points
    718             WPaintedCloud(InputArray cloud, const Point3d& p1, const Point3d& p2);
    719 
    720             //! Paint cloud with gradient specified by given colors between given points
    721             WPaintedCloud(InputArray cloud, const Point3d& p1, const Point3d& p2, const Color& c1, const Color c2);
    722         };
    723 
    724         /** @brief This 3D Widget defines a collection of clouds. :
    725         @note In case there are four channels in the cloud, fourth channel is ignored.
    726         */
    727         class CV_EXPORTS WCloudCollection : public Widget3D
    728         {
    729         public:
    730             WCloudCollection();
    731 
    732             /** @brief Adds a cloud to the collection.
    733 
    734             @param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    735             @param colors Set of colors. It has to be of the same size with cloud.
    736             @param pose Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    737              */
    738             void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
    739             /** @brief Adds a cloud to the collection.
    740 
    741             @param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    742             @param color A single Color for the whole cloud.
    743             @param pose Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
    744              */
    745             void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3d &pose = Affine3d::Identity());
    746             /** @brief Finalizes cloud data by repacking to single cloud.
    747 
    748             Useful for large cloud collections to reduce memory usage
    749             */
    750             void finalize();
    751         };
    752 
    753         /** @brief This 3D Widget represents normals of a point cloud. :
    754         */
    755         class CV_EXPORTS WCloudNormals : public Widget3D
    756         {
    757         public:
    758             /** @brief Constructs a WCloudNormals.
    759 
    760             @param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
    761             @param normals A set of normals that has to be of same type with cloud.
    762             @param level Display only every level th normal.
    763             @param scale Scale of the arrows that represent normals.
    764             @param color Color of the arrows that represent normals.
    765 
    766             @note In case there are four channels in the cloud, fourth channel is ignored.
    767              */
    768             WCloudNormals(InputArray cloud, InputArray normals, int level = 64, double scale = 0.1, const Color &color = Color::white());
    769         };
    770 
    771         /** @brief Constructs a WMesh.
    772 
    773         @param mesh Mesh object that will be displayed.
    774         @param cloud Points of the mesh object.
    775         @param polygons Points of the mesh object.
    776         @param colors Point colors.
    777         @param normals Point normals.
    778          */
    779         class CV_EXPORTS WMesh : public Widget3D
    780         {
    781         public:
    782             WMesh(const Mesh &mesh);
    783             WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
    784         };
    785 
    786         /** @brief This class allows to merge several widgets to single one.
    787 
    788         It has quite limited functionality and can't merge widgets with different attributes. For
    789         instance, if widgetA has color array and widgetB has only global color defined, then result
    790         of merge won't have color at all. The class is suitable for merging large amount of similar
    791         widgets. :
    792          */
    793         class CV_EXPORTS WWidgetMerger : public Widget3D
    794         {
    795         public:
    796             WWidgetMerger();
    797 
    798             //! Add widget to merge with optional position change
    799             void addWidget(const Widget3D& widget, const Affine3d &pose = Affine3d::Identity());
    800 
    801             //! Repacks internal structure to single widget
    802             void finalize();
    803         };
    804 
    805         /////////////////////////////////////////////////////////////////////////////
    806         /// Utility exports
    807 
    808         template<> CV_EXPORTS Widget2D Widget::cast<Widget2D>();
    809         template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>();
    810         template<> CV_EXPORTS WLine Widget::cast<WLine>();
    811         template<> CV_EXPORTS WPlane Widget::cast<WPlane>();
    812         template<> CV_EXPORTS WSphere Widget::cast<WSphere>();
    813         template<> CV_EXPORTS WCylinder Widget::cast<WCylinder>();
    814         template<> CV_EXPORTS WArrow Widget::cast<WArrow>();
    815         template<> CV_EXPORTS WCircle Widget::cast<WCircle>();
    816         template<> CV_EXPORTS WCone Widget::cast<WCone>();
    817         template<> CV_EXPORTS WCube Widget::cast<WCube>();
    818         template<> CV_EXPORTS WCoordinateSystem Widget::cast<WCoordinateSystem>();
    819         template<> CV_EXPORTS WPolyLine Widget::cast<WPolyLine>();
    820         template<> CV_EXPORTS WGrid Widget::cast<WGrid>();
    821         template<> CV_EXPORTS WText3D Widget::cast<WText3D>();
    822         template<> CV_EXPORTS WText Widget::cast<WText>();
    823         template<> CV_EXPORTS WImageOverlay Widget::cast<WImageOverlay>();
    824         template<> CV_EXPORTS WImage3D Widget::cast<WImage3D>();
    825         template<> CV_EXPORTS WCameraPosition Widget::cast<WCameraPosition>();
    826         template<> CV_EXPORTS WTrajectory Widget::cast<WTrajectory>();
    827         template<> CV_EXPORTS WTrajectoryFrustums Widget::cast<WTrajectoryFrustums>();
    828         template<> CV_EXPORTS WTrajectorySpheres Widget::cast<WTrajectorySpheres>();
    829         template<> CV_EXPORTS WCloud Widget::cast<WCloud>();
    830         template<> CV_EXPORTS WPaintedCloud Widget::cast<WPaintedCloud>();
    831         template<> CV_EXPORTS WCloudCollection Widget::cast<WCloudCollection>();
    832         template<> CV_EXPORTS WCloudNormals Widget::cast<WCloudNormals>();
    833         template<> CV_EXPORTS WMesh Widget::cast<WMesh>();
    834         template<> CV_EXPORTS WWidgetMerger Widget::cast<WWidgetMerger>();
    835 
    836 //! @}
    837 
    838     } /* namespace viz */
    839 } /* namespace cv */
    840 
    841 #endif
    842