vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZ_HPP
#define OPENCV_VIZ_HPP
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/widgets.hpp>
#include <opencv2/viz/viz3d.hpp>
#include <opencv2/viz/vizcore.hpp>
/**
@defgroup viz 3D Visualizer
This section describes 3D visualization window as well as classes and methods that are used to
interact with it.
3D visualization window (see Viz3d) is used to display widgets (see Widget), and it provides several
methods to interact with scene and widgets.
@{
@defgroup viz_widget Widget
In this section, the widget framework is explained. Widgets represent 2D or 3D objects, varying from
simple ones such as lines to complex ones such as point clouds and meshes.
Widgets are **implicitly shared**. Therefore, one can add a widget to the scene, and modify the
widget without re-adding the widget.
@code
// Create a cloud widget
viz::WCloud cw(cloud, viz::Color::red());
// Display it in a window
myWindow.showWidget("CloudWidget1", cw);
// Modify it, and it will be modified in the window.
cw.setColor(viz::Color::yellow());
@endcode
@}
*/
#endif /* OPENCV_VIZ_HPP */
+394
View File
@@ -0,0 +1,394 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZ_TYPES_HPP
#define OPENCV_VIZ_TYPES_HPP
#include <string>
#include <opencv2/core.hpp>
#include <opencv2/core/affine.hpp>
namespace cv
{
namespace viz
{
//! @addtogroup viz
//! @{
/** @brief This class represents color in BGR order.
*/
class Color : public Scalar // FIXIT design bug, missing CV_EXPORTS
{
public:
Color();
//! The three channels will have the same value equal to gray.
Color(double gray);
Color(double blue, double green, double red);
Color(const Scalar& color);
operator Vec3b() const;
static Color black();
static Color blue();
static Color green();
static Color red();
static Color cyan();
static Color yellow();
static Color magenta();
static Color white();
static Color gray();
static Color silver();
static Color mlab();
static Color navy();
static Color maroon();
static Color teal();
static Color olive();
static Color purple();
static Color azure();
static Color chartreuse();
static Color rose();
static Color lime();
static Color gold();
static Color orange();
static Color orange_red();
static Color indigo();
static Color brown();
static Color apricot();
static Color pink();
static Color raspberry();
static Color cherry();
static Color violet();
static Color amethyst();
static Color bluberry();
static Color celestial_blue();
static Color turquoise();
static Color not_set();
};
/** @brief This class wraps mesh attributes, and it can load a mesh from a ply file. :
*/
class CV_EXPORTS_W_SIMPLE Mesh
{
public:
enum {
LOAD_AUTO = 0,
LOAD_PLY = 1,
LOAD_OBJ = 2
};
CV_PROP_RW Mat cloud; //!< point coordinates of type CV_32FC3 or CV_64FC3 with only 1 row
CV_PROP_RW Mat colors; //!< point color of type CV_8UC3 or CV_8UC4 with only 1 row
CV_PROP_RW Mat normals; //!< point normals of type CV_32FC3, CV_32FC4, CV_64FC3 or CV_64FC4 with only 1 row
//! Raw integer list of the form: (n,id1,id2,...,idn, n,id1,id2,...,idn, ...)
//! where n is the number of points in the polygon, and id is a zero-offset index into an associated cloud.
CV_PROP_RW Mat polygons; //!< CV_32SC1 with only 1 row
CV_PROP_RW Mat texture;
CV_PROP_RW Mat tcoords; //!< CV_32FC2 or CV_64FC2 with only 1 row
CV_WRAP Mesh()
{
// nothing
}
/** @brief Loads a mesh from a ply or a obj file.
@param file File name
@param type File type (for now only PLY and OBJ are supported)
**File type** can be one of the following:
- **LOAD_PLY**
- **LOAD_OBJ**
*/
static Mesh load(const String& file, int type = LOAD_PLY);
};
/** @brief This class wraps intrinsic parameters of a camera.
It provides several constructors that can extract the intrinsic parameters from field of
view, intrinsic matrix and projection matrix. :
*/
class CV_EXPORTS Camera
{
public:
/** @brief Constructs a Camera.
@param fx Horizontal focal length.
@param fy Vertical focal length.
@param cx x coordinate of the principal point.
@param cy y coordinate of the principal point.
@param window_size Size of the window. This together with focal length and principal
point determines the field of view.
*/
Camera(double fx, double fy, double cx, double cy, const Size &window_size);
/** @overload
@param fov Field of view (horizontal, vertical) in radians
@param window_size Size of the window. Principal point is at the center of the window
by default.
*/
Camera(const Vec2d &fov, const Size &window_size);
/** @overload
@param K Intrinsic matrix of the camera with the following form
\f[
\begin{bmatrix}
f_x & 0 & c_x\\
0 & f_y & c_y\\
0 & 0 & 1\\
\end{bmatrix}
\f]
@param window_size Size of the window. This together with intrinsic matrix determines
the field of view.
*/
Camera(const Matx33d &K, const Size &window_size);
/** @overload
@param proj Projection matrix of the camera with the following form
\f[
\begin{bmatrix}
\frac{2n}{r-l} & 0 & \frac{r+l}{r-l} & 0\\
0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\
0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\
0 & 0 & -1 & 0\\
\end{bmatrix}
\f]
@param window_size Size of the window. This together with projection matrix determines
the field of view.
*/
explicit Camera(const Matx44d &proj, const Size &window_size);
const Vec2d & getClip() const { return clip_; }
void setClip(const Vec2d &clip) { clip_ = clip; }
const Size & getWindowSize() const { return window_size_; }
void setWindowSize(const Size &window_size);
const Vec2d& getFov() const { return fov_; }
void setFov(const Vec2d& fov) { fov_ = fov; }
const Vec2d& getPrincipalPoint() const { return principal_point_; }
const Vec2d& getFocalLength() const { return focal_; }
/** @brief Computes projection matrix using intrinsic parameters of the camera.
@param proj Output projection matrix with the following form
\f[
\begin{bmatrix}
\frac{2n}{r-l} & 0 & \frac{r+l}{r-l} & 0\\
0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\
0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\
0 & 0 & -1 & 0\\
\end{bmatrix}
\f]
*/
void computeProjectionMatrix(Matx44d &proj) const;
/** @brief Creates a Kinect Camera with
- fx = fy = 525
- cx = 320
- cy = 240
@param window_size Size of the window. This together with intrinsic matrix of a Kinect Camera
determines the field of view.
*/
static Camera KinectCamera(const Size &window_size);
private:
void init(double fx, double fy, double cx, double cy, const Size &window_size);
/** The near plane and the far plane.
* - clip_[0]: the near plane; default value is 0.01
* - clip_[1]: the far plane; default value is 1000.01
*/
Vec2d clip_;
/**
* Field of view.
* - fov_[0]: horizontal(x-axis) field of view in radians
* - fov_[1]: vertical(y-axis) field of view in radians
*/
Vec2d fov_;
/** Window size.*/
Size window_size_;
/**
* Principal point.
* - principal_point_[0]: cx
* - principal_point_[1]: cy
*/
Vec2d principal_point_;
/**
* Focal length.
* - focal_[0]: fx
* - focal_[1]: fy
*/
Vec2d focal_;
};
/** @brief This class represents a keyboard event.
*/
class CV_EXPORTS KeyboardEvent
{
public:
enum { NONE = 0, ALT = 1, CTRL = 2, SHIFT = 4 };
enum Action { KEY_UP = 0, KEY_DOWN = 1 };
/** @brief Constructs a KeyboardEvent.
@param action Signals if key is pressed or released.
@param symbol Name of the key.
@param code Code of the key.
@param modifiers Signals if alt, ctrl or shift are pressed or their combination.
*/
KeyboardEvent(Action action, const String& symbol, unsigned char code, int modifiers);
Action action;
String symbol;
unsigned char code;
int modifiers;
};
/** @brief This class represents a mouse event.
*/
class CV_EXPORTS MouseEvent
{
public:
enum Type { MouseMove = 1, MouseButtonPress, MouseButtonRelease, MouseScrollDown, MouseScrollUp, MouseDblClick } ;
enum MouseButton { NoButton = 0, LeftButton, MiddleButton, RightButton, VScroll } ;
/** @brief Constructs a MouseEvent.
@param type Type of the event. This can be **MouseMove**, **MouseButtonPress**,
**MouseButtonRelease**, **MouseScrollDown**, **MouseScrollUp**, **MouseDblClick**.
@param button Mouse button. This can be **NoButton**, **LeftButton**, **MiddleButton**,
**RightButton**, **VScroll**.
@param pointer Position of the event.
@param modifiers Signals if alt, ctrl or shift are pressed or their combination.
*/
MouseEvent(const Type& type, const MouseButton& button, const Point& pointer, int modifiers);
Type type;
MouseButton button;
Point pointer;
int modifiers;
};
//! @} viz
} /* namespace viz */
} /* namespace cv */
//! @cond IGNORED
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// cv::viz::Color
inline cv::viz::Color::Color() : Scalar(0, 0, 0) {}
inline cv::viz::Color::Color(double _gray) : Scalar(_gray, _gray, _gray) {}
inline cv::viz::Color::Color(double _blue, double _green, double _red) : Scalar(_blue, _green, _red) {}
inline cv::viz::Color::Color(const Scalar& color) : Scalar(color) {}
inline cv::viz::Color::operator cv::Vec3b() const { return cv::Vec3d(val); }
inline cv::viz::Color cv::viz::Color::black() { return Color( 0, 0, 0); }
inline cv::viz::Color cv::viz::Color::blue() { return Color(255, 0, 0); }
inline cv::viz::Color cv::viz::Color::green() { return Color( 0, 255, 0); }
inline cv::viz::Color cv::viz::Color::red() { return Color( 0, 0, 255); }
inline cv::viz::Color cv::viz::Color::cyan() { return Color(255, 255, 0); }
inline cv::viz::Color cv::viz::Color::yellow() { return Color( 0, 255, 255); }
inline cv::viz::Color cv::viz::Color::magenta() { return Color(255, 0, 255); }
inline cv::viz::Color cv::viz::Color::white() { return Color(255, 255, 255); }
inline cv::viz::Color cv::viz::Color::gray() { return Color(128, 128, 128); }
inline cv::viz::Color cv::viz::Color::silver() { return Color(192, 192, 192); }
inline cv::viz::Color cv::viz::Color::mlab() { return Color(255, 128, 128); }
inline cv::viz::Color cv::viz::Color::navy() { return Color(128, 0, 0); }
inline cv::viz::Color cv::viz::Color::maroon() { return Color( 0, 0, 128); }
inline cv::viz::Color cv::viz::Color::teal() { return Color(128, 128, 0); }
inline cv::viz::Color cv::viz::Color::olive() { return Color( 0, 128, 128); }
inline cv::viz::Color cv::viz::Color::purple() { return Color(128, 0, 128); }
inline cv::viz::Color cv::viz::Color::azure() { return Color(255, 128, 0); }
inline cv::viz::Color cv::viz::Color::chartreuse() { return Color( 0, 255, 128); }
inline cv::viz::Color cv::viz::Color::rose() { return Color(128, 0, 255); }
inline cv::viz::Color cv::viz::Color::lime() { return Color( 0, 255, 191); }
inline cv::viz::Color cv::viz::Color::gold() { return Color( 0, 215, 255); }
inline cv::viz::Color cv::viz::Color::orange() { return Color( 0, 165, 255); }
inline cv::viz::Color cv::viz::Color::orange_red() { return Color( 0, 69, 255); }
inline cv::viz::Color cv::viz::Color::indigo() { return Color(130, 0, 75); }
inline cv::viz::Color cv::viz::Color::brown() { return Color( 42, 42, 165); }
inline cv::viz::Color cv::viz::Color::apricot() { return Color(177, 206, 251); }
inline cv::viz::Color cv::viz::Color::pink() { return Color(203, 192, 255); }
inline cv::viz::Color cv::viz::Color::raspberry() { return Color( 92, 11, 227); }
inline cv::viz::Color cv::viz::Color::cherry() { return Color( 99, 29, 222); }
inline cv::viz::Color cv::viz::Color::violet() { return Color(226, 43, 138); }
inline cv::viz::Color cv::viz::Color::amethyst() { return Color(204, 102, 153); }
inline cv::viz::Color cv::viz::Color::bluberry() { return Color(247, 134, 79); }
inline cv::viz::Color cv::viz::Color::celestial_blue() { return Color(208, 151, 73); }
inline cv::viz::Color cv::viz::Color::turquoise() { return Color(208, 224, 64); }
inline cv::viz::Color cv::viz::Color::not_set() { return Color(-1, -1, -1); }
//! @endcond
#endif
+353
View File
@@ -0,0 +1,353 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZ_VIZ3D_HPP
#define OPENCV_VIZ_VIZ3D_HPP
#if !defined YES_I_AGREE_THAT_VIZ_API_IS_NOT_STABLE_NOW_AND_BINARY_COMPARTIBILITY_WONT_BE_SUPPORTED && !defined CVAPI_EXPORTS
//#error "Viz is in beta state now. Please define macro above to use it"
#endif
#include <opencv2/core.hpp>
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/widgets.hpp>
namespace cv
{
namespace viz
{
//! @addtogroup viz
//! @{
/** @brief The Viz3d class represents a 3D visualizer window. This class is implicitly shared.
*/
class CV_EXPORTS Viz3d
{
public:
typedef cv::viz::Color Color;
typedef void (*KeyboardCallback)(const KeyboardEvent&, void*);
typedef void (*MouseCallback)(const MouseEvent&, void*);
/** @brief The constructors.
@param window_name Name of the window.
*/
Viz3d(const String& window_name = String());
Viz3d(const Viz3d&);
Viz3d& operator=(const Viz3d&);
~Viz3d();
/** @brief Shows a widget in the window.
@param id A unique id for the widget. @param widget The widget to be displayed in the window.
@param pose Pose of the widget.
*/
void showWidget(const String &id, const Widget &widget, const Affine3d &pose = Affine3d::Identity());
/** @brief Removes a widget from the window.
@param id The id of the widget that will be removed.
*/
void removeWidget(const String &id);
/** @brief Retrieves a widget from the window.
A widget is implicitly shared; that is, if the returned widget is modified, the changes
will be immediately visible in the window.
@param id The id of the widget that will be returned.
*/
Widget getWidget(const String &id) const;
/** @brief Removes all widgets from the window.
*/
void removeAllWidgets();
/** @brief Removed all widgets and displays image scaled to whole window area.
@param image Image to be displayed.
@param window_size Size of Viz3d window. Default value means no change.
*/
void showImage(InputArray image, const Size& window_size = Size(-1, -1));
/** @brief Sets pose of a widget in the window.
@param id The id of the widget whose pose will be set. @param pose The new pose of the widget.
*/
void setWidgetPose(const String &id, const Affine3d &pose);
/** @brief Updates pose of a widget in the window by pre-multiplying its current pose.
@param id The id of the widget whose pose will be updated. @param pose The pose that the current
pose of the widget will be pre-multiplied by.
*/
void updateWidgetPose(const String &id, const Affine3d &pose);
/** @brief Returns the current pose of a widget in the window.
@param id The id of the widget whose pose will be returned.
*/
Affine3d getWidgetPose(const String &id) const;
/** @brief Sets the intrinsic parameters of the viewer using Camera.
@param camera Camera object wrapping intrinsic parameters.
*/
void setCamera(const Camera &camera);
/** @brief Returns a camera object that contains intrinsic parameters of the current viewer.
*/
Camera getCamera() const;
/** @brief Returns the current pose of the viewer.
*/
Affine3d getViewerPose() const;
/** @brief Sets pose of the viewer.
@param pose The new pose of the viewer.
*/
void setViewerPose(const Affine3d &pose);
/** @brief Resets camera viewpoint to a 3D widget in the scene.
@param id Id of a 3D widget.
*/
void resetCameraViewpoint(const String &id);
/** @brief Resets camera.
*/
void resetCamera();
/** @brief Transforms a point in world coordinate system to window coordinate system.
@param pt Point in world coordinate system.
@param window_coord Output point in window coordinate system.
*/
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
/** @brief Transforms a point in window coordinate system to a 3D ray in world coordinate system.
@param window_coord Point in window coordinate system. @param origin Output origin of the ray.
@param direction Output direction of the ray.
*/
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
/** @brief Returns the current size of the window.
*/
Size getWindowSize() const;
/** @brief Sets the size of the window.
@param window_size New size of the window.
*/
void setWindowSize(const Size &window_size);
/** @brief Returns the name of the window which has been set in the constructor.
* `Viz - ` is prepended to the name if necessary.
*/
String getWindowName() const;
/** @brief Returns the Mat screenshot of the current scene.
*/
cv::Mat getScreenshot() const;
/** @brief Saves screenshot of the current scene.
@param file Name of the file.
*/
void saveScreenshot(const String &file);
/** @brief Sets the position of the window in the screen.
@param window_position coordinates of the window
*/
void setWindowPosition(const Point& window_position);
/** @brief Sets or unsets full-screen rendering mode.
@param mode If true, window will use full-screen mode.
*/
void setFullScreen(bool mode = true);
/** @brief Sets background color.
*/
void setBackgroundColor(const Color& color = Color::black(), const Color& color2 = Color::not_set());
void setBackgroundTexture(InputArray image = noArray());
void setBackgroundMeshLab();
/** @brief The window renders and starts the event loop.
*/
void spin();
/** @brief Starts the event loop for a given time.
@param time Amount of time in milliseconds for the event loop to keep running.
@param force_redraw If true, window renders.
*/
void spinOnce(int time = 1, bool force_redraw = false);
/** @brief Create a window in memory instead of on the screen.
*/
void setOffScreenRendering();
/** @brief Remove all lights from the current scene.
*/
void removeAllLights();
/** @brief Add a light in the scene.
@param position The position of the light.
@param focalPoint The point at which the light is shining
@param color The color of the light
@param diffuseColor The diffuse color of the light
@param ambientColor The ambient color of the light
@param specularColor The specular color of the light
*/
void addLight(const Vec3d &position, const Vec3d &focalPoint = Vec3d(0, 0, 0), const Color &color = Color::white(),
const Color &diffuseColor = Color::white(), const Color &ambientColor = Color::black(),
const Color &specularColor = Color::white());
/** @brief Returns whether the event loop has been stopped.
*/
bool wasStopped() const;
void close();
/** @brief Sets keyboard handler.
@param callback Keyboard callback (void (\*KeyboardCallbackFunction(const
KeyboardEvent&, void\*)).
@param cookie The optional parameter passed to the callback.
*/
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
/** @brief Sets mouse handler.
@param callback Mouse callback (void (\*MouseCallback)(const MouseEvent&, void\*)).
@param cookie The optional parameter passed to the callback.
*/
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
/** @brief Sets rendering property of a widget.
@param id Id of the widget.
@param property Property that will be modified.
@param value The new value of the property.
Rendering property can be one of the following:
- **POINT_SIZE**
- **OPACITY**
- **LINE_WIDTH**
- **FONT_SIZE**
REPRESENTATION: Expected values are
- **REPRESENTATION_POINTS**
- **REPRESENTATION_WIREFRAME**
- **REPRESENTATION_SURFACE**
IMMEDIATE_RENDERING:
- Turn on immediate rendering by setting the value to 1.
- Turn off immediate rendering by setting the value to 0.
SHADING: Expected values are
- **SHADING_FLAT**
- **SHADING_GOURAUD**
- **SHADING_PHONG**
*/
void setRenderingProperty(const String &id, int property, double value);
/** @brief Returns rendering property of a widget.
@param id Id of the widget.
@param property Property.
Rendering property can be one of the following:
- **POINT_SIZE**
- **OPACITY**
- **LINE_WIDTH**
- **FONT_SIZE**
REPRESENTATION: Expected values are
- **REPRESENTATION_POINTS**
- **REPRESENTATION_WIREFRAME**
- **REPRESENTATION_SURFACE**
IMMEDIATE_RENDERING:
- Turn on immediate rendering by setting the value to 1.
- Turn off immediate rendering by setting the value to 0.
SHADING: Expected values are
- **SHADING_FLAT**
- **SHADING_GOURAUD**
- **SHADING_PHONG**
*/
double getRenderingProperty(const String &id, int property);
/** @brief Sets geometry representation of the widgets to surface, wireframe or points.
@param representation Geometry representation which can be one of the following:
- **REPRESENTATION_POINTS**
- **REPRESENTATION_WIREFRAME**
- **REPRESENTATION_SURFACE**
*/
void setRepresentation(int representation);
void setGlobalWarnings(bool enabled = false);
private:
struct VizImpl;
VizImpl* impl_;
void create(const String &window_name);
void release();
friend class VizStorage;
};
//! @}
} /* namespace viz */
} /* namespace cv */
#endif
+221
View File
@@ -0,0 +1,221 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZCORE_HPP
#define OPENCV_VIZCORE_HPP
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/widgets.hpp>
#include <opencv2/viz/viz3d.hpp>
namespace cv
{
namespace viz
{
//! @addtogroup viz
//! @{
/** @brief Takes coordinate frame data and builds transform to global coordinate frame.
@param axis_x X axis vector in global coordinate frame.
@param axis_y Y axis vector in global coordinate frame.
@param axis_z Z axis vector in global coordinate frame.
@param origin Origin of the coordinate frame in global coordinate frame.
@return An affine transform that describes transformation between global coordinate frame
and a given coordinate frame.
The returned transforms can transform a point in the given coordinate frame to the global
coordinate frame.
*/
CV_EXPORTS Affine3d makeTransformToGlobal(const Vec3d& axis_x, const Vec3d& axis_y, const Vec3d& axis_z, const Vec3d& origin = Vec3d::all(0));
/** @brief Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more
information).
@param position Position of the camera in global coordinate frame.
@param focal_point Focal point of the camera in global coordinate frame.
@param y_dir Up vector of the camera in global coordinate frame.
This function returns pose of the camera in global coordinate frame.
*/
CV_EXPORTS Affine3d makeCameraPose(const Vec3d& position, const Vec3d& focal_point, const Vec3d& y_dir);
/** @brief Retrieves a window by its name.
@param window_name Name of the window that is to be retrieved.
This function returns a Viz3d object with the given name.
@note If the window with that name already exists, that window is returned. Otherwise, new window is
created with the given name, and it is returned.
*/
CV_EXPORTS Viz3d getWindowByName(const String &window_name);
//! Unregisters all Viz windows from internal database. After it 'getWindowByName()' will create new windows instead of getting existing from the database.
CV_EXPORTS void unregisterAllWindows();
//! Displays image in specified window
CV_EXPORTS Viz3d imshow(const String& window_name, InputArray image, const Size& window_size = Size(-1, -1));
/** @brief Checks **float/double** value for nan.
@param x return true if nan.
*/
inline bool isNan(float x)
{
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
return ((u[0] & 0x7f800000) == 0x7f800000) && (u[0] & 0x007fffff);
}
/** @brief Checks **float/double** value for nan.
@param x return true if nan.
*/
inline bool isNan(double x)
{
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
return (u[1] & 0x7ff00000) == 0x7ff00000 && (u[0] != 0 || (u[1] & 0x000fffff) != 0);
}
/** @brief Checks **float/double** value for nan.
@param v return true if **any** of the elements of the vector is *nan*.
*/
template<typename _Tp, int cn> inline bool isNan(const Vec<_Tp, cn>& v)
{ return isNan(v.val[0]) || isNan(v.val[1]) || isNan(v.val[2]); }
/** @brief Checks **float/double** value for nan.
@param p return true if **any** of the elements of the point is *nan*.
*/
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read/write clouds. Supported formats: ply, xyz, obj and stl (readonly)
/**
* @param file Filename with extension. Supported formats: PLY, XYZ and OBJ.
* @param cloud Supported depths: CV_32F and CV_64F. Supported channels: 3 and 4.
* @param colors Used by PLY format only. Supported depth: CV_8U. Supported channels: 1, 3 and 4.
* @param normals Used by PLY and OBJ format only. Supported depths: CV_32F and CV_64F.
* Supported channels: 3 and 4.
* @param binary Used only for PLY format.
*/
CV_EXPORTS_W void writeCloud(const String& file, InputArray cloud, InputArray colors = noArray(), InputArray normals = noArray(), bool binary = false);
/**
* @param file Filename with extension. Supported formats: PLY, XYZ, OBJ and STL.
* @param colors Used by PLY and STL formats only.
* @param normals Used by PLY, OBJ and STL formats only.
* @return A mat containing the point coordinates with depth CV_32F or CV_64F and number of
* channels 3 or 4 with only 1 row.
*/
CV_EXPORTS_W Mat readCloud (const String& file, OutputArray colors = noArray(), OutputArray normals = noArray());
///////////////////////////////////////////////////////////////////////////////////////////////
/// Reads mesh. Only ply format is supported now and no texture load support
CV_EXPORTS_W Mesh readMesh(const String& file);
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read/write poses and trajectories
/**
* @param file Filename of type supported by cv::FileStorage.
* @param pose Output matrix.
* @param tag Name of the pose in the file.
*/
CV_EXPORTS bool readPose(const String& file, Affine3d& pose, const String& tag = "pose");
/**
* @param file Filename.
* @param pose Input matrix.
* @param tag Name of the pose to be saved into the given file.
*/
CV_EXPORTS void writePose(const String& file, const Affine3d& pose, const String& tag = "pose");
/** takes vector<Affine3<T>> with T = float/double and writes to a sequence of files with given filename format
* @param traj Trajectory containing a list of poses. It can be
* - std::vector<cv::Mat>, each cv::Mat is of type CV_32F16 or CV_64FC16
* - std::vector<cv::Affine3f>, std::vector<cv::Affine3d>
* - cv::Mat of type CV_32FC16 OR CV_64F16
* @param files_format Format specifier string for constructing filenames.
* The only placeholder in the string should support `int`.
* @param start The initial counter for files_format.
* @param tag Name of the matrix in the file.
*/
CV_EXPORTS void writeTrajectory(InputArray traj, const String& files_format = "pose%05d.xml", int start = 0, const String& tag = "pose");
/** takes vector<Affine3<T>> with T = float/double and loads poses from sequence of files
*
* @param traj Output array containing a lists of poses. It can be
* - std::vector<cv::Affine3f>, std::vector<cv::Affine3d>
* - cv::Mat
* @param files_format Format specifier string for constructing filenames.
* The only placeholder in the string should support `int`.
* @param start The initial counter for files_format. It must be greater than or equal to 0.
* @param end The final counter for files_format.
* @param tag Name of the matrix in the file.
*/
CV_EXPORTS void readTrajectory(OutputArray traj, const String& files_format = "pose%05d.xml", int start = 0, int end = INT_MAX, const String& tag = "pose");
///////////////////////////////////////////////////////////////////////////////////////////////
/** Computing normals for mesh
* @param mesh Input mesh.
* @param normals Normals at very point in the mesh of type CV_64FC3.
*/
CV_EXPORTS_W void computeNormals(const Mesh& mesh, OutputArray normals);
//! @}
} /* namespace viz */
} /* namespace cv */
#endif /* OPENCV_VIZCORE_HPP */
@@ -0,0 +1,89 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZ_WIDGET_ACCESSOR_HPP
#define OPENCV_VIZ_WIDGET_ACCESSOR_HPP
#include <opencv2/core/cvdef.h>
#include <vtkSmartPointer.h>
#include <vtkProp.h>
namespace cv
{
namespace viz
{
//! @addtogroup viz_widget
//! @{
class Widget;
/** @brief This class is for users who want to develop their own widgets using VTK library API. :
*/
struct CV_EXPORTS WidgetAccessor
{
/** @brief Returns vtkProp of a given widget.
@param widget Widget whose vtkProp is to be returned.
@note vtkProp has to be down cast appropriately to be modified.
@code
vtkActor * actor = vtkActor::SafeDownCast(viz::WidgetAccessor::getProp(widget));
@endcode
*/
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
/** @brief Sets vtkProp of a given widget.
@param widget Widget whose vtkProp is to be set. @param prop A vtkProp.
*/
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
};
//! @}
}
}
#endif
+853
View File
@@ -0,0 +1,853 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef OPENCV_VIZ_WIDGETS_HPP
#define OPENCV_VIZ_WIDGETS_HPP
#include <opencv2/viz/types.hpp>
namespace cv
{
namespace viz
{
//! @addtogroup viz_widget
//! @{
/////////////////////////////////////////////////////////////////////////////
/// Widget rendering properties
enum RenderingProperties
{
POINT_SIZE,
OPACITY,
LINE_WIDTH,
FONT_SIZE,
REPRESENTATION,
IMMEDIATE_RENDERING,
SHADING,
AMBIENT,
LIGHTING
};
enum RepresentationValues
{
REPRESENTATION_POINTS,
REPRESENTATION_WIREFRAME,
REPRESENTATION_SURFACE
};
enum ShadingValues
{
SHADING_FLAT,
SHADING_GOURAUD,
SHADING_PHONG
};
/////////////////////////////////////////////////////////////////////////////
/** @brief Base class of all widgets. Widget is implicitly shared.
*/
class CV_EXPORTS Widget
{
public:
Widget();
Widget(const Widget& other);
Widget& operator=(const Widget& other);
virtual ~Widget();
/** @brief Creates a widget from ply file.
@param file_name Ply file name.
*/
static Widget fromPlyFile(const String &file_name);
/** @brief Sets rendering property of the widget.
@param property Property that will be modified.
@param value The new value of the property.
Rendering property can be one of the following:
- **POINT_SIZE**
- **OPACITY**
- **LINE_WIDTH**
- **FONT_SIZE**
REPRESENTATION: Expected values are
- **REPRESENTATION_POINTS**
- **REPRESENTATION_WIREFRAME**
- **REPRESENTATION_SURFACE**
IMMEDIATE_RENDERING:
- Turn on immediate rendering by setting the value to 1.
- Turn off immediate rendering by setting the value to 0.
SHADING: Expected values are
- **SHADING_FLAT**
- **SHADING_GOURAUD**
- **SHADING_PHONG**
*/
void setRenderingProperty(int property, double value);
/** @brief Returns rendering property of the widget.
@param property Property.
Rendering property can be one of the following:
- **POINT_SIZE**
- **OPACITY**
- **LINE_WIDTH**
- **FONT_SIZE**
- **AMBIENT**
REPRESENTATION: Expected values are
- **REPRESENTATION_POINTS**
- **REPRESENTATION_WIREFRAME**
- **REPRESENTATION_SURFACE**
**IMMEDIATE_RENDERING**:
- Turn on immediate rendering by setting the value to 1.
- Turn off immediate rendering by setting the value to 0.
SHADING: Expected values are
- **SHADING_FLAT**
- **SHADING_GOURAUD**
- **SHADING_PHONG**
*/
double getRenderingProperty(int property) const;
/** @brief Casts a widget to another.
@code
// Create a sphere widget
viz::WSphere sw(Point3f(0.0f,0.0f,0.0f), 0.5f);
// Cast sphere widget to cloud widget
viz::WCloud cw = sw.cast<viz::WCloud>();
@endcode
@note 3D Widgets can only be cast to 3D Widgets. 2D Widgets can only be cast to 2D Widgets.
*/
template<typename _W> _W cast() const;
private:
class Impl;
Impl *impl_;
friend struct WidgetAccessor;
};
/////////////////////////////////////////////////////////////////////////////
/** @brief Base class of all 3D widgets.
*/
class CV_EXPORTS Widget3D : public Widget
{
public:
Widget3D() {}
/** @brief Sets pose of the widget.
@param pose The new pose of the widget.
*/
void setPose(const Affine3d &pose);
/** @brief Updates pose of the widget by pre-multiplying its current pose.
@param pose The pose that the current pose of the widget will be pre-multiplied by.
*/
void updatePose(const Affine3d &pose);
/** @brief Returns the current pose of the widget.
*/
Affine3d getPose() const;
/** @brief Transforms internal widget data (i.e. points, normals) using the given transform.
@param transform Specified transformation to apply.
*/
void applyTransform(const Affine3d &transform);
/** @brief Sets the color of the widget.
@param color color of type Color
*/
void setColor(const Color &color);
};
/////////////////////////////////////////////////////////////////////////////
/** @brief Base class of all 2D widgets.
*/
class CV_EXPORTS Widget2D : public Widget
{
public:
Widget2D() {}
/** @brief Sets the color of the widget.
@param color color of type Color
*/
void setColor(const Color &color);
};
/////////////////////////////////////////////////////////////////////////////
/// Simple widgets
/** @brief This 3D Widget defines a finite line.
*/
class CV_EXPORTS WLine : public Widget3D
{
public:
/** @brief Constructs a WLine.
@param pt1 Start point of the line.
@param pt2 End point of the line.
@param color Color of the line.
*/
WLine(const Point3d &pt1, const Point3d &pt2, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a finite plane.
*/
class CV_EXPORTS WPlane : public Widget3D
{
public:
/** @brief Constructs a default plane with center point at origin and normal oriented along z-axis.
@param size Size of the plane
@param color Color of the plane.
*/
WPlane(const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());
/** @brief Constructs a repositioned plane
@param center Center of the plane
@param normal Plane normal orientation
@param new_yaxis Up-vector. New orientation of plane y-axis.
@param size
@param color Color of the plane.
*/
WPlane(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis,
const Size2d& size = Size2d(1.0, 1.0), const Color &color = Color::white());
};
/** @brief This 3D Widget defines a sphere. :
*/
class CV_EXPORTS WSphere : public Widget3D
{
public:
/** @brief Constructs a WSphere.
@param center Center of the sphere.
@param radius Radius of the sphere.
@param sphere_resolution Resolution of the sphere.
@param color Color of the sphere.
*/
WSphere(const cv::Point3d &center, double radius, int sphere_resolution = 10, const Color &color = Color::white());
};
/** @brief This 3D Widget defines an arrow.
*/
class CV_EXPORTS WArrow : public Widget3D
{
public:
/** @brief Constructs an WArrow.
@param pt1 Start point of the arrow.
@param pt2 End point of the arrow.
@param thickness Thickness of the arrow. Thickness of arrow head is also adjusted
accordingly.
@param color Color of the arrow.
Arrow head is located at the end point of the arrow.
*/
WArrow(const Point3d& pt1, const Point3d& pt2, double thickness = 0.03, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a circle.
*/
class CV_EXPORTS WCircle : public Widget3D
{
public:
/** @brief Constructs default planar circle centered at origin with plane normal along z-axis
@param radius Radius of the circle.
@param thickness Thickness of the circle.
@param color Color of the circle.
*/
WCircle(double radius, double thickness = 0.01, const Color &color = Color::white());
/** @brief Constructs repositioned planar circle.
@param radius Radius of the circle.
@param center Center of the circle.
@param normal Normal of the plane in which the circle lies.
@param thickness Thickness of the circle.
@param color Color of the circle.
*/
WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a cone. :
*/
class CV_EXPORTS WCone : public Widget3D
{
public:
/** @brief Constructs default cone oriented along x-axis with center of its base located at origin
@param length Length of the cone.
@param radius Radius of the cone.
@param resolution Resolution of the cone.
@param color Color of the cone.
*/
WCone(double length, double radius, int resolution = 6, const Color &color = Color::white());
/** @brief Constructs repositioned planar cone.
@param radius Radius of the cone.
@param center Center of the cone base.
@param tip Tip of the cone.
@param resolution Resolution of the cone.
@param color Color of the cone.
*/
WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a cylinder. :
*/
class CV_EXPORTS WCylinder : public Widget3D
{
public:
/** @brief Constructs a WCylinder.
@param axis_point1 A point1 on the axis of the cylinder.
@param axis_point2 A point2 on the axis of the cylinder.
@param radius Radius of the cylinder.
@param numsides Resolution of the cylinder.
@param color Color of the cylinder.
*/
WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides = 30, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a cube.
*/
class CV_EXPORTS WCube : public Widget3D
{
public:
/** @brief Constructs a WCube.
@param min_point Specifies minimum (or maximum) point of the bounding box.
@param max_point Specifies maximum (or minimum) point of the bounding box, opposite to the first parameter.
@param wire_frame If true, cube is represented as wireframe.
@param color Color of the cube.
![Cube Widget](images/cube_widget.png)
*/
WCube(const Point3d& min_point = Vec3d::all(-0.5), const Point3d& max_point = Vec3d::all(0.5),
bool wire_frame = true, const Color &color = Color::white());
};
/** @brief This 3D Widget defines a poly line. :
*/
class CV_EXPORTS WPolyLine : public Widget3D
{
public:
WPolyLine(InputArray points, InputArray colors);
/** @brief Constructs a WPolyLine.
@param points Point set.
@param color Color of the poly line.
*/
WPolyLine(InputArray points, const Color &color = Color::white());
};
/////////////////////////////////////////////////////////////////////////////
/// Text and image widgets
/** @brief This 2D Widget represents text overlay.
*/
class CV_EXPORTS WText : public Widget2D
{
public:
/** @brief Constructs a WText.
@param text Text content of the widget.
@param pos Position of the text.
@param font_size Font size.
@param color Color of the text.
*/
WText(const String &text, const Point &pos, int font_size = 20, const Color &color = Color::white());
/** @brief Sets the text content of the widget.
@param text Text content of the widget.
*/
void setText(const String &text);
/** @brief Returns the current text content of the widget.
*/
String getText() const;
};
/** @brief This 3D Widget represents 3D text. The text always faces the camera.
*/
class CV_EXPORTS WText3D : public Widget3D
{
public:
/** @brief Constructs a WText3D.
@param text Text content of the widget.
@param position Position of the text.
@param text_scale Size of the text.
@param face_camera If true, text always faces the camera.
@param color Color of the text.
*/
WText3D(const String &text, const Point3d &position, double text_scale = 1., bool face_camera = true, const Color &color = Color::white());
/** @brief Sets the text content of the widget.
@param text Text content of the widget.
*/
void setText(const String &text);
/** @brief Returns the current text content of the widget.
*/
String getText() const;
};
/** @brief This 2D Widget represents an image overlay. :
*/
class CV_EXPORTS WImageOverlay : public Widget2D
{
public:
/** @brief Constructs an WImageOverlay.
@param image BGR or Gray-Scale image.
@param rect Image is scaled and positioned based on rect.
*/
WImageOverlay(InputArray image, const Rect &rect);
/** @brief Sets the image content of the widget.
@param image BGR or Gray-Scale image.
*/
void setImage(InputArray image);
};
/** @brief This 3D Widget represents an image in 3D space. :
*/
class CV_EXPORTS WImage3D : public Widget3D
{
public:
/** @brief Constructs an WImage3D.
@param image BGR or Gray-Scale image.
@param size Size of the image.
*/
WImage3D(InputArray image, const Size2d &size);
/** @brief Constructs an WImage3D.
@param image BGR or Gray-Scale image.
@param size Size of the image.
@param center Position of the image.
@param normal Normal of the plane that represents the image.
@param up_vector Determines orientation of the image.
*/
WImage3D(InputArray image, const Size2d &size, const Vec3d &center, const Vec3d &normal, const Vec3d &up_vector);
/** @brief Sets the image content of the widget.
@param image BGR or Gray-Scale image.
*/
void setImage(InputArray image);
/** @brief Sets the image size of the widget.
@param size the new size of the image.
*/
void setSize(const Size& size);
};
/////////////////////////////////////////////////////////////////////////////
/// Compound widgets
/** @brief This 3D Widget represents a coordinate system. :
*/
class CV_EXPORTS WCoordinateSystem : public Widget3D
{
public:
/** @brief Constructs a WCoordinateSystem.
@param scale Determines the size of the axes.
*/
WCoordinateSystem(double scale = 1.0);
};
/** @brief This 3D Widget defines a grid. :
*/
class CV_EXPORTS WGrid : public Widget3D
{
public:
/** @brief Constructs a WGrid.
@param cells Number of cell columns and rows, respectively.
@param cells_spacing Size of each cell, respectively.
@param color Color of the grid.
*/
WGrid(const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());
//! Creates repositioned grid
WGrid(const Point3d& center, const Vec3d& normal, const Vec3d& new_yaxis,
const Vec2i &cells = Vec2i::all(10), const Vec2d &cells_spacing = Vec2d::all(1.0), const Color &color = Color::white());
};
/** @brief This 3D Widget represents camera position in a scene by its axes or viewing frustum. :
*/
class CV_EXPORTS WCameraPosition : public Widget3D
{
public:
/** @brief Creates camera coordinate frame at the origin.
![Camera coordinate frame](images/cpw1.png)
*/
WCameraPosition(double scale = 1.0);
/** @brief Display the viewing frustum
@param K Intrinsic matrix of the camera.
@param scale Scale of the frustum.
@param color Color of the frustum.
Creates viewing frustum of the camera based on its intrinsic matrix K.
![Camera viewing frustum](images/cpw2.png)
*/
WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
/** @brief Display the viewing frustum
@param fov Field of view of the camera (horizontal, vertical).
@param scale Scale of the frustum.
@param color Color of the frustum.
Creates viewing frustum of the camera based on its field of view fov.
![Camera viewing frustum](images/cpw2.png)
*/
WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
/** @brief Display image on the far plane of the viewing frustum
@param K Intrinsic matrix of the camera.
@param image BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
@param scale Scale of the frustum and image.
@param color Color of the frustum.
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on
the far end plane.
![Camera viewing frustum with image](images/cpw3.png)
*/
WCameraPosition(const Matx33d &K, InputArray image, double scale = 1.0, const Color &color = Color::white());
/** @brief Display image on the far plane of the viewing frustum
@param fov Field of view of the camera (horizontal, vertical).
@param image BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
@param scale Scale of the frustum and image.
@param color Color of the frustum.
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on
the far end plane.
![Camera viewing frustum with image](images/cpw3.png)
*/
WCameraPosition(const Vec2d &fov, InputArray image, double scale = 1.0, const Color &color = Color::white());
};
/////////////////////////////////////////////////////////////////////////////
/// Trajectories
/** @brief This 3D Widget represents a trajectory. :
*/
class CV_EXPORTS WTrajectory : public Widget3D
{
public:
enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH };
/** @brief Constructs a WTrajectory.
@param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
@param display_mode Display mode. This can be PATH, FRAMES, and BOTH.
@param scale Scale of the frames. Polyline is not affected.
@param color Color of the polyline that represents path.
Frames are not affected.
Displays trajectory of the given path as follows:
- PATH : Displays a poly line that represents the path.
- FRAMES : Displays coordinate frames at each pose.
- PATH & FRAMES : Displays both poly line and coordinate frames.
*/
WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.0, const Color &color = Color::white());
};
/** @brief This 3D Widget represents a trajectory. :
*/
class CV_EXPORTS WTrajectoryFrustums : public Widget3D
{
public:
/** @brief Constructs a WTrajectoryFrustums.
@param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
@param K Intrinsic matrix of the camera.
@param scale Scale of the frustums.
@param color Color of the frustums.
Displays frustums at each pose of the trajectory.
*/
WTrajectoryFrustums(InputArray path, const Matx33d &K, double scale = 1., const Color &color = Color::white());
/** @brief Constructs a WTrajectoryFrustums.
@param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
@param fov Field of view of the camera (horizontal, vertical).
@param scale Scale of the frustums.
@param color Color of the frustums.
Displays frustums at each pose of the trajectory.
*/
WTrajectoryFrustums(InputArray path, const Vec2d &fov, double scale = 1., const Color &color = Color::white());
};
/** @brief This 3D Widget represents a trajectory using spheres and lines
where spheres represent the positions of the camera, and lines represent the direction from
previous position to the current. :
*/
class CV_EXPORTS WTrajectorySpheres: public Widget3D
{
public:
/** @brief Constructs a WTrajectorySpheres.
@param path List of poses on a trajectory. Takes std::vector\<Affine\<T\>\> with T == [float | double]
@param line_length Max length of the lines which point to previous position
@param radius Radius of the spheres.
@param from Color for first sphere.
@param to Color for last sphere. Intermediate spheres will have interpolated color.
*/
WTrajectorySpheres(InputArray path, double line_length = 0.05, double radius = 0.007,
const Color &from = Color::red(), const Color &to = Color::white());
};
/////////////////////////////////////////////////////////////////////////////
/// Clouds
/** @brief This 3D Widget defines a point cloud. :
@note In case there are four channels in the cloud, fourth channel is ignored.
*/
class CV_EXPORTS WCloud: public Widget3D
{
public:
/** @brief Constructs a WCloud.
@param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param colors Set of colors. It has to be of the same size with cloud.
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
WCloud(InputArray cloud, InputArray colors);
/** @brief Constructs a WCloud.
@param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param color A single Color for the whole cloud.
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
WCloud(InputArray cloud, const Color &color = Color::white());
/** @brief Constructs a WCloud.
@param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param colors Set of colors. It has to be of the same size with cloud.
@param normals Normals for each point in cloud. Size and type should match with the cloud parameter.
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
WCloud(InputArray cloud, InputArray colors, InputArray normals);
/** @brief Constructs a WCloud.
@param cloud Set of points which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param color A single Color for the whole cloud.
@param normals Normals for each point in cloud.
Size and type should match with the cloud parameter.
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
WCloud(InputArray cloud, const Color &color, InputArray normals);
};
class CV_EXPORTS WPaintedCloud: public Widget3D
{
public:
//! Paint cloud with default gradient between cloud bounds points
WPaintedCloud(InputArray cloud);
//! Paint cloud with default gradient between given points
WPaintedCloud(InputArray cloud, const Point3d& p1, const Point3d& p2);
//! Paint cloud with gradient specified by given colors between given points
WPaintedCloud(InputArray cloud, const Point3d& p1, const Point3d& p2, const Color& c1, const Color c2);
};
/** @brief This 3D Widget defines a collection of clouds. :
@note In case there are four channels in the cloud, fourth channel is ignored.
*/
class CV_EXPORTS WCloudCollection : public Widget3D
{
public:
WCloudCollection();
/** @brief Adds a cloud to the collection.
@param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param colors Set of colors. It has to be of the same size with cloud.
@param pose Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
/** @brief Adds a cloud to the collection.
@param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param color A single Color for the whole cloud.
@param pose Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
*/
void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3d &pose = Affine3d::Identity());
/** @brief Finalizes cloud data by repacking to single cloud.
Useful for large cloud collections to reduce memory usage
*/
void finalize();
};
/** @brief This 3D Widget represents normals of a point cloud. :
*/
class CV_EXPORTS WCloudNormals : public Widget3D
{
public:
/** @brief Constructs a WCloudNormals.
@param cloud Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4.
@param normals A set of normals that has to be of same type with cloud.
@param level Display only every level th normal.
@param scale Scale of the arrows that represent normals.
@param color Color of the arrows that represent normals.
@note In case there are four channels in the cloud, fourth channel is ignored.
*/
WCloudNormals(InputArray cloud, InputArray normals, int level = 64, double scale = 0.1, const Color &color = Color::white());
};
/** @brief Constructs a WMesh.
@param mesh Mesh object that will be displayed.
@param cloud Points of the mesh object.
@param polygons Points of the mesh object.
@param colors Point colors.
@param normals Point normals.
*/
class CV_EXPORTS_W WMesh
#ifndef OPENCV_BINDING_PARSER
: public Widget3D
#endif
{
public:
CV_WRAP WMesh(const Mesh &mesh);
CV_WRAP WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
};
/** @brief This class allows to merge several widgets to single one.
It has quite limited functionality and can't merge widgets with different attributes. For
instance, if widgetA has color array and widgetB has only global color defined, then result
of merge won't have color at all. The class is suitable for merging large amount of similar
widgets. :
*/
class CV_EXPORTS WWidgetMerger : public Widget3D
{
public:
WWidgetMerger();
//! Add widget to merge with optional position change
void addWidget(const Widget3D& widget, const Affine3d &pose = Affine3d::Identity());
//! Repacks internal structure to single widget
void finalize();
};
/////////////////////////////////////////////////////////////////////////////
/// Utility exports
template<> CV_EXPORTS Widget2D Widget::cast<Widget2D>() const;
template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>() const;
template<> CV_EXPORTS WLine Widget::cast<WLine>() const;
template<> CV_EXPORTS WPlane Widget::cast<WPlane>() const;
template<> CV_EXPORTS WSphere Widget::cast<WSphere>() const;
template<> CV_EXPORTS WCylinder Widget::cast<WCylinder>() const;
template<> CV_EXPORTS WArrow Widget::cast<WArrow>() const;
template<> CV_EXPORTS WCircle Widget::cast<WCircle>() const;
template<> CV_EXPORTS WCone Widget::cast<WCone>() const;
template<> CV_EXPORTS WCube Widget::cast<WCube>() const;
template<> CV_EXPORTS WCoordinateSystem Widget::cast<WCoordinateSystem>() const;
template<> CV_EXPORTS WPolyLine Widget::cast<WPolyLine>() const;
template<> CV_EXPORTS WGrid Widget::cast<WGrid>() const;
template<> CV_EXPORTS WText3D Widget::cast<WText3D>() const;
template<> CV_EXPORTS WText Widget::cast<WText>() const;
template<> CV_EXPORTS WImageOverlay Widget::cast<WImageOverlay>() const;
template<> CV_EXPORTS WImage3D Widget::cast<WImage3D>() const;
template<> CV_EXPORTS WCameraPosition Widget::cast<WCameraPosition>() const;
template<> CV_EXPORTS WTrajectory Widget::cast<WTrajectory>() const;
template<> CV_EXPORTS WTrajectoryFrustums Widget::cast<WTrajectoryFrustums>() const;
template<> CV_EXPORTS WTrajectorySpheres Widget::cast<WTrajectorySpheres>() const;
template<> CV_EXPORTS WCloud Widget::cast<WCloud>() const;
template<> CV_EXPORTS WPaintedCloud Widget::cast<WPaintedCloud>() const;
template<> CV_EXPORTS WCloudCollection Widget::cast<WCloudCollection>() const;
template<> CV_EXPORTS WCloudNormals Widget::cast<WCloudNormals>() const;
template<> CV_EXPORTS WMesh Widget::cast<WMesh>() const;
template<> CV_EXPORTS WWidgetMerger Widget::cast<WWidgetMerger>() const;
//! @}
} /* namespace viz */
} /* namespace cv */
#endif