opencv/modules/viz/doc/viz3d.rst

657 lines
20 KiB
ReStructuredText
Raw Normal View History

2013-09-08 20:26:58 +08:00
Viz
===
2013-09-02 01:34:17 +08:00
.. highlight:: cpp
2013-09-08 20:26:58 +08:00
This section describes 3D visualization window as well as classes and methods
2013-09-18 19:50:55 +08:00
that are used to interact with it.
2013-09-08 20:26:58 +08:00
3D visualization window (see :ocv:class:`Viz3d`) is used to display widgets (see :ocv:class:`Widget`), and it provides
several methods to interact with scene and widgets.
viz::makeTransformToGlobal
--------------------------
Takes coordinate frame data and builds transform to global coordinate frame.
.. ocv:function:: Affine3f viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0))
: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.
This function returns affine transform that describes transformation between global coordinate frame and a given coordinate frame.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::makeCameraPose
-------------------
Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation).
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
.. ocv:function:: Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& y_dir)
: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.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
This function returns pose of the camera in global coordinate frame.
viz::get
--------
Retrieves a window by its name.
.. ocv:function:: Viz3d get(const String &window_name)
:param window_name: Name of the window that is to be retrieved.
2013-09-18 19:50:55 +08:00
This function returns a :ocv:class:`Viz3d` object with the given name.
2013-09-08 20:26:58 +08:00
.. 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.
.. note:: Window names are automatically prefixed by "Viz - " if it is not done by the user.
.. code-block:: cpp
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
/// window and window_2 are the same windows.
viz::Viz3d window = viz::get("myWindow");
viz::Viz3d window_2 = viz::get("Viz - myWindow");
viz::isNan
----------
Checks **float/double** value for nan.
.. ocv:function:: bool isNan(float x)
.. ocv:function:: bool isNan(double x)
:param x: return true if nan.
Checks **vector** for nan.
.. ocv:function:: bool isNan(const Vec<_Tp, cn>& v)
:param v: return true if **any** of the elements of the vector is *nan*.
Checks **point** for nan
.. ocv:function:: bool isNan(const Point3_<_Tp>& p)
:param p: return true if **any** of the elements of the point is *nan*.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d
----------
2013-09-02 01:34:17 +08:00
.. ocv:class:: Viz3d
2013-09-02 02:12:31 +08:00
The Viz3d class represents a 3D visualizer window. This class is implicitly shared. ::
class CV_EXPORTS Viz3d
{
public:
typedef cv::Ptr<Viz3d> Ptr;
typedef void (*KeyboardCallback)(const KeyboardEvent&, void*);
typedef void (*MouseCallback)(const MouseEvent&, void*);
Viz3d(const String& window_name = String());
Viz3d(const Viz3d&);
Viz3d& operator=(const Viz3d&);
~Viz3d();
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
void removeWidget(const String &id);
Widget getWidget(const String &id) const;
void removeAllWidgets();
void setWidgetPose(const String &id, const Affine3f &pose);
void updateWidgetPose(const String &id, const Affine3f &pose);
Affine3f getWidgetPose(const String &id) const;
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void setCamera(const Camera &camera);
Camera getCamera() const;
Affine3f getViewerPose();
void setViewerPose(const Affine3f &pose);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void resetCameraViewpoint (const String &id);
void resetCamera();
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
Size getWindowSize() const;
void setWindowSize(const Size &window_size);
String getWindowName() const;
void saveScreenshot (const String &file);
void setWindowPosition (int x, int y);
void setFullScreen (bool mode);
void setBackgroundColor(const Color& color = Color::black());
void spin();
void spinOnce(int time = 1, bool force_redraw = false);
bool wasStopped() const;
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void setRenderingProperty(const String &id, int property, double value);
double getRenderingProperty(const String &id, int property);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void setDesiredUpdateRate(double rate);
double getDesiredUpdateRate();
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
void setRepresentation(int representation);
2013-09-02 02:12:31 +08:00
private:
/* hidden */
};
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::Viz3d
-----------------
2013-09-02 01:34:17 +08:00
The constructors.
.. ocv:function:: Viz3d::Viz3d(const String& window_name = String())
2013-09-02 02:12:31 +08:00
:param window_name: Name of the window.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::showWidget
----------------------
2013-09-02 01:34:17 +08:00
Shows a widget in the window.
.. ocv:function:: void Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity())
2013-09-02 02:12:31 +08:00
:param id: A unique id for the widget.
2013-09-08 20:26:58 +08:00
:param widget: The widget to be displayed in the window.
2013-09-02 02:12:31 +08:00
:param pose: Pose of the widget.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::removeWidget
------------------------
2013-09-02 01:34:17 +08:00
Removes a widget from the window.
.. ocv:function:: void removeWidget(const String &id)
2013-09-02 02:12:31 +08:00
:param id: The id of the widget that will be removed.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getWidget
---------------------
2013-09-02 01:34:17 +08:00
Retrieves a widget from the window. A widget is implicitly shared;
2013-09-18 19:50:55 +08:00
that is, if the returned widget is modified, the changes will be
2013-09-02 01:34:17 +08:00
immediately visible in the window.
.. ocv:function:: Widget getWidget(const String &id) const
2013-09-02 02:12:31 +08:00
:param id: The id of the widget that will be returned.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::removeAllWidgets
----------------------------
2013-09-02 01:34:17 +08:00
Removes all widgets from the window.
.. ocv:function:: void removeAllWidgets()
2013-09-08 20:26:58 +08:00
viz::Viz3d::setWidgetPose
-------------------------
2013-09-02 01:34:17 +08:00
Sets pose of a widget in the window.
.. ocv:function:: void setWidgetPose(const String &id, const Affine3f &pose)
2013-09-02 02:12:31 +08:00
:param id: The id of the widget whose pose will be set.
:param pose: The new pose of the widget.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::updateWidgetPose
----------------------------
2013-09-02 01:34:17 +08:00
Updates pose of a widget in the window by pre-multiplying its current pose.
.. ocv:function:: void updateWidgetPose(const String &id, const Affine3f &pose)
2013-09-02 02:12:31 +08:00
: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.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getWidgetPose
-------------------------
2013-09-02 01:34:17 +08:00
Returns the current pose of a widget in the window.
.. ocv:function:: Affine3f getWidgetPose(const String &id) const
2013-09-02 02:12:31 +08:00
:param id: The id of the widget whose pose will be returned.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::setCamera
---------------------
2013-09-02 01:34:17 +08:00
Sets the intrinsic parameters of the viewer using Camera.
.. ocv:function:: void setCamera(const Camera &camera)
2013-09-02 02:12:31 +08:00
:param camera: Camera object wrapping intrinsinc parameters.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getCamera
---------------------
2013-09-02 01:34:17 +08:00
Returns a camera object that contains intrinsic parameters of the current viewer.
.. ocv:function:: Camera getCamera() const
2013-09-08 20:26:58 +08:00
viz::Viz3d::getViewerPose
-------------------------
2013-09-02 01:34:17 +08:00
Returns the current pose of the viewer.
..ocv:function:: Affine3f getViewerPose()
2013-09-08 20:26:58 +08:00
viz::Viz3d::setViewerPose
-------------------------
2013-09-02 01:34:17 +08:00
Sets pose of the viewer.
.. ocv:function:: void setViewerPose(const Affine3f &pose)
2013-09-02 02:12:31 +08:00
:param pose: The new pose of the viewer.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::resetCameraViewpoint
--------------------------------
2013-09-02 01:34:17 +08:00
Resets camera viewpoint to a 3D widget in the scene.
.. ocv:function:: void resetCameraViewpoint (const String &id)
2013-09-02 02:12:31 +08:00
:param pose: Id of a 3D widget.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::resetCamera
-----------------------
2013-09-02 01:34:17 +08:00
Resets camera.
.. ocv:function:: void resetCamera()
2013-09-08 20:26:58 +08:00
viz::Viz3d::convertToWindowCoordinates
--------------------------------------
2013-09-02 01:34:17 +08:00
Transforms a point in world coordinate system to window coordinate system.
.. ocv:function:: void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord)
2013-09-02 02:12:31 +08:00
:param pt: Point in world coordinate system.
:param window_coord: Output point in window coordinate system.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::converTo3DRay
-------------------------
2013-09-02 01:34:17 +08:00
Transforms a point in window coordinate system to a 3D ray in world coordinate system.
.. ocv:function:: void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction)
2013-09-02 02:12:31 +08:00
:param window_coord: Point in window coordinate system.
:param origin: Output origin of the ray.
:param direction: Output direction of the ray.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getWindowSize
-------------------------
2013-09-02 01:34:17 +08:00
Returns the current size of the window.
.. ocv:function:: Size getWindowSize() const
2013-09-08 20:26:58 +08:00
viz::Viz3d::setWindowSize
-------------------------
2013-09-02 01:34:17 +08:00
Sets the size of the window.
.. ocv:function:: void setWindowSize(const Size &window_size)
2013-09-02 02:12:31 +08:00
:param window_size: New size of the window.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getWindowName
-------------------------
2013-09-02 01:34:17 +08:00
Returns the name of the window which has been set in the constructor.
.. ocv:function:: String getWindowName() const
2013-09-08 20:26:58 +08:00
viz::Viz3d::saveScreenshot
--------------------------
2013-09-02 01:34:17 +08:00
Saves screenshot of the current scene.
.. ocv:function:: void saveScreenshot(const String &file)
2013-09-02 02:12:31 +08:00
:param file: Name of the file.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::setWindowPosition
-----------------------------
2013-09-02 01:34:17 +08:00
Sets the position of the window in the screen.
.. ocv:function:: void setWindowPosition(int x, int y)
2013-09-02 02:12:31 +08:00
:param x: x coordinate of the window
:param y: y coordinate of the window
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::setFullScreen
-------------------------
2013-09-02 01:34:17 +08:00
Sets or unsets full-screen rendering mode.
.. ocv:function:: void setFullScreen(bool mode)
2013-09-02 02:12:31 +08:00
:param mode: If true, window will use full-screen mode.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::setBackgroundColor
------------------------------
2013-09-02 01:34:17 +08:00
Sets background color.
.. ocv:function:: void setBackgroundColor(const Color& color = Color::black())
2013-09-08 20:26:58 +08:00
viz::Viz3d::spin
----------------
2013-09-02 01:34:17 +08:00
The window renders and starts the event loop.
.. ocv:function:: void spin()
2013-09-08 20:26:58 +08:00
viz::Viz3d::spinOnce
--------------------
2013-09-02 01:34:17 +08:00
Starts the event loop for a given time.
.. ocv:function:: void spinOnce(int time = 1, bool force_redraw = false)
2013-09-02 02:12:31 +08:00
:param time: Amount of time in milliseconds for the event loop to keep running.
:param force_draw: If true, window renders.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::wasStopped
----------------------
2013-09-02 01:34:17 +08:00
Returns whether the event loop has been stopped.
.. ocv:function:: bool wasStopped()
2013-09-08 20:26:58 +08:00
viz::Viz3d::registerKeyboardCallback
------------------------------------
2013-09-02 01:34:17 +08:00
Sets keyboard handler.
.. ocv:function:: void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0)
2013-09-08 20:26:58 +08:00
:param callback: Keyboard callback ``(void (*KeyboardCallbackFunction(const KeyboardEvent&, void*))``.
2013-09-02 02:12:31 +08:00
:param cookie: The optional parameter passed to the callback.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::registerMouseCallback
---------------------------------
2013-09-02 01:34:17 +08:00
Sets mouse handler.
.. ocv:function:: void registerMouseCallback(MouseCallback callback, void* cookie = 0)
2013-09-08 20:26:58 +08:00
:param callback: Mouse callback ``(void (*MouseCallback)(const MouseEvent&, void*))``.
2013-09-02 02:12:31 +08:00
:param cookie: The optional parameter passed to the callback.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::setRenderingProperty
--------------------------------
2013-09-02 01:34:17 +08:00
Sets rendering property of a widget.
.. ocv:function:: void setRenderingProperty(const String &id, int property, double value)
2013-09-02 02:12:31 +08:00
:param id: Id of the widget.
:param property: Property that will be modified.
:param value: The new value of the property.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
**Rendering property** can be one of the following:
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
* **POINT_SIZE**
* **OPACITY**
* **LINE_WIDTH**
* **FONT_SIZE**
* **REPRESENTATION**: Expected values are
* **REPRESENTATION_POINTS**
* **REPRESENTATION_WIREFRAME**
* **REPRESENTATION_SURFACE**
2013-09-18 19:50:55 +08:00
* **IMMEDIATE_RENDERING**:
2013-09-08 20:26:58 +08:00
* 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**
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getRenderingProperty
--------------------------------
2013-09-02 01:34:17 +08:00
Returns rendering property of a widget.
.. ocv:function:: double getRenderingProperty(const String &id, int property)
2013-09-02 02:12:31 +08:00
:param id: Id of the widget.
:param property: Property.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
**Rendering property** can be one of the following:
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
* **POINT_SIZE**
* **OPACITY**
* **LINE_WIDTH**
* **FONT_SIZE**
* **REPRESENTATION**: Expected values are
* **REPRESENTATION_POINTS**
* **REPRESENTATION_WIREFRAME**
* **REPRESENTATION_SURFACE**
2013-09-18 19:50:55 +08:00
* **IMMEDIATE_RENDERING**:
2013-09-08 20:26:58 +08:00
* Turn on immediate rendering by setting the value to ``1``.
* Turn off immediate rendering by setting the value to ``0``.
* **SHADING**: Expected values are
* **SHADING_FLAT**
* **SHADING_GOURAUD**
* **SHADING_PHONG**
viz::Viz3d::setDesiredUpdateRate
--------------------------------
2013-09-02 01:34:17 +08:00
Sets desired update rate of the window.
.. ocv:function:: void setDesiredUpdateRate(double rate)
2013-09-02 02:12:31 +08:00
:param rate: Desired update rate. The default is 30.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Viz3d::getDesiredUpdateRate
--------------------------------
2013-09-02 01:34:17 +08:00
Returns desired update rate of the window.
.. ocv:function:: double getDesiredUpdateRate()
2013-09-08 20:26:58 +08:00
viz::Viz3d::setRepresentation
-----------------------------
Sets geometry representation of the widgets to surface, wireframe or points.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
.. ocv:function:: void setRepresentation(int representation)
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
:param representation: Geometry representation which can be one of the following:
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
* **REPRESENTATION_POINTS**
* **REPRESENTATION_WIREFRAME**
* **REPRESENTATION_SURFACE**
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Color
----------
2013-09-02 01:34:17 +08:00
.. ocv:class:: Color
This class a represents BGR color. ::
2013-09-02 02:12:31 +08:00
class CV_EXPORTS Color : public Scalar
{
public:
Color();
Color(double gray);
Color(double blue, double green, double red);
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
Color(const Scalar& color);
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
static Color black();
static Color blue();
static Color green();
static Color cyan();
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
static Color red();
static Color magenta();
static Color yellow();
static Color white();
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
static Color gray();
};
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Mesh3d
-----------
2013-09-02 01:34:17 +08:00
.. ocv:class:: Mesh3d
This class wraps mesh attributes, and it can load a mesh from a ``ply`` file. ::
2013-09-02 02:12:31 +08:00
class CV_EXPORTS Mesh3d
{
public:
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
Mat cloud, colors;
Mat polygons;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
//! Loads mesh from a given ply file
static Mesh3d loadMesh(const String& file);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
private:
/* hidden */
};
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Mesh3d::loadMesh
---------------------
2013-09-02 01:34:17 +08:00
Loads a mesh from a ``ply`` file.
.. ocv:function:: static Mesh3d loadMesh(const String& file)
2013-09-02 02:12:31 +08:00
:param file: File name.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::KeyboardEvent
------------------
2013-09-02 01:34:17 +08:00
.. ocv:class:: KeyboardEvent
This class represents a keyboard event. ::
2013-09-02 02:12:31 +08:00
class CV_EXPORTS KeyboardEvent
{
public:
static const unsigned int Alt = 1;
static const unsigned int Ctrl = 2;
static const unsigned int Shift = 4;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
//! Create a keyboard event
//! - Note that action is true if key is pressed, false if released
KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift);
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
bool isAltPressed () const;
bool isCtrlPressed () const;
bool isShiftPressed () const;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
unsigned char getKeyCode () const;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
const String& getKeySym () const;
bool keyDown () const;
bool keyUp () const;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
protected:
/* hidden */
};
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::KeyboardEvent::KeyboardEvent
---------------------------------
2013-09-02 01:34:17 +08:00
Constructs a KeyboardEvent.
.. ocv:function:: KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift)
2013-09-02 02:12:31 +08:00
:param action: If true, key is pressed. If false, key is released.
:param key_sym: Name of the key.
:param key: Code of the key.
:param alt: If true, ``alt`` is pressed.
:param ctrl: If true, ``ctrl`` is pressed.
:param shift: If true, ``shift`` is pressed.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::MouseEvent
---------------
2013-09-02 01:34:17 +08:00
.. ocv:class:: MouseEvent
This class represents a mouse event. ::
2013-09-02 02:12:31 +08:00
class CV_EXPORTS MouseEvent
{
public:
enum Type { MouseMove = 1, MouseButtonPress, MouseButtonRelease, MouseScrollDown, MouseScrollUp, MouseDblClick } ;
enum MouseButton { NoButton = 0, LeftButton, MiddleButton, RightButton, VScroll } ;
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift);
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
Type type;
MouseButton button;
Point pointer;
unsigned int key_state;
};
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::MouseEvent::MouseEvent
---------------------------
2013-09-02 01:34:17 +08:00
Constructs a MouseEvent.
.. ocv:function:: MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift)
2013-09-02 02:12:31 +08:00
: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 p: Position of the event.
:param alt: If true, ``alt`` is pressed.
:param ctrl: If true, ``ctrl`` is pressed.
:param shift: If true, ``shift`` is pressed.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Camera
-----------
2013-09-02 01:34:17 +08:00
.. ocv:class:: Camera
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``. ::
2013-09-02 02:12:31 +08:00
class CV_EXPORTS Camera
{
public:
Camera(float f_x, float f_y, float c_x, float c_y, const Size &window_size);
Camera(const Vec2f &fov, const Size &window_size);
Camera(const cv::Matx33f &K, const Size &window_size);
Camera(const cv::Matx44f &proj, const Size &window_size);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
inline const Vec2d & getClip() const { return clip_; }
inline void setClip(const Vec2d &clip) { clip_ = clip; }
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
inline const Size & getWindowSize() const { return window_size_; }
void setWindowSize(const Size &window_size);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
inline const Vec2f & getFov() const { return fov_; }
inline void setFov(const Vec2f & fov) { fov_ = fov; }
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
inline const Vec2f & getPrincipalPoint() const { return principal_point_; }
inline const Vec2f & getFocalLength() const { return focal_; }
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
void computeProjectionMatrix(Matx44f &proj) const;
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
static Camera KinectCamera(const Size &window_size);
2013-09-18 19:50:55 +08:00
2013-09-02 02:12:31 +08:00
private:
/* hidden */
};
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Camera::Camera
-------------------
2013-09-02 01:34:17 +08:00
Constructs a Camera.
.. ocv:function:: Camera(float f_x, float f_y, float c_x, float c_y, const Size &window_size)
2013-09-02 02:12:31 +08:00
:param f_x: Horizontal focal length.
:param f_y: Vertical focal length.
:param c_x: x coordinate of the principal point.
:param c_y: 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.
2013-09-02 01:34:17 +08:00
.. ocv:function:: Camera(const Vec2f &fov, const Size &window_size)
2013-09-02 02:12:31 +08:00
:param fov: Field of view (horizontal, vertical)
:param window_size: Size of the window.
2013-09-02 01:34:17 +08:00
2013-09-02 02:12:31 +08:00
Principal point is at the center of the window by default.
2013-09-18 19:50:55 +08:00
2013-09-02 01:34:17 +08:00
.. ocv:function:: Camera(const cv::Matx33f &K, const Size &window_size)
2013-09-02 02:12:31 +08:00
:param K: Intrinsic matrix of the camera.
:param window_size: Size of the window. This together with intrinsic matrix determines the field of view.
2013-09-02 01:34:17 +08:00
.. ocv:function:: Camera(const cv::Matx44f &proj, const Size &window_size)
2013-09-02 02:12:31 +08:00
:param proj: Projection matrix of the camera.
:param window_size: Size of the window. This together with projection matrix determines the field of view.
2013-09-02 01:34:17 +08:00
2013-09-08 20:26:58 +08:00
viz::Camera::computeProjectionMatrix
------------------------------------
2013-09-02 01:34:17 +08:00
Computes projection matrix using intrinsic parameters of the camera.
.. ocv:function:: void computeProjectionMatrix(Matx44f &proj) const
2013-09-02 02:12:31 +08:00
:param proj: Output projection matrix.
2013-09-18 19:50:55 +08:00
2013-09-08 20:26:58 +08:00
viz::Camera::KinectCamera
-------------------------
2013-09-02 01:34:17 +08:00
Creates a Kinect Camera.
.. ocv:function:: static Camera KinectCamera(const Size &window_size)
2013-09-02 02:12:31 +08:00
:param window_size: Size of the window. This together with intrinsic matrix of a Kinect Camera determines the field of view.