~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/modules/viz/include/opencv2/viz/widgets.hpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

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