~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/viz3d.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_VIZ3D_HPP__
 
47
#define __OPENCV_VIZ_VIZ3D_HPP__
 
48
 
 
49
#if !defined YES_I_AGREE_THAT_VIZ_API_IS_NOT_STABLE_NOW_AND_BINARY_COMPARTIBILITY_WONT_BE_SUPPORTED && !defined CVAPI_EXPORTS
 
50
    //#error "Viz is in beta state now. Please define macro above to use it"
 
51
#endif
 
52
 
 
53
#include <opencv2/core.hpp>
 
54
#include <opencv2/viz/types.hpp>
 
55
#include <opencv2/viz/widgets.hpp>
 
56
 
 
57
namespace cv
 
58
{
 
59
    namespace viz
 
60
    {
 
61
 
 
62
//! @addtogroup viz
 
63
//! @{
 
64
 
 
65
        /** @brief The Viz3d class represents a 3D visualizer window. This class is implicitly shared. :
 
66
        */
 
67
        class CV_EXPORTS Viz3d
 
68
        {
 
69
        public:
 
70
            typedef cv::viz::Color Color;
 
71
            typedef void (*KeyboardCallback)(const KeyboardEvent&, void*);
 
72
            typedef void (*MouseCallback)(const MouseEvent&, void*);
 
73
 
 
74
            /** @brief The constructors.
 
75
 
 
76
            @param window_name Name of the window.
 
77
             */
 
78
            Viz3d(const String& window_name = String());
 
79
            Viz3d(const Viz3d&);
 
80
            Viz3d& operator=(const Viz3d&);
 
81
            ~Viz3d();
 
82
 
 
83
            /** @brief Shows a widget in the window.
 
84
 
 
85
            @param id A unique id for the widget. @param widget The widget to be displayed in the window.
 
86
            @param pose Pose of the widget.
 
87
             */
 
88
            void showWidget(const String &id, const Widget &widget, const Affine3d &pose = Affine3d::Identity());
 
89
 
 
90
            /** @brief Removes a widget from the window.
 
91
 
 
92
            @param id The id of the widget that will be removed.
 
93
             */
 
94
            void removeWidget(const String &id);
 
95
 
 
96
            /** @brief Retrieves a widget from the window.
 
97
 
 
98
            A widget is implicitly shared; that is, if the returned widget is modified, the changes
 
99
            will be immediately visible in the window.
 
100
 
 
101
            @param id The id of the widget that will be returned.
 
102
             */
 
103
            Widget getWidget(const String &id) const;
 
104
 
 
105
            /** @brief Removes all widgets from the window.
 
106
            */
 
107
            void removeAllWidgets();
 
108
 
 
109
            /** @brief Removed all widgets and displays image scaled to whole window area.
 
110
 
 
111
            @param image Image to be displayed.
 
112
            @param window_size Size of Viz3d window. Default value means no change.
 
113
             */
 
114
            void showImage(InputArray image, const Size& window_size = Size(-1, -1));
 
115
 
 
116
            /** @brief Sets pose of a widget in the window.
 
117
 
 
118
            @param id The id of the widget whose pose will be set. @param pose The new pose of the widget.
 
119
             */
 
120
            void setWidgetPose(const String &id, const Affine3d &pose);
 
121
 
 
122
            /** @brief Updates pose of a widget in the window by pre-multiplying its current pose.
 
123
 
 
124
            @param id The id of the widget whose pose will be updated. @param pose The pose that the current
 
125
            pose of the widget will be pre-multiplied by.
 
126
             */
 
127
            void updateWidgetPose(const String &id, const Affine3d &pose);
 
128
 
 
129
            /** @brief Returns the current pose of a widget in the window.
 
130
 
 
131
            @param id The id of the widget whose pose will be returned.
 
132
             */
 
133
            Affine3d getWidgetPose(const String &id) const;
 
134
 
 
135
            /** @brief Sets the intrinsic parameters of the viewer using Camera.
 
136
 
 
137
            @param camera Camera object wrapping intrinsinc parameters.
 
138
             */
 
139
            void setCamera(const Camera &camera);
 
140
 
 
141
            /** @brief Returns a camera object that contains intrinsic parameters of the current viewer.
 
142
            */
 
143
            Camera getCamera() const;
 
144
 
 
145
            /** @brief Returns the current pose of the viewer.
 
146
            */
 
147
            Affine3d getViewerPose();
 
148
 
 
149
            /** @brief Sets pose of the viewer.
 
150
 
 
151
            @param pose The new pose of the viewer.
 
152
             */
 
153
            void setViewerPose(const Affine3d &pose);
 
154
 
 
155
            /** @brief Resets camera viewpoint to a 3D widget in the scene.
 
156
 
 
157
            @param id Id of a 3D widget.
 
158
             */
 
159
            void resetCameraViewpoint(const String &id);
 
160
 
 
161
            /** @brief Resets camera.
 
162
            */
 
163
            void resetCamera();
 
164
 
 
165
            /** @brief Transforms a point in world coordinate system to window coordinate system.
 
166
 
 
167
            @param pt Point in world coordinate system.
 
168
            @param window_coord Output point in window coordinate system.
 
169
             */
 
170
            void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
 
171
 
 
172
            /** @brief Transforms a point in window coordinate system to a 3D ray in world coordinate system.
 
173
 
 
174
            @param window_coord Point in window coordinate system. @param origin Output origin of the ray.
 
175
            @param direction Output direction of the ray.
 
176
             */
 
177
            void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
 
178
 
 
179
            /** @brief Returns the current size of the window.
 
180
            */
 
181
            Size getWindowSize() const;
 
182
            /** @brief Sets the size of the window.
 
183
 
 
184
            @param window_size New size of the window.
 
185
             */
 
186
            void setWindowSize(const Size &window_size);
 
187
 
 
188
            /** @brief Returns the name of the window which has been set in the constructor.
 
189
             */
 
190
            String getWindowName() const;
 
191
 
 
192
            /** @brief Returns the Mat screenshot of the current scene.
 
193
            */
 
194
            cv::Mat getScreenshot() const;
 
195
 
 
196
            /** @brief Saves screenshot of the current scene.
 
197
 
 
198
            @param file Name of the file.
 
199
             */
 
200
            void saveScreenshot(const String &file);
 
201
 
 
202
            /** @brief Sets the position of the window in the screen.
 
203
 
 
204
            @param window_position coordinates of the window
 
205
             */
 
206
            void setWindowPosition(const Point& window_position);
 
207
 
 
208
            /** @brief Sets or unsets full-screen rendering mode.
 
209
 
 
210
            @param mode If true, window will use full-screen mode.
 
211
             */
 
212
            void setFullScreen(bool mode = true);
 
213
 
 
214
            /** @brief Sets background color.
 
215
            */
 
216
            void setBackgroundColor(const Color& color = Color::black(), const Color& color2 = Color::not_set());
 
217
            void setBackgroundTexture(InputArray image = noArray());
 
218
            void setBackgroundMeshLab();
 
219
 
 
220
            /** @brief The window renders and starts the event loop.
 
221
            */
 
222
            void spin();
 
223
 
 
224
            /** @brief Starts the event loop for a given time.
 
225
 
 
226
            @param time Amount of time in milliseconds for the event loop to keep running.
 
227
            @param force_redraw If true, window renders.
 
228
             */
 
229
            void spinOnce(int time = 1, bool force_redraw = false);
 
230
 
 
231
            /** @brief Create a window in memory instead of on the screen.
 
232
             */
 
233
            void setOffScreenRendering();
 
234
 
 
235
            /** @brief Remove all lights from the current scene.
 
236
            */
 
237
            void removeAllLights();
 
238
 
 
239
            /** @brief Add a light in the scene.
 
240
 
 
241
            @param position The position of the light.
 
242
            @param focalPoint The point at which the light is shining
 
243
            @param color The color of the light
 
244
            @param diffuseColor The diffuse color of the light
 
245
            @param ambientColor The ambient color of the light
 
246
            @param specularColor The specular color of the light
 
247
             */
 
248
            void addLight(Vec3d position, Vec3d focalPoint = Vec3d(0, 0, 0), Color color = Color::white(),
 
249
                          Color diffuseColor = Color::white(), Color ambientColor = Color::black(), Color specularColor = Color::white());
 
250
 
 
251
            /** @brief Returns whether the event loop has been stopped.
 
252
            */
 
253
            bool wasStopped() const;
 
254
            void close();
 
255
 
 
256
            /** @brief Sets keyboard handler.
 
257
 
 
258
            @param callback Keyboard callback (void (\*KeyboardCallbackFunction(const
 
259
            KeyboardEvent&, void\*)).
 
260
            @param cookie The optional parameter passed to the callback.
 
261
             */
 
262
            void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
 
263
 
 
264
            /** @brief Sets mouse handler.
 
265
 
 
266
            @param callback Mouse callback (void (\*MouseCallback)(const MouseEvent&, void\*)).
 
267
            @param cookie The optional parameter passed to the callback.
 
268
             */
 
269
            void registerMouseCallback(MouseCallback callback, void* cookie = 0);
 
270
 
 
271
            /** @brief Sets rendering property of a widget.
 
272
 
 
273
            @param id Id of the widget.
 
274
            @param property Property that will be modified.
 
275
            @param value The new value of the property.
 
276
 
 
277
            **Rendering property** can be one of the following:
 
278
            -   **POINT_SIZE**
 
279
            -   **OPACITY**
 
280
            -   **LINE_WIDTH**
 
281
            -   **FONT_SIZE**
 
282
            -
 
283
            **REPRESENTATION**: Expected values are
 
284
            -   **REPRESENTATION_POINTS**
 
285
            -   **REPRESENTATION_WIREFRAME**
 
286
            -   **REPRESENTATION_SURFACE**
 
287
            -
 
288
            **IMMEDIATE_RENDERING**:
 
289
            -   Turn on immediate rendering by setting the value to 1.
 
290
            -   Turn off immediate rendering by setting the value to 0.
 
291
            -
 
292
            **SHADING**: Expected values are
 
293
            -   **SHADING_FLAT**
 
294
            -   **SHADING_GOURAUD**
 
295
            -   **SHADING_PHONG**
 
296
             */
 
297
            void setRenderingProperty(const String &id, int property, double value);
 
298
            /** @brief Returns rendering property of a widget.
 
299
 
 
300
            @param id Id of the widget.
 
301
            @param property Property.
 
302
 
 
303
            **Rendering property** can be one of the following:
 
304
            -   **POINT_SIZE**
 
305
            -   **OPACITY**
 
306
            -   **LINE_WIDTH**
 
307
            -   **FONT_SIZE**
 
308
            -
 
309
            **REPRESENTATION**: Expected values are
 
310
            -   **REPRESENTATION_POINTS**
 
311
            -   **REPRESENTATION_WIREFRAME**
 
312
            -   **REPRESENTATION_SURFACE**
 
313
            -
 
314
            **IMMEDIATE_RENDERING**:
 
315
            -   Turn on immediate rendering by setting the value to 1.
 
316
            -   Turn off immediate rendering by setting the value to 0.
 
317
            -
 
318
            **SHADING**: Expected values are
 
319
            -   **SHADING_FLAT**
 
320
            -   **SHADING_GOURAUD**
 
321
            -   **SHADING_PHONG**
 
322
             */
 
323
            double getRenderingProperty(const String &id, int property);
 
324
 
 
325
            /** @brief Sets geometry representation of the widgets to surface, wireframe or points.
 
326
 
 
327
            @param representation Geometry representation which can be one of the following:
 
328
            -   **REPRESENTATION_POINTS**
 
329
            -   **REPRESENTATION_WIREFRAME**
 
330
            -   **REPRESENTATION_SURFACE**
 
331
             */
 
332
            void setRepresentation(int representation);
 
333
 
 
334
            void setGlobalWarnings(bool enabled = false);
 
335
        private:
 
336
 
 
337
            struct VizImpl;
 
338
            VizImpl* impl_;
 
339
 
 
340
            void create(const String &window_name);
 
341
            void release();
 
342
 
 
343
            friend class VizStorage;
 
344
        };
 
345
 
 
346
//! @}
 
347
 
 
348
    } /* namespace viz */
 
349
} /* namespace cv */
 
350
 
 
351
#endif