commit
07d55b05b3
25 changed files with 2148 additions and 1823 deletions
After Width: | Height: | Size: 7.3 KiB |
@ -0,0 +1,118 @@ |
|||||||
|
.. _viz: |
||||||
|
|
||||||
|
Launching Viz |
||||||
|
************* |
||||||
|
|
||||||
|
Goal |
||||||
|
==== |
||||||
|
|
||||||
|
In this tutorial you will learn how to |
||||||
|
|
||||||
|
.. container:: enumeratevisibleitemswithsquare |
||||||
|
|
||||||
|
* Open a visualization window. |
||||||
|
* Access a window by its name. |
||||||
|
* Start event loop. |
||||||
|
* Start event loop for a given amount of time. |
||||||
|
|
||||||
|
Code |
||||||
|
==== |
||||||
|
|
||||||
|
You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/launching_viz.cpp>`_. |
||||||
|
|
||||||
|
.. code-block:: cpp |
||||||
|
|
||||||
|
#include <opencv2/viz.hpp> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
/** |
||||||
|
* @function main |
||||||
|
*/ |
||||||
|
int main() |
||||||
|
{ |
||||||
|
/// Create a window |
||||||
|
viz::Viz3d myWindow("Viz Demo"); |
||||||
|
|
||||||
|
/// Start event loop |
||||||
|
myWindow.spin(); |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E |
||||||
|
cout << "First event loop is over" << endl; |
||||||
|
|
||||||
|
/// Access window via its name |
||||||
|
viz::Viz3d sameWindow = viz::get("Viz Demo"); |
||||||
|
|
||||||
|
/// Start event loop |
||||||
|
sameWindow.spin(); |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E |
||||||
|
cout << "Second event loop is over" << endl; |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E |
||||||
|
/// Start event loop once for 1 millisecond |
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
while(!sameWindow.wasStopped()) |
||||||
|
{ |
||||||
|
/// Interact with window |
||||||
|
|
||||||
|
/// Event loop for 1 millisecond |
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
} |
||||||
|
|
||||||
|
/// Once more event loop is stopped |
||||||
|
cout << "Last event loop is over" << endl; |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
Explanation |
||||||
|
=========== |
||||||
|
|
||||||
|
Here is the general structure of the program: |
||||||
|
|
||||||
|
* Create a window. |
||||||
|
|
||||||
|
.. code-block:: cpp |
||||||
|
|
||||||
|
/// Create a window |
||||||
|
viz::Viz3d myWindow("Viz Demo"); |
||||||
|
|
||||||
|
* Start event loop. This event loop will run until user terminates it by pressing **e**, **E**, **q**, **Q**. |
||||||
|
|
||||||
|
.. code-block:: cpp |
||||||
|
|
||||||
|
/// Start event loop |
||||||
|
myWindow.spin(); |
||||||
|
|
||||||
|
* Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly the same with **myWindow**. If the name does not exist, a new window is created. |
||||||
|
|
||||||
|
.. code-block:: cpp |
||||||
|
|
||||||
|
/// Access window via its name |
||||||
|
viz::Viz3d sameWindow = viz::get("Viz Demo"); |
||||||
|
|
||||||
|
* Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping. Inside the while loop, user can execute other statements including those which interact with the window. |
||||||
|
|
||||||
|
.. code-block:: cpp |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E |
||||||
|
/// Start event loop once for 1 millisecond |
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
while(!sameWindow.wasStopped()) |
||||||
|
{ |
||||||
|
/// Interact with window |
||||||
|
|
||||||
|
/// Event loop for 1 millisecond |
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
} |
||||||
|
|
||||||
|
Results |
||||||
|
======= |
||||||
|
|
||||||
|
Here is the result of the program. |
||||||
|
|
||||||
|
.. image:: images/window_demo.png |
||||||
|
:alt: Launching Viz |
||||||
|
:align: center |
@ -0,0 +1,9 @@ |
|||||||
|
*********************** |
||||||
|
viz. 3D Visualizer |
||||||
|
*********************** |
||||||
|
|
||||||
|
.. toctree:: |
||||||
|
:maxdepth: 2 |
||||||
|
|
||||||
|
viz3d.rst |
||||||
|
widget.rst |
@ -0,0 +1,556 @@ |
|||||||
|
Viz3d |
||||||
|
===== |
||||||
|
|
||||||
|
.. highlight:: cpp |
||||||
|
|
||||||
|
Viz3d |
||||||
|
----- |
||||||
|
.. ocv:class:: Viz3d |
||||||
|
|
||||||
|
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; |
||||||
|
|
||||||
|
void setCamera(const Camera &camera); |
||||||
|
Camera getCamera() const; |
||||||
|
Affine3f getViewerPose(); |
||||||
|
void setViewerPose(const Affine3f &pose); |
||||||
|
|
||||||
|
void resetCameraViewpoint (const String &id); |
||||||
|
void resetCamera(); |
||||||
|
|
||||||
|
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord); |
||||||
|
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction); |
||||||
|
|
||||||
|
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); |
||||||
|
|
||||||
|
void setRenderingProperty(const String &id, int property, double value); |
||||||
|
double getRenderingProperty(const String &id, int property); |
||||||
|
|
||||||
|
void setDesiredUpdateRate(double rate); |
||||||
|
double getDesiredUpdateRate(); |
||||||
|
|
||||||
|
void setRepresentationToSurface(); |
||||||
|
void setRepresentationToWireframe(); |
||||||
|
void setRepresentationToPoints(); |
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
Viz3d::Viz3d |
||||||
|
------------ |
||||||
|
The constructors. |
||||||
|
|
||||||
|
.. ocv:function:: Viz3d::Viz3d(const String& window_name = String()) |
||||||
|
|
||||||
|
:param window_name: Name of the window. |
||||||
|
|
||||||
|
Viz3d::showWidget |
||||||
|
----------------- |
||||||
|
Shows a widget in the window. |
||||||
|
|
||||||
|
.. ocv:function:: void Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity()) |
||||||
|
|
||||||
|
:param id: A unique id for the widget. |
||||||
|
:param widget: The widget to be rendered in the window. |
||||||
|
:param pose: Pose of the widget. |
||||||
|
|
||||||
|
Viz3d::removeWidget |
||||||
|
------------------- |
||||||
|
Removes a widget from the window. |
||||||
|
|
||||||
|
.. ocv:function:: void removeWidget(const String &id) |
||||||
|
|
||||||
|
:param id: The id of the widget that will be removed. |
||||||
|
|
||||||
|
Viz3d::getWidget |
||||||
|
---------------- |
||||||
|
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. |
||||||
|
|
||||||
|
.. ocv:function:: Widget getWidget(const String &id) const |
||||||
|
|
||||||
|
:param id: The id of the widget that will be returned. |
||||||
|
|
||||||
|
Viz3d::removeAllWidgets |
||||||
|
----------------------- |
||||||
|
Removes all widgets from the window. |
||||||
|
|
||||||
|
.. ocv:function:: void removeAllWidgets() |
||||||
|
|
||||||
|
Viz3d::setWidgetPose |
||||||
|
-------------------- |
||||||
|
Sets pose of a widget in the window. |
||||||
|
|
||||||
|
.. ocv:function:: void setWidgetPose(const String &id, const Affine3f &pose) |
||||||
|
|
||||||
|
:param id: The id of the widget whose pose will be set. |
||||||
|
:param pose: The new pose of the widget. |
||||||
|
|
||||||
|
Viz3d::updateWidgetPose |
||||||
|
----------------------- |
||||||
|
Updates pose of a widget in the window by pre-multiplying its current pose. |
||||||
|
|
||||||
|
.. ocv:function:: void updateWidgetPose(const String &id, const Affine3f &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. |
||||||
|
|
||||||
|
Viz3d::getWidgetPose |
||||||
|
-------------------- |
||||||
|
Returns the current pose of a widget in the window. |
||||||
|
|
||||||
|
.. ocv:function:: Affine3f getWidgetPose(const String &id) const |
||||||
|
|
||||||
|
:param id: The id of the widget whose pose will be returned. |
||||||
|
|
||||||
|
Viz3d::setCamera |
||||||
|
---------------- |
||||||
|
Sets the intrinsic parameters of the viewer using Camera. |
||||||
|
|
||||||
|
.. ocv:function:: void setCamera(const Camera &camera) |
||||||
|
|
||||||
|
:param camera: Camera object wrapping intrinsinc parameters. |
||||||
|
|
||||||
|
Viz3d::getCamera |
||||||
|
---------------- |
||||||
|
Returns a camera object that contains intrinsic parameters of the current viewer. |
||||||
|
|
||||||
|
.. ocv:function:: Camera getCamera() const |
||||||
|
|
||||||
|
Viz3d::getViewerPose |
||||||
|
-------------------- |
||||||
|
Returns the current pose of the viewer. |
||||||
|
|
||||||
|
..ocv:function:: Affine3f getViewerPose() |
||||||
|
|
||||||
|
Viz3d::setViewerPose |
||||||
|
-------------------- |
||||||
|
Sets pose of the viewer. |
||||||
|
|
||||||
|
.. ocv:function:: void setViewerPose(const Affine3f &pose) |
||||||
|
|
||||||
|
:param pose: The new pose of the viewer. |
||||||
|
|
||||||
|
Viz3d::resetCameraViewpoint |
||||||
|
--------------------------- |
||||||
|
Resets camera viewpoint to a 3D widget in the scene. |
||||||
|
|
||||||
|
.. ocv:function:: void resetCameraViewpoint (const String &id) |
||||||
|
|
||||||
|
:param pose: Id of a 3D widget. |
||||||
|
|
||||||
|
Viz3d::resetCamera |
||||||
|
------------------ |
||||||
|
Resets camera. |
||||||
|
|
||||||
|
.. ocv:function:: void resetCamera() |
||||||
|
|
||||||
|
Viz3d::convertToWindowCoordinates |
||||||
|
--------------------------------- |
||||||
|
Transforms a point in world coordinate system to window coordinate system. |
||||||
|
|
||||||
|
.. ocv:function:: void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord) |
||||||
|
|
||||||
|
:param pt: Point in world coordinate system. |
||||||
|
:param window_coord: Output point in window coordinate system. |
||||||
|
|
||||||
|
Viz3d::converTo3DRay |
||||||
|
-------------------- |
||||||
|
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) |
||||||
|
|
||||||
|
:param window_coord: Point in window coordinate system. |
||||||
|
:param origin: Output origin of the ray. |
||||||
|
:param direction: Output direction of the ray. |
||||||
|
|
||||||
|
Viz3d::getWindowSize |
||||||
|
-------------------- |
||||||
|
Returns the current size of the window. |
||||||
|
|
||||||
|
.. ocv:function:: Size getWindowSize() const |
||||||
|
|
||||||
|
Viz3d::setWindowSize |
||||||
|
-------------------- |
||||||
|
Sets the size of the window. |
||||||
|
|
||||||
|
.. ocv:function:: void setWindowSize(const Size &window_size) |
||||||
|
|
||||||
|
:param window_size: New size of the window. |
||||||
|
|
||||||
|
Viz3d::getWindowName |
||||||
|
-------------------- |
||||||
|
Returns the name of the window which has been set in the constructor. |
||||||
|
|
||||||
|
.. ocv:function:: String getWindowName() const |
||||||
|
|
||||||
|
Viz3d::saveScreenshot |
||||||
|
--------------------- |
||||||
|
Saves screenshot of the current scene. |
||||||
|
|
||||||
|
.. ocv:function:: void saveScreenshot(const String &file) |
||||||
|
|
||||||
|
:param file: Name of the file. |
||||||
|
|
||||||
|
Viz3d::setWindowPosition |
||||||
|
------------------------ |
||||||
|
Sets the position of the window in the screen. |
||||||
|
|
||||||
|
.. ocv:function:: void setWindowPosition(int x, int y) |
||||||
|
|
||||||
|
:param x: x coordinate of the window |
||||||
|
:param y: y coordinate of the window |
||||||
|
|
||||||
|
Viz3d::setFullScreen |
||||||
|
-------------------- |
||||||
|
Sets or unsets full-screen rendering mode. |
||||||
|
|
||||||
|
.. ocv:function:: void setFullScreen(bool mode) |
||||||
|
|
||||||
|
:param mode: If true, window will use full-screen mode. |
||||||
|
|
||||||
|
Viz3d::setBackgroundColor |
||||||
|
------------------------- |
||||||
|
Sets background color. |
||||||
|
|
||||||
|
.. ocv:function:: void setBackgroundColor(const Color& color = Color::black()) |
||||||
|
|
||||||
|
Viz3d::spin |
||||||
|
----------- |
||||||
|
The window renders and starts the event loop. |
||||||
|
|
||||||
|
.. ocv:function:: void spin() |
||||||
|
|
||||||
|
Viz3d::spinOnce |
||||||
|
--------------- |
||||||
|
Starts the event loop for a given time. |
||||||
|
|
||||||
|
.. ocv:function:: void spinOnce(int time = 1, bool force_redraw = false) |
||||||
|
|
||||||
|
:param time: Amount of time in milliseconds for the event loop to keep running. |
||||||
|
:param force_draw: If true, window renders. |
||||||
|
|
||||||
|
Viz3d::wasStopped |
||||||
|
----------------- |
||||||
|
Returns whether the event loop has been stopped. |
||||||
|
|
||||||
|
.. ocv:function:: bool wasStopped() |
||||||
|
|
||||||
|
Viz3d::registerKeyboardCallback |
||||||
|
------------------------------- |
||||||
|
Sets keyboard handler. |
||||||
|
|
||||||
|
.. ocv:function:: void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0) |
||||||
|
|
||||||
|
:param callback: Keyboard callback. |
||||||
|
:param cookie: The optional parameter passed to the callback. |
||||||
|
|
||||||
|
Viz3d::registerMouseCallback |
||||||
|
---------------------------- |
||||||
|
Sets mouse handler. |
||||||
|
|
||||||
|
.. ocv:function:: void registerMouseCallback(MouseCallback callback, void* cookie = 0) |
||||||
|
|
||||||
|
:param callback: Mouse callback. |
||||||
|
:param cookie: The optional parameter passed to the callback. |
||||||
|
|
||||||
|
Viz3d::setRenderingProperty |
||||||
|
--------------------------- |
||||||
|
Sets rendering property of a widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setRenderingProperty(const String &id, int property, double value) |
||||||
|
|
||||||
|
:param id: Id of the widget. |
||||||
|
:param property: Property that will be modified. |
||||||
|
:param value: The new value of the property. |
||||||
|
|
||||||
|
Viz3d::getRenderingProperty |
||||||
|
--------------------------- |
||||||
|
Returns rendering property of a widget. |
||||||
|
|
||||||
|
.. ocv:function:: double getRenderingProperty(const String &id, int property) |
||||||
|
|
||||||
|
:param id: Id of the widget. |
||||||
|
:param property: Property. |
||||||
|
|
||||||
|
Viz3d::setDesiredUpdateRate |
||||||
|
--------------------------- |
||||||
|
Sets desired update rate of the window. |
||||||
|
|
||||||
|
.. ocv:function:: void setDesiredUpdateRate(double rate) |
||||||
|
|
||||||
|
:param rate: Desired update rate. The default is 30. |
||||||
|
|
||||||
|
Viz3d::getDesiredUpdateRate |
||||||
|
--------------------------- |
||||||
|
Returns desired update rate of the window. |
||||||
|
|
||||||
|
.. ocv:function:: double getDesiredUpdateRate() |
||||||
|
|
||||||
|
Viz3d::setRepresentationToSurface |
||||||
|
--------------------------------- |
||||||
|
Sets geometry representation of the widgets to surface. |
||||||
|
|
||||||
|
.. ocv:function:: void setRepresentationToSurface() |
||||||
|
|
||||||
|
Viz3d::setRepresentationToWireframe |
||||||
|
----------------------------------- |
||||||
|
Sets geometry representation of the widgets to wireframe. |
||||||
|
|
||||||
|
.. ocv:function:: void setRepresentationToWireframe() |
||||||
|
|
||||||
|
Viz3d::setRepresentationToPoints |
||||||
|
-------------------------------- |
||||||
|
Sets geometry representation of the widgets to points. |
||||||
|
|
||||||
|
.. ocv:function:: void setRepresentationToPoints() |
||||||
|
|
||||||
|
Color |
||||||
|
----- |
||||||
|
.. ocv:class:: Color |
||||||
|
|
||||||
|
This class a represents BGR color. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Color : public Scalar |
||||||
|
{ |
||||||
|
public: |
||||||
|
Color(); |
||||||
|
Color(double gray); |
||||||
|
Color(double blue, double green, double red); |
||||||
|
|
||||||
|
Color(const Scalar& color); |
||||||
|
|
||||||
|
static Color black(); |
||||||
|
static Color blue(); |
||||||
|
static Color green(); |
||||||
|
static Color cyan(); |
||||||
|
|
||||||
|
static Color red(); |
||||||
|
static Color magenta(); |
||||||
|
static Color yellow(); |
||||||
|
static Color white(); |
||||||
|
|
||||||
|
static Color gray(); |
||||||
|
}; |
||||||
|
|
||||||
|
Mesh3d |
||||||
|
------ |
||||||
|
.. ocv:class:: Mesh3d |
||||||
|
|
||||||
|
This class wraps mesh attributes, and it can load a mesh from a ``ply`` file. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Mesh3d |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
Mat cloud, colors; |
||||||
|
Mat polygons; |
||||||
|
|
||||||
|
//! Loads mesh from a given ply file |
||||||
|
static Mesh3d loadMesh(const String& file); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
Mesh3d::loadMesh |
||||||
|
---------------- |
||||||
|
Loads a mesh from a ``ply`` file. |
||||||
|
|
||||||
|
.. ocv:function:: static Mesh3d loadMesh(const String& file) |
||||||
|
|
||||||
|
:param file: File name. |
||||||
|
|
||||||
|
|
||||||
|
KeyboardEvent |
||||||
|
------------- |
||||||
|
.. ocv:class:: KeyboardEvent |
||||||
|
|
||||||
|
This class represents a keyboard event. :: |
||||||
|
|
||||||
|
class CV_EXPORTS KeyboardEvent |
||||||
|
{ |
||||||
|
public: |
||||||
|
static const unsigned int Alt = 1; |
||||||
|
static const unsigned int Ctrl = 2; |
||||||
|
static const unsigned int Shift = 4; |
||||||
|
|
||||||
|
//! 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); |
||||||
|
|
||||||
|
bool isAltPressed () const; |
||||||
|
bool isCtrlPressed () const; |
||||||
|
bool isShiftPressed () const; |
||||||
|
|
||||||
|
unsigned char getKeyCode () const; |
||||||
|
|
||||||
|
const String& getKeySym () const; |
||||||
|
bool keyDown () const; |
||||||
|
bool keyUp () const; |
||||||
|
|
||||||
|
protected: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
KeyboardEvent::KeyboardEvent |
||||||
|
---------------------------- |
||||||
|
Constructs a KeyboardEvent. |
||||||
|
|
||||||
|
.. ocv:function:: KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
MouseEvent |
||||||
|
---------- |
||||||
|
.. ocv:class:: MouseEvent |
||||||
|
|
||||||
|
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 } ; |
||||||
|
|
||||||
|
MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift); |
||||||
|
|
||||||
|
Type type; |
||||||
|
MouseButton button; |
||||||
|
Point pointer; |
||||||
|
unsigned int key_state; |
||||||
|
}; |
||||||
|
|
||||||
|
MouseEvent::MouseEvent |
||||||
|
---------------------- |
||||||
|
Constructs a MouseEvent. |
||||||
|
|
||||||
|
.. ocv:function:: MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
Camera |
||||||
|
------ |
||||||
|
.. 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``. :: |
||||||
|
|
||||||
|
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); |
||||||
|
|
||||||
|
inline const Vec2d & getClip() const { return clip_; } |
||||||
|
inline void setClip(const Vec2d &clip) { clip_ = clip; } |
||||||
|
|
||||||
|
inline const Size & getWindowSize() const { return window_size_; } |
||||||
|
void setWindowSize(const Size &window_size); |
||||||
|
|
||||||
|
inline const Vec2f & getFov() const { return fov_; } |
||||||
|
inline void setFov(const Vec2f & fov) { fov_ = fov; } |
||||||
|
|
||||||
|
inline const Vec2f & getPrincipalPoint() const { return principal_point_; } |
||||||
|
inline const Vec2f & getFocalLength() const { return focal_; } |
||||||
|
|
||||||
|
void computeProjectionMatrix(Matx44f &proj) const; |
||||||
|
|
||||||
|
static Camera KinectCamera(const Size &window_size); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
Camera::Camera |
||||||
|
-------------- |
||||||
|
Constructs a Camera. |
||||||
|
|
||||||
|
.. ocv:function:: Camera(float f_x, float f_y, float c_x, float c_y, const Size &window_size) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
.. ocv:function:: Camera(const Vec2f &fov, const Size &window_size) |
||||||
|
|
||||||
|
:param fov: Field of view (horizontal, vertical) |
||||||
|
:param window_size: Size of the window. |
||||||
|
|
||||||
|
Principal point is at the center of the window by default. |
||||||
|
|
||||||
|
.. ocv:function:: Camera(const cv::Matx33f &K, const Size &window_size) |
||||||
|
|
||||||
|
:param K: Intrinsic matrix of the camera. |
||||||
|
:param window_size: Size of the window. This together with intrinsic matrix determines the field of view. |
||||||
|
|
||||||
|
.. ocv:function:: Camera(const cv::Matx44f &proj, const Size &window_size) |
||||||
|
|
||||||
|
:param proj: Projection matrix of the camera. |
||||||
|
:param window_size: Size of the window. This together with projection matrix determines the field of view. |
||||||
|
|
||||||
|
Camera::computeProjectionMatrix |
||||||
|
------------------------------- |
||||||
|
Computes projection matrix using intrinsic parameters of the camera. |
||||||
|
|
||||||
|
.. ocv:function:: void computeProjectionMatrix(Matx44f &proj) const |
||||||
|
|
||||||
|
:param proj: Output projection matrix. |
||||||
|
|
||||||
|
Camera::KinectCamera |
||||||
|
-------------------- |
||||||
|
Creates a Kinect Camera. |
||||||
|
|
||||||
|
.. ocv:function:: static Camera KinectCamera(const Size &window_size) |
||||||
|
|
||||||
|
:param window_size: Size of the window. This together with intrinsic matrix of a Kinect Camera determines the field of view. |
||||||
|
|
@ -0,0 +1,823 @@ |
|||||||
|
Widget |
||||||
|
====== |
||||||
|
|
||||||
|
.. highlight:: cpp |
||||||
|
|
||||||
|
In this section, the built-in widgets are presented. |
||||||
|
|
||||||
|
Widget |
||||||
|
------ |
||||||
|
.. ocv:class:: Widget |
||||||
|
|
||||||
|
Base class of all widgets. Widget is implicitly shared.:: |
||||||
|
|
||||||
|
class CV_EXPORTS Widget |
||||||
|
{ |
||||||
|
public: |
||||||
|
Widget(); |
||||||
|
Widget(const Widget& other); |
||||||
|
Widget& operator=(const Widget& other); |
||||||
|
~Widget(); |
||||||
|
|
||||||
|
//! Create a widget directly from ply file |
||||||
|
static Widget fromPlyFile(const String &file_name); |
||||||
|
|
||||||
|
//! Rendering properties of this particular widget |
||||||
|
void setRenderingProperty(int property, double value); |
||||||
|
double getRenderingProperty(int property) const; |
||||||
|
|
||||||
|
//! Casting between widgets |
||||||
|
template<typename _W> _W cast(); |
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
Widget::fromPlyFile |
||||||
|
------------------- |
||||||
|
Creates a widget from ply file. |
||||||
|
|
||||||
|
.. ocv:function:: static Widget fromPlyFile(const String &file_name) |
||||||
|
|
||||||
|
:param file_name: Ply file name. |
||||||
|
|
||||||
|
Widget::setRenderingProperty |
||||||
|
---------------------------- |
||||||
|
Sets rendering property of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setRenderingProperty(int property, double value) |
||||||
|
|
||||||
|
:param property: Property that will be modified. |
||||||
|
:param value: The new value of the property. |
||||||
|
|
||||||
|
Widget::getRenderingProperty |
||||||
|
---------------------------- |
||||||
|
Returns rendering property of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: double getRenderingProperty(int property) const |
||||||
|
|
||||||
|
:param property: Property. |
||||||
|
|
||||||
|
Widget::cast |
||||||
|
------------ |
||||||
|
Casts a widget to another. |
||||||
|
|
||||||
|
.. ocv:function:: template<typename _W> _W cast() |
||||||
|
|
||||||
|
WidgetAccessor |
||||||
|
-------------- |
||||||
|
.. ocv:class:: WidgetAccessor |
||||||
|
|
||||||
|
This class is for users who want to develop their own widgets using VTK library API. :: |
||||||
|
|
||||||
|
struct CV_EXPORTS WidgetAccessor |
||||||
|
{ |
||||||
|
static vtkSmartPointer<vtkProp> getProp(const Widget &widget); |
||||||
|
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop); |
||||||
|
}; |
||||||
|
|
||||||
|
Widget3D |
||||||
|
-------- |
||||||
|
.. ocv:class:: Widget3D |
||||||
|
|
||||||
|
Base class of all 3D widgets. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Widget3D : public Widget |
||||||
|
{ |
||||||
|
public: |
||||||
|
Widget3D() {} |
||||||
|
|
||||||
|
void setPose(const Affine3f &pose); |
||||||
|
void updatePose(const Affine3f &pose); |
||||||
|
Affine3f getPose() const; |
||||||
|
|
||||||
|
void setColor(const Color &color); |
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
Widget3D::setPose |
||||||
|
----------------- |
||||||
|
Sets pose of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setPose(const Affine3f &pose) |
||||||
|
|
||||||
|
:param pose: The new pose of the widget. |
||||||
|
|
||||||
|
Widget3D::updateWidgetPose |
||||||
|
-------------------------- |
||||||
|
Updates pose of the widget by pre-multiplying its current pose. |
||||||
|
|
||||||
|
.. ocv:function:: void updateWidgetPose(const Affine3f &pose) |
||||||
|
|
||||||
|
:param pose: The pose that the current pose of the widget will be pre-multiplied by. |
||||||
|
|
||||||
|
Widget3D::getPose |
||||||
|
----------------- |
||||||
|
Returns the current pose of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: Affine3f getWidgetPose() const |
||||||
|
|
||||||
|
Widget3D::setColor |
||||||
|
------------------ |
||||||
|
Sets the color of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setColor(const Color &color) |
||||||
|
|
||||||
|
:param color: Color |
||||||
|
|
||||||
|
Widget2D |
||||||
|
-------- |
||||||
|
.. ocv:class:: Widget2D |
||||||
|
|
||||||
|
Base class of all 2D widgets. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Widget2D : public Widget |
||||||
|
{ |
||||||
|
public: |
||||||
|
Widget2D() {} |
||||||
|
|
||||||
|
void setColor(const Color &color); |
||||||
|
}; |
||||||
|
|
||||||
|
Widget2D::setColor |
||||||
|
------------------ |
||||||
|
Sets the color of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setColor(const Color &color) |
||||||
|
|
||||||
|
:param color: Color |
||||||
|
|
||||||
|
LineWidget |
||||||
|
---------- |
||||||
|
.. ocv:class:: LineWidget |
||||||
|
|
||||||
|
This 3D Widget defines a finite line. :: |
||||||
|
|
||||||
|
class CV_EXPORTS LineWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
LineWidget::LineWidget |
||||||
|
---------------------- |
||||||
|
Constructs a LineWidget. |
||||||
|
|
||||||
|
.. ocv:function:: LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param pt1: Start point of the line. |
||||||
|
:param pt2: End point of the line. |
||||||
|
:param color: Color of the line. |
||||||
|
|
||||||
|
PlaneWidget |
||||||
|
----------- |
||||||
|
.. ocv:class:: PlaneWidget |
||||||
|
|
||||||
|
This 3D Widget defines a finite plane. :: |
||||||
|
|
||||||
|
class CV_EXPORTS PlaneWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()); |
||||||
|
PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()); |
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
PlaneWidget::PlaneWidget |
||||||
|
------------------------ |
||||||
|
Constructs a PlaneWidget. |
||||||
|
|
||||||
|
.. ocv:function:: PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. |
||||||
|
:param size: Size of the plane. |
||||||
|
:param color: Color of the plane. |
||||||
|
|
||||||
|
.. ocv:function:: PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. |
||||||
|
:param pt: Position of the plane. |
||||||
|
:param color: Color of the plane. |
||||||
|
|
||||||
|
SphereWidget |
||||||
|
------------ |
||||||
|
.. ocv:class:: SphereWidget |
||||||
|
|
||||||
|
This 3D Widget defines a sphere. :: |
||||||
|
|
||||||
|
class CV_EXPORTS SphereWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) |
||||||
|
}; |
||||||
|
|
||||||
|
SphereWidget::SphereWidget |
||||||
|
-------------------------- |
||||||
|
Constructs a SphereWidget. |
||||||
|
|
||||||
|
.. ocv:function:: SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
ArrowWidget |
||||||
|
----------- |
||||||
|
.. ocv:class:: ArrowWidget |
||||||
|
|
||||||
|
This 3D Widget defines an arrow. :: |
||||||
|
|
||||||
|
class CV_EXPORTS ArrowWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
ArrowWidget::ArrowWidget |
||||||
|
------------------------ |
||||||
|
Constructs an ArrowWidget. |
||||||
|
|
||||||
|
.. ocv:function:: ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
CircleWidget |
||||||
|
------------ |
||||||
|
.. ocv:class:: CircleWidget |
||||||
|
|
||||||
|
This 3D Widget defines a circle. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CircleWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
CircleWidget::CircleWidget |
||||||
|
-------------------------- |
||||||
|
Constructs a CircleWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param pt: Center of the circle. |
||||||
|
:param radius: Radius of the circle. |
||||||
|
:param thickness: Thickness of the circle. |
||||||
|
:param color: Color of the circle. |
||||||
|
|
||||||
|
CylinderWidget |
||||||
|
-------------- |
||||||
|
.. ocv:class:: CylinderWidget |
||||||
|
|
||||||
|
This 3D Widget defines a cylinder. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CylinderWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
CylinderWidget::CylinderWidget |
||||||
|
------------------------------ |
||||||
|
Constructs a CylinderWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param pt_on_axis: A point on the axis of the cylinder. |
||||||
|
:param axis_direction: Direction of the axis of the cylinder. |
||||||
|
:param radius: Radius of the cylinder. |
||||||
|
:param numsides: Resolution of the cylinder. |
||||||
|
:param color: Color of the cylinder. |
||||||
|
|
||||||
|
CubeWidget |
||||||
|
---------- |
||||||
|
.. ocv:class:: CubeWidget |
||||||
|
|
||||||
|
This 3D Widget defines a cube. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CubeWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
CubeWidget::CubeWidget |
||||||
|
---------------------- |
||||||
|
Constructs a CudeWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param pt_min: Specifies minimum point of the bounding box. |
||||||
|
:param pt_max: Specifies maximum point of the bounding box. |
||||||
|
:param wire_frame: If true, cube is represented as wireframe. |
||||||
|
:param color: Color of the cube. |
||||||
|
|
||||||
|
CoordinateSystemWidget |
||||||
|
---------------------- |
||||||
|
.. ocv:class:: CoordinateSystemWidget |
||||||
|
|
||||||
|
This 3D Widget represents a coordinate system. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CoordinateSystemWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CoordinateSystemWidget(double scale = 1.0); |
||||||
|
}; |
||||||
|
|
||||||
|
CoordinateSystemWidget::CoordinateSystemWidget |
||||||
|
---------------------------------------------- |
||||||
|
Constructs a CoordinateSystemWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CoordinateSystemWidget(double scale = 1.0) |
||||||
|
|
||||||
|
:param scale: Determines the size of the axes. |
||||||
|
|
||||||
|
PolyLineWidget |
||||||
|
-------------- |
||||||
|
.. ocv:class:: PolyLineWidget |
||||||
|
|
||||||
|
This 3D Widget defines a poly line. :: |
||||||
|
|
||||||
|
class CV_EXPORTS PolyLineWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
PolyLineWidget(InputArray points, const Color &color = Color::white()); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
PolyLineWidget::PolyLineWidget |
||||||
|
------------------------------ |
||||||
|
Constructs a PolyLineWidget. |
||||||
|
|
||||||
|
.. ocv:function:: PolyLineWidget(InputArray points, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param points: Point set. |
||||||
|
:param color: Color of the poly line. |
||||||
|
|
||||||
|
GridWidget |
||||||
|
---------- |
||||||
|
.. ocv:class:: GridWidget |
||||||
|
|
||||||
|
This 3D Widget defines a grid. :: |
||||||
|
|
||||||
|
class CV_EXPORTS GridWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
//! Creates grid at the origin |
||||||
|
GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); |
||||||
|
//! Creates grid based on the plane equation |
||||||
|
GridWidget(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); |
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
GridWidget::GridWidget |
||||||
|
---------------------- |
||||||
|
Constructs a GridWidget. |
||||||
|
|
||||||
|
.. ocv:function:: GridWidget(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param dimensions: Number of columns and rows, respectively. |
||||||
|
:param spacing: Size of each column and row, respectively. |
||||||
|
:param color: Color of the grid. |
||||||
|
|
||||||
|
.. ocv:function: GridWidget(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param coeffs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. |
||||||
|
:param dimensions: Number of columns and rows, respectively. |
||||||
|
:param spacing: Size of each column and row, respectively. |
||||||
|
:param color: Color of the grid. |
||||||
|
|
||||||
|
Text3DWidget |
||||||
|
------------ |
||||||
|
.. ocv:class:: Text3DWidget |
||||||
|
|
||||||
|
This 3D Widget represents 3D text. The text always faces the camera. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Text3DWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, const Color &color = Color::white()); |
||||||
|
|
||||||
|
void setText(const String &text); |
||||||
|
String getText() const; |
||||||
|
}; |
||||||
|
|
||||||
|
Text3DWidget::Text3DWidget |
||||||
|
-------------------------- |
||||||
|
Constructs a Text3DWidget. |
||||||
|
|
||||||
|
.. ocv:function:: Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param text: Text content of the widget. |
||||||
|
:param position: Position of the text. |
||||||
|
:param text_scale: Size of the text. |
||||||
|
:param color: Color of the text. |
||||||
|
|
||||||
|
Text3DWidget::setText |
||||||
|
--------------------- |
||||||
|
Sets the text content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setText(const String &text) |
||||||
|
|
||||||
|
:param text: Text content of the widget. |
||||||
|
|
||||||
|
Text3DWidget::getText |
||||||
|
--------------------- |
||||||
|
Returns the current text content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: String getText() const |
||||||
|
|
||||||
|
TextWidget |
||||||
|
---------- |
||||||
|
.. ocv:class:: TextWidget |
||||||
|
|
||||||
|
This 2D Widget represents text overlay. :: |
||||||
|
|
||||||
|
class CV_EXPORTS TextWidget : public Widget2D |
||||||
|
{ |
||||||
|
public: |
||||||
|
TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()); |
||||||
|
|
||||||
|
void setText(const String &text); |
||||||
|
String getText() const; |
||||||
|
}; |
||||||
|
|
||||||
|
TextWidget::TextWidget |
||||||
|
---------------------- |
||||||
|
Constructs a TextWidget. |
||||||
|
|
||||||
|
.. ocv:function:: TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param text: Text content of the widget. |
||||||
|
:param pos: Position of the text. |
||||||
|
:param font_size: Font size. |
||||||
|
:param color: Color of the text. |
||||||
|
|
||||||
|
TextWidget::setText |
||||||
|
--------------------- |
||||||
|
Sets the text content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setText(const String &text) |
||||||
|
|
||||||
|
:param text: Text content of the widget. |
||||||
|
|
||||||
|
TextWidget::getText |
||||||
|
--------------------- |
||||||
|
Returns the current text content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: String getText() const |
||||||
|
|
||||||
|
ImageOverlayWidget |
||||||
|
------------------ |
||||||
|
.. ocv:class:: ImageOverlayWidget |
||||||
|
|
||||||
|
This 2D Widget represents an image overlay. :: |
||||||
|
|
||||||
|
class CV_EXPORTS ImageOverlayWidget : public Widget2D |
||||||
|
{ |
||||||
|
public: |
||||||
|
ImageOverlayWidget(const Mat &image, const Rect &rect); |
||||||
|
|
||||||
|
void setImage(const Mat &image); |
||||||
|
}; |
||||||
|
|
||||||
|
ImageOverlayWidget::ImageOverlayWidget |
||||||
|
-------------------------------------- |
||||||
|
Constructs a ImageOverlayWidget. |
||||||
|
|
||||||
|
.. ocv:function:: ImageOverlayWidget(const Mat &image, const Rect &rect) |
||||||
|
|
||||||
|
:param image: BGR or Gray-Scale image. |
||||||
|
:param rect: Image is scaled and positioned based on rect. |
||||||
|
|
||||||
|
ImageOverlayWidget::setImage |
||||||
|
---------------------------- |
||||||
|
Sets the image content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setImage(const Mat &image) |
||||||
|
|
||||||
|
:param image: BGR or Gray-Scale image. |
||||||
|
|
||||||
|
Image3DWidget |
||||||
|
------------- |
||||||
|
.. ocv:class:: Image3DWidget |
||||||
|
|
||||||
|
This 3D Widget represents 3D image. :: |
||||||
|
|
||||||
|
class CV_EXPORTS Image3DWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
//! Creates 3D image at the origin |
||||||
|
Image3DWidget(const Mat &image, const Size &size); |
||||||
|
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation |
||||||
|
Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); |
||||||
|
|
||||||
|
void setImage(const Mat &image); |
||||||
|
}; |
||||||
|
|
||||||
|
Image3DWidget::Image3DWidget |
||||||
|
---------------------------- |
||||||
|
Constructs a Image3DWidget. |
||||||
|
|
||||||
|
.. ocv:function:: Image3DWidget(const Mat &image, const Size &size) |
||||||
|
|
||||||
|
:param image: BGR or Gray-Scale image. |
||||||
|
:param size: Size of the image. |
||||||
|
|
||||||
|
.. ocv:function:: Image3DWidget(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) |
||||||
|
|
||||||
|
:param position: Position of the image. |
||||||
|
:param normal: Normal of the plane that represents the image. |
||||||
|
:param up_vector: Determines orientation of the image. |
||||||
|
:param image: BGR or Gray-Scale image. |
||||||
|
:param size: Size of the image. |
||||||
|
|
||||||
|
Image3DWidget::setImage |
||||||
|
----------------------- |
||||||
|
Sets the image content of the widget. |
||||||
|
|
||||||
|
.. ocv:function:: void setImage(const Mat &image) |
||||||
|
|
||||||
|
:param image: BGR or Gray-Scale image. |
||||||
|
|
||||||
|
CameraPositionWidget |
||||||
|
-------------------- |
||||||
|
.. ocv:class:: CameraPositionWidget |
||||||
|
|
||||||
|
This 3D Widget represents camera position. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CameraPositionWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
//! Creates camera coordinate frame (axes) at the origin |
||||||
|
CameraPositionWidget(double scale = 1.0); |
||||||
|
//! Creates frustum based on the intrinsic marix K at the origin |
||||||
|
CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); |
||||||
|
//! Creates frustum based on the field of view at the origin |
||||||
|
CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); |
||||||
|
//! Creates frustum and display given image at the far plane |
||||||
|
CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
CameraPositionWidget::CameraPositionWidget |
||||||
|
------------------------------------------ |
||||||
|
Constructs a CameraPositionWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CameraPositionWidget(double scale = 1.0) |
||||||
|
|
||||||
|
Creates camera coordinate frame at the origin. |
||||||
|
|
||||||
|
.. ocv:function:: CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
.. ocv:function:: CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
.. ocv:function:: CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param K: Intrinsic matrix of the camera. |
||||||
|
:param img: BGR or Gray-Scale image that is going to be displayed at 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. |
||||||
|
|
||||||
|
TrajectoryWidget |
||||||
|
---------------- |
||||||
|
.. ocv:class:: TrajectoryWidget |
||||||
|
|
||||||
|
This 3D Widget represents a trajectory. :: |
||||||
|
|
||||||
|
class CV_EXPORTS TrajectoryWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2}; |
||||||
|
|
||||||
|
//! Displays trajectory of the given path either by coordinate frames or polyline |
||||||
|
TrajectoryWidget(const std::vector<Affine3f> &path, int display_mode = TrajectoryWidget::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0); |
||||||
|
//! Displays trajectory of the given path by frustums |
||||||
|
TrajectoryWidget(const std::vector<Affine3f> &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()); |
||||||
|
//! Displays trajectory of the given path by frustums |
||||||
|
TrajectoryWidget(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
TrajectoryWidget::TrajectoryWidget |
||||||
|
---------------------------------- |
||||||
|
Constructs a TrajectoryWidget. |
||||||
|
|
||||||
|
.. ocv:function:: TrajectoryWidget(const std::vector<Affine3f> &path, int display_mode = TrajectoryWidget::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0) |
||||||
|
|
||||||
|
:param path: List of poses on a trajectory. |
||||||
|
:param display_mode: Display mode. This can be DISPLAY_PATH, DISPLAY_FRAMES, DISPLAY_PATH & DISPLAY_FRAMES. |
||||||
|
:param color: Color of the polyline that represents path. Frames are not affected. |
||||||
|
:param scale: Scale of the frames. Polyline is not affected. |
||||||
|
|
||||||
|
Displays trajectory of the given path as follows: |
||||||
|
|
||||||
|
* DISPLAY_PATH : Displays a poly line that represents the path. |
||||||
|
* DISPLAY_FRAMES : Displays coordinate frames at each pose. |
||||||
|
* DISPLAY_PATH & DISPLAY_FRAMES : Displays both poly line and coordinate frames. |
||||||
|
|
||||||
|
.. ocv:function:: TrajectoryWidget(const std::vector<Affine3f> &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param path: List of poses on a trajectory. |
||||||
|
: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. |
||||||
|
|
||||||
|
.. ocv:function:: TrajectoryWidget(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white()) |
||||||
|
|
||||||
|
:param path: List of poses on a trajectory. |
||||||
|
: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. |
||||||
|
|
||||||
|
SpheresTrajectoryWidget |
||||||
|
----------------------- |
||||||
|
.. ocv:class:: SpheresTrajectoryWidget |
||||||
|
|
||||||
|
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 SpheresTrajectoryWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
SpheresTrajectoryWidget(const std::vector<Affine3f> &path, float line_length = 0.05f, |
||||||
|
double init_sphere_radius = 0.021, sphere_radius = 0.007, |
||||||
|
Color &line_color = Color::white(), const Color &sphere_color = Color::white()); |
||||||
|
}; |
||||||
|
|
||||||
|
SpheresTrajectoryWidget::SpheresTrajectoryWidget |
||||||
|
------------------------------------------------ |
||||||
|
Constructs a SpheresTrajectoryWidget. |
||||||
|
|
||||||
|
.. ocv:function:: SpheresTrajectoryWidget(const std::vector<Affine3f> &path, float line_length = 0.05f, double init_sphere_radius = 0.021, double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()) |
||||||
|
|
||||||
|
:param path: List of poses on a trajectory. |
||||||
|
:param line_length: Length of the lines. |
||||||
|
:param init_sphere_radius: Radius of the first sphere which represents the initial position of the camera. |
||||||
|
:param sphere_radius: Radius of the rest of the spheres. |
||||||
|
:param line_color: Color of the lines. |
||||||
|
:param sphere_color: Color of the spheres. |
||||||
|
|
||||||
|
CloudWidget |
||||||
|
----------- |
||||||
|
.. ocv:class:: CloudWidget |
||||||
|
|
||||||
|
This 3D Widget defines a point cloud. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CloudWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
//! Each point in cloud is mapped to a color in colors |
||||||
|
CloudWidget(InputArray cloud, InputArray colors); |
||||||
|
//! All points in cloud have the same color |
||||||
|
CloudWidget(InputArray cloud, const Color &color = Color::white()); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
CloudWidget::CloudWidget |
||||||
|
------------------------ |
||||||
|
Constructs a CloudWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CloudWidget(InputArray cloud, InputArray colors) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). |
||||||
|
|
||||||
|
.. ocv:function:: CloudWidget(InputArray cloud, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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. |
||||||
|
|
||||||
|
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). |
||||||
|
|
||||||
|
CloudCollectionWidget |
||||||
|
--------------------- |
||||||
|
.. ocv:class:: CloudCollectionWidget |
||||||
|
|
||||||
|
This 3D Widget defines a collection of clouds. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CloudCollectionWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CloudCollectionWidget(); |
||||||
|
|
||||||
|
//! Each point in cloud is mapped to a color in colors |
||||||
|
void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity()); |
||||||
|
//! All points in cloud have the same color |
||||||
|
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3f &pose = Affine3f::Identity()); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
CloudCollectionWidget::CloudCollectionWidget |
||||||
|
-------------------------------------------- |
||||||
|
Constructs a CloudCollectionWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CloudCollectionWidget() |
||||||
|
|
||||||
|
CloudCollectionWidget::addCloud |
||||||
|
------------------------------- |
||||||
|
Adds a cloud to the collection. |
||||||
|
|
||||||
|
.. ocv:function:: void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity()) |
||||||
|
|
||||||
|
: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). |
||||||
|
|
||||||
|
.. ocv:function:: void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3f &pose = Affine3f::Identity()) |
||||||
|
|
||||||
|
:param cloud: Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4. |
||||||
|
:param colors: 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). |
||||||
|
|
||||||
|
CloudNormalsWidget |
||||||
|
------------------ |
||||||
|
.. ocv:class:: CloudNormalsWidget |
||||||
|
|
||||||
|
This 3D Widget represents normals of a point cloud. :: |
||||||
|
|
||||||
|
class CV_EXPORTS CloudNormalsWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
CloudNormalsWidget::CloudNormalsWidget |
||||||
|
-------------------------------------- |
||||||
|
Constructs a CloudNormalsWidget. |
||||||
|
|
||||||
|
.. ocv:function:: CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()) |
||||||
|
|
||||||
|
: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 levelth normal. |
||||||
|
:param scale: Scale of the arrows that represent normals. |
||||||
|
:param color: Color of the arrows that represent normals. |
||||||
|
|
||||||
|
MeshWidget |
||||||
|
---------- |
||||||
|
.. ocv:class:: MeshWidget |
||||||
|
|
||||||
|
This 3D Widget defines a mesh. :: |
||||||
|
|
||||||
|
class CV_EXPORTS MeshWidget : public Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
MeshWidget(const Mesh3d &mesh); |
||||||
|
|
||||||
|
private: |
||||||
|
/* hidden */ |
||||||
|
}; |
||||||
|
|
||||||
|
MeshWidget::MeshWidget |
||||||
|
---------------------- |
||||||
|
Constructs a MeshWidget. |
||||||
|
|
||||||
|
.. ocv:function:: MeshWidget(const Mesh3d &mesh) |
||||||
|
|
||||||
|
:param mesh: Mesh object that will be displayed. |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,265 +0,0 @@ |
|||||||
#include <common.h> |
|
||||||
#include <cstdlib> |
|
||||||
#include <opencv2/viz/types.hpp> |
|
||||||
#include "viz3d_impl.hpp" |
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//Eigen::Vector2i cv::viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
|
||||||
//{
|
|
||||||
// // Transform world to clipping coordinates
|
|
||||||
// Eigen::Vector4d world (view_projection_matrix * world_pt);
|
|
||||||
// // Normalize w-component
|
|
||||||
// world /= world.w ();
|
|
||||||
|
|
||||||
// // X/Y screen space coordinate
|
|
||||||
// int screen_x = int (floor (double (((world.x () + 1) / 2.0) * width) + 0.5));
|
|
||||||
// int screen_y = int (floor (double (((world.y () + 1) / 2.0) * height) + 0.5));
|
|
||||||
|
|
||||||
// // Calculate -world_pt.y () because the screen Y axis is oriented top->down, ie 0 is top-left
|
|
||||||
// //int winY = (int) floor ( (double) (((1 - world_pt.y ()) / 2.0) * height) + 0.5); // top left
|
|
||||||
|
|
||||||
// return (Eigen::Vector2i (screen_x, screen_y));
|
|
||||||
//}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//void cv::viz::getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24])
|
|
||||||
//{
|
|
||||||
// // Set up the normals
|
|
||||||
// Eigen::Vector4d normals[6];
|
|
||||||
// for (int i=0; i < 6; i++)
|
|
||||||
// {
|
|
||||||
// normals[i] = Eigen::Vector4d (0.0, 0.0, 0.0, 1.0);
|
|
||||||
|
|
||||||
// // if i is even set to -1, if odd set to +1
|
|
||||||
// normals[i] (i/2) = 1 - (i%2)*2;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Transpose the matrix for use with normals
|
|
||||||
// Eigen::Matrix4d view_matrix = view_projection_matrix.transpose ();
|
|
||||||
|
|
||||||
// // Transform the normals to world coordinates
|
|
||||||
// for (int i=0; i < 6; i++)
|
|
||||||
// {
|
|
||||||
// normals[i] = view_matrix * normals[i];
|
|
||||||
|
|
||||||
// double f = 1.0/sqrt (normals[i].x () * normals[i].x () +
|
|
||||||
// normals[i].y () * normals[i].y () +
|
|
||||||
// normals[i].z () * normals[i].z ());
|
|
||||||
|
|
||||||
// planes[4*i + 0] = normals[i].x ()*f;
|
|
||||||
// planes[4*i + 1] = normals[i].y ()*f;
|
|
||||||
// planes[4*i + 2] = normals[i].z ()*f;
|
|
||||||
// planes[4*i + 3] = normals[i].w ()*f;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//int cv::viz::cullFrustum (double frustum[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
|
|
||||||
//{
|
|
||||||
// int result = PCL_INSIDE_FRUSTUM;
|
|
||||||
|
|
||||||
// for(int i =0; i < 6; i++){
|
|
||||||
// double a = frustum[(i*4)];
|
|
||||||
// double b = frustum[(i*4)+1];
|
|
||||||
// double c = frustum[(i*4)+2];
|
|
||||||
// double d = frustum[(i*4)+3];
|
|
||||||
|
|
||||||
// //cout << i << ": " << a << "x + " << b << "y + " << c << "z + " << d << endl;
|
|
||||||
|
|
||||||
// // Basic VFC algorithm
|
|
||||||
// Eigen::Vector3d center ((max_bb.x () - min_bb.x ()) / 2 + min_bb.x (),
|
|
||||||
// (max_bb.y () - min_bb.y ()) / 2 + min_bb.y (),
|
|
||||||
// (max_bb.z () - min_bb.z ()) / 2 + min_bb.z ());
|
|
||||||
|
|
||||||
// Eigen::Vector3d radius (fabs (static_cast<double> (max_bb.x () - center.x ())),
|
|
||||||
// fabs (static_cast<double> (max_bb.y () - center.y ())),
|
|
||||||
// fabs (static_cast<double> (max_bb.z () - center.z ())));
|
|
||||||
|
|
||||||
// double m = (center.x () * a) + (center.y () * b) + (center.z () * c) + d;
|
|
||||||
// double n = (radius.x () * fabs(a)) + (radius.y () * fabs(b)) + (radius.z () * fabs(c));
|
|
||||||
|
|
||||||
// if (m + n < 0){
|
|
||||||
// result = PCL_OUTSIDE_FRUSTUM;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (m - n < 0)
|
|
||||||
// {
|
|
||||||
// result = PCL_INTERSECT_FRUSTUM;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return result;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void
|
|
||||||
//cv::viz::getModelViewPosition (Eigen::Matrix4d model_view_matrix, Eigen::Vector3d &position)
|
|
||||||
//{
|
|
||||||
// //Compute eye or position from model view matrix
|
|
||||||
// Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix.inverse();
|
|
||||||
// for (int i=0; i < 3; i++)
|
|
||||||
// {
|
|
||||||
// position(i) = inverse_model_view_matrix(i, 3);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Lookup table of max 6 bounding box vertices, followed by number of vertices, ie {v0, v1, v2, v3, v4, v5, nv}
|
|
||||||
//
|
|
||||||
// 3--------2
|
|
||||||
// /| /| Y 0 = xmin, ymin, zmin
|
|
||||||
// / | / | | 6 = xmax, ymax. zmax
|
|
||||||
// 7--------6 | |
|
|
||||||
// | | | | |
|
|
||||||
// | 0-----|--1 +------X
|
|
||||||
// | / | / /
|
|
||||||
// |/ |/ /
|
|
||||||
// 4--------5 Z
|
|
||||||
|
|
||||||
int hull_vertex_table[43][7] = { |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, // inside
|
|
||||||
{ 0, 4, 7, 3, 0, 0, 4 }, // left
|
|
||||||
{ 1, 2, 6, 5, 0, 0, 4 }, // right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 1, 5, 4, 0, 0, 4 }, // bottom
|
|
||||||
{ 0, 1, 5, 4, 7, 3, 6 }, // bottom, left
|
|
||||||
{ 0, 1, 2, 6, 5, 4, 6 }, // bottom, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 2, 3, 7, 6, 0, 0, 4 }, // top
|
|
||||||
{ 4, 7, 6, 2, 3, 0, 6 }, // top, left
|
|
||||||
{ 2, 3, 7, 6, 5, 1, 6 }, // top, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 3, 2, 1, 0, 0, 4 }, // front
|
|
||||||
{ 0, 4, 7, 3, 2, 1, 6 }, // front, left
|
|
||||||
{ 0, 3, 2, 6, 5, 1, 6 }, // front, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 3, 2, 1, 5, 4, 6 }, // front, bottom
|
|
||||||
{ 2, 1, 5, 4, 7, 3, 6 }, // front, bottom, left
|
|
||||||
{ 0, 3, 2, 6, 5, 4, 6 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 3, 7, 6, 2, 1, 6 }, // front, top
|
|
||||||
{ 0, 4, 7, 6, 2, 1, 6 }, // front, top, left
|
|
||||||
{ 0, 3, 7, 6, 5, 1, 6 }, // front, top, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 4, 5, 6, 7, 0, 0, 4 }, // back
|
|
||||||
{ 4, 5, 6, 7, 3, 0, 6 }, // back, left
|
|
||||||
{ 1, 2, 6, 7, 4, 5, 6 }, // back, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 0, 1, 5, 6, 7, 4, 6 }, // back, bottom
|
|
||||||
{ 0, 1, 5, 6, 7, 3, 6 }, // back, bottom, left
|
|
||||||
{ 0, 1, 2, 6, 7, 4, 6 }, // back, bottom, right
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0 }, |
|
||||||
{ 2, 3, 7, 4, 5, 6, 6 }, // back, top
|
|
||||||
{ 0, 4, 5, 6, 2, 3, 6 }, // back, top, left
|
|
||||||
{ 1, 2, 3, 7, 4, 5, 6 } // back, top, right
|
|
||||||
}; |
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//float
|
|
||||||
//cv::viz::viewScreenArea (
|
|
||||||
// const Eigen::Vector3d &eye,
|
|
||||||
// const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb,
|
|
||||||
// const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
|
||||||
//{
|
|
||||||
// Eigen::Vector4d bounding_box[8];
|
|
||||||
// bounding_box[0] = Eigen::Vector4d(min_bb.x (), min_bb.y (), min_bb.z (), 1.0);
|
|
||||||
// bounding_box[1] = Eigen::Vector4d(max_bb.x (), min_bb.y (), min_bb.z (), 1.0);
|
|
||||||
// bounding_box[2] = Eigen::Vector4d(max_bb.x (), max_bb.y (), min_bb.z (), 1.0);
|
|
||||||
// bounding_box[3] = Eigen::Vector4d(min_bb.x (), max_bb.y (), min_bb.z (), 1.0);
|
|
||||||
// bounding_box[4] = Eigen::Vector4d(min_bb.x (), min_bb.y (), max_bb.z (), 1.0);
|
|
||||||
// bounding_box[5] = Eigen::Vector4d(max_bb.x (), min_bb.y (), max_bb.z (), 1.0);
|
|
||||||
// bounding_box[6] = Eigen::Vector4d(max_bb.x (), max_bb.y (), max_bb.z (), 1.0);
|
|
||||||
// bounding_box[7] = Eigen::Vector4d(min_bb.x (), max_bb.y (), max_bb.z (), 1.0);
|
|
||||||
|
|
||||||
// // Compute 6-bit code to classify eye with respect to the 6 defining planes
|
|
||||||
// int pos = ((eye.x () < bounding_box[0].x ()) ) // 1 = left
|
|
||||||
// + ((eye.x () > bounding_box[6].x ()) << 1) // 2 = right
|
|
||||||
// + ((eye.y () < bounding_box[0].y ()) << 2) // 4 = bottom
|
|
||||||
// + ((eye.y () > bounding_box[6].y ()) << 3) // 8 = top
|
|
||||||
// + ((eye.z () < bounding_box[0].z ()) << 4) // 16 = front
|
|
||||||
// + ((eye.z () > bounding_box[6].z ()) << 5); // 32 = back
|
|
||||||
|
|
||||||
// // Look up number of vertices
|
|
||||||
// int num = hull_vertex_table[pos][6];
|
|
||||||
// if (num == 0)
|
|
||||||
// {
|
|
||||||
// return (float (width * height));
|
|
||||||
// }
|
|
||||||
// //return 0.0;
|
|
||||||
|
|
||||||
|
|
||||||
// // cout << "eye: " << eye.x() << " " << eye.y() << " " << eye.z() << endl;
|
|
||||||
// // cout << "min: " << bounding_box[0].x() << " " << bounding_box[0].y() << " " << bounding_box[0].z() << endl;
|
|
||||||
// //
|
|
||||||
// // cout << "pos: " << pos << " ";
|
|
||||||
// // switch(pos){
|
|
||||||
// // case 0: cout << "inside" << endl; break;
|
|
||||||
// // case 1: cout << "left" << endl; break;
|
|
||||||
// // case 2: cout << "right" << endl; break;
|
|
||||||
// // case 3:
|
|
||||||
// // case 4: cout << "bottom" << endl; break;
|
|
||||||
// // case 5: cout << "bottom, left" << endl; break;
|
|
||||||
// // case 6: cout << "bottom, right" << endl; break;
|
|
||||||
// // case 7:
|
|
||||||
// // case 8: cout << "top" << endl; break;
|
|
||||||
// // case 9: cout << "top, left" << endl; break;
|
|
||||||
// // case 10: cout << "top, right" << endl; break;
|
|
||||||
// // case 11:
|
|
||||||
// // case 12:
|
|
||||||
// // case 13:
|
|
||||||
// // case 14:
|
|
||||||
// // case 15:
|
|
||||||
// // case 16: cout << "front" << endl; break;
|
|
||||||
// // case 17: cout << "front, left" << endl; break;
|
|
||||||
// // case 18: cout << "front, right" << endl; break;
|
|
||||||
// // case 19:
|
|
||||||
// // case 20: cout << "front, bottom" << endl; break;
|
|
||||||
// // case 21: cout << "front, bottom, left" << endl; break;
|
|
||||||
// // case 22:
|
|
||||||
// // case 23:
|
|
||||||
// // case 24: cout << "front, top" << endl; break;
|
|
||||||
// // case 25: cout << "front, top, left" << endl; break;
|
|
||||||
// // case 26: cout << "front, top, right" << endl; break;
|
|
||||||
// // case 27:
|
|
||||||
// // case 28:
|
|
||||||
// // case 29:
|
|
||||||
// // case 30:
|
|
||||||
// // case 31:
|
|
||||||
// // case 32: cout << "back" << endl; break;
|
|
||||||
// // case 33: cout << "back, left" << endl; break;
|
|
||||||
// // case 34: cout << "back, right" << endl; break;
|
|
||||||
// // case 35:
|
|
||||||
// // case 36: cout << "back, bottom" << endl; break;
|
|
||||||
// // case 37: cout << "back, bottom, left" << endl; break;
|
|
||||||
// // case 38: cout << "back, bottom, right" << endl; break;
|
|
||||||
// // case 39:
|
|
||||||
// // case 40: cout << "back, top" << endl; break;
|
|
||||||
// // case 41: cout << "back, top, left" << endl; break;
|
|
||||||
// // case 42: cout << "back, top, right" << endl; break;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// //return -1 if inside
|
|
||||||
// Eigen::Vector2d dst[8];
|
|
||||||
// for (int i = 0; i < num; i++)
|
|
||||||
// {
|
|
||||||
// Eigen::Vector4d world_pt = bounding_box[hull_vertex_table[pos][i]];
|
|
||||||
// Eigen::Vector2i screen_pt = cv::viz::worldToView(world_pt, view_projection_matrix, width, height);
|
|
||||||
// // cout << "point[" << i << "]: " << screen_pt.x() << " " << screen_pt.y() << endl;
|
|
||||||
// dst[i] = Eigen::Vector2d(screen_pt.x (), screen_pt.y ());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// double sum = 0.0;
|
|
||||||
// for (int i = 0; i < num; ++i)
|
|
||||||
// {
|
|
||||||
// sum += (dst[i].x () - dst[(i+1) % num].x ()) * (dst[i].y () + dst[(i+1) % num].y ());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return (fabsf (float (sum * 0.5f)));
|
|
||||||
//}
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,106 @@ |
|||||||
|
/**
|
||||||
|
* @file creating_widgets.cpp |
||||||
|
* @brief Creating custom widgets using VTK |
||||||
|
* @author Ozan Cagri Tonkal |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <opencv2/viz.hpp> |
||||||
|
#include <opencv2/viz/widget_accessor.hpp> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#include <vtkPoints.h> |
||||||
|
#include <vtkTriangle.h> |
||||||
|
#include <vtkCellArray.h> |
||||||
|
#include <vtkPolyData.h> |
||||||
|
#include <vtkPolyDataMapper.h> |
||||||
|
#include <vtkIdList.h> |
||||||
|
#include <vtkActor.h> |
||||||
|
#include <vtkProp.h> |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @function help |
||||||
|
* @brief Display instructions to use this tutorial program |
||||||
|
*/ |
||||||
|
void help() |
||||||
|
{ |
||||||
|
cout |
||||||
|
<< "--------------------------------------------------------------------------" << endl |
||||||
|
<< "This program shows how to create a custom widget. You can create your own " |
||||||
|
<< "widgets by extending Widget2D/Widget3D, and with the help of WidgetAccessor." << endl |
||||||
|
<< "Usage:" << endl |
||||||
|
<< "./creating_widgets" << endl |
||||||
|
<< endl; |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @class TriangleWidget |
||||||
|
* @brief Defining our own 3D Triangle widget |
||||||
|
*/ |
||||||
|
class TriangleWidget : public viz::Widget3D |
||||||
|
{ |
||||||
|
public: |
||||||
|
TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||||
|
}; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @function TriangleWidget::TriangleWidget |
||||||
|
* @brief Constructor |
||||||
|
*/ |
||||||
|
TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color) |
||||||
|
{ |
||||||
|
// Create a triangle
|
||||||
|
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); |
||||||
|
points->InsertNextPoint(pt1.x, pt1.y, pt1.z); |
||||||
|
points->InsertNextPoint(pt2.x, pt2.y, pt2.z); |
||||||
|
points->InsertNextPoint(pt3.x, pt3.y, pt3.z); |
||||||
|
|
||||||
|
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New(); |
||||||
|
triangle->GetPointIds()->SetId(0,0); |
||||||
|
triangle->GetPointIds()->SetId(1,1); |
||||||
|
triangle->GetPointIds()->SetId(2,2); |
||||||
|
|
||||||
|
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); |
||||||
|
cells->InsertNextCell(triangle); |
||||||
|
|
||||||
|
// Create a polydata object
|
||||||
|
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New(); |
||||||
|
|
||||||
|
// Add the geometry and topology to the polydata
|
||||||
|
polyData->SetPoints(points); |
||||||
|
polyData->SetPolys(cells); |
||||||
|
|
||||||
|
// Create mapper and actor
|
||||||
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); |
||||||
|
mapper->SetInput(polyData); |
||||||
|
|
||||||
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); |
||||||
|
actor->SetMapper(mapper); |
||||||
|
|
||||||
|
// Store this actor in the widget in order that visualizer can access it
|
||||||
|
viz::WidgetAccessor::setProp(*this, actor); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @function main |
||||||
|
*/ |
||||||
|
int main() |
||||||
|
{ |
||||||
|
help(); |
||||||
|
|
||||||
|
/// Create a window
|
||||||
|
viz::Viz3d myWindow("Creating Widgets"); |
||||||
|
|
||||||
|
/// Create a triangle widget
|
||||||
|
TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0)); |
||||||
|
|
||||||
|
/// Show widget in the visualizer window
|
||||||
|
myWindow.showWidget("TRIANGLE", tw); |
||||||
|
|
||||||
|
/// Start event loop
|
||||||
|
myWindow.spin(); |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
/**
|
||||||
|
* @file launching_viz.cpp |
||||||
|
* @brief Launching visualization window |
||||||
|
* @author Ozan Cagri Tonkal |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <opencv2/viz.hpp> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @function help |
||||||
|
* @brief Display instructions to use this tutorial program |
||||||
|
*/ |
||||||
|
void help() |
||||||
|
{ |
||||||
|
cout |
||||||
|
<< "--------------------------------------------------------------------------" << endl |
||||||
|
<< "This program shows how to launch a 3D visualization window. You can stop event loop to continue executing. " |
||||||
|
<< "You can access the same window via its name. You can run event loop for a given period of time. " << endl |
||||||
|
<< "Usage:" << endl |
||||||
|
<< "./launching_viz" << endl |
||||||
|
<< endl; |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @function main |
||||||
|
*/ |
||||||
|
int main() |
||||||
|
{ |
||||||
|
help(); |
||||||
|
/// Create a window
|
||||||
|
viz::Viz3d myWindow("Viz Demo"); |
||||||
|
|
||||||
|
/// Start event loop
|
||||||
|
myWindow.spin(); |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
|
cout << "First event loop is over" << endl; |
||||||
|
|
||||||
|
/// Access window via its name
|
||||||
|
viz::Viz3d sameWindow = viz::get("Viz Demo"); |
||||||
|
|
||||||
|
/// Start event loop
|
||||||
|
sameWindow.spin(); |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
|
cout << "Second event loop is over" << endl; |
||||||
|
|
||||||
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
|
/// Start event loop once for 1 millisecond
|
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
while(!sameWindow.wasStopped()) |
||||||
|
{ |
||||||
|
/// Interact with window
|
||||||
|
|
||||||
|
/// Event loop for 1 millisecond
|
||||||
|
sameWindow.spinOnce(1, true); |
||||||
|
} |
||||||
|
|
||||||
|
/// Once more event loop is stopped
|
||||||
|
cout << "Last event loop is over" << endl; |
||||||
|
return 0; |
||||||
|
} |
Loading…
Reference in new issue