OpenCV 4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::viz::Viz3d Class Reference

The Viz3d class represents a 3D visualizer window. This class is implicitly shared. More...

#include <opencv2/viz/viz3d.hpp>

Collaboration diagram for cv::viz::Viz3d:

Public Types

typedef cv::viz::Color Color
 
typedef void(*) KeyboardCallback(const KeyboardEvent &, void *)
 
typedef void(*) MouseCallback(const MouseEvent &, void *)
 

Public Member Functions

 Viz3d (const String &window_name=String())
 The constructors.
 
 Viz3d (const Viz3d &)
 
 ~Viz3d ()
 
void addLight (const Vec3d &position, const Vec3d &focalPoint=Vec3d(0, 0, 0), const Color &color=Color::white(), const Color &diffuseColor=Color::white(), const Color &ambientColor=Color::black(), const Color &specularColor=Color::white())
 Add a light in the scene.
 
void close ()
 
void converTo3DRay (const Point3d &window_coord, Point3d &origin, Vec3d &direction)
 Transforms a point in window coordinate system to a 3D ray in world coordinate system.
 
void convertToWindowCoordinates (const Point3d &pt, Point3d &window_coord)
 Transforms a point in world coordinate system to window coordinate system.
 
Camera getCamera () const
 Returns a camera object that contains intrinsic parameters of the current viewer.
 
double getRenderingProperty (const String &id, int property)
 Returns rendering property of a widget.
 
cv::Mat getScreenshot () const
 Returns the Mat screenshot of the current scene.
 
Affine3d getViewerPose () const
 Returns the current pose of the viewer.
 
Widget getWidget (const String &id) const
 Retrieves a widget from the window.
 
Affine3d getWidgetPose (const String &id) const
 Returns the current pose of a widget in the window.
 
String getWindowName () const
 Returns the name of the window which has been set in the constructor. Viz - is prepended to the name if necessary.
 
Size getWindowSize () const
 Returns the current size of the window.
 
Viz3doperator= (const Viz3d &)
 
void registerKeyboardCallback (KeyboardCallback callback, void *cookie=0)
 Sets keyboard handler.
 
void registerMouseCallback (MouseCallback callback, void *cookie=0)
 Sets mouse handler.
 
void removeAllLights ()
 Remove all lights from the current scene.
 
void removeAllWidgets ()
 Removes all widgets from the window.
 
void removeWidget (const String &id)
 Removes a widget from the window.
 
void resetCamera ()
 Resets camera.
 
void resetCameraViewpoint (const String &id)
 Resets camera viewpoint to a 3D widget in the scene.
 
void saveScreenshot (const String &file)
 Saves screenshot of the current scene.
 
void setBackgroundColor (const Color &color=Color::black(), const Color &color2=Color::not_set())
 Sets background color.
 
void setBackgroundMeshLab ()
 
void setBackgroundTexture (InputArray image=noArray())
 
void setCamera (const Camera &camera)
 Sets the intrinsic parameters of the viewer using Camera.
 
void setFullScreen (bool mode=true)
 Sets or unsets full-screen rendering mode.
 
void setGlobalWarnings (bool enabled=false)
 
void setOffScreenRendering ()
 Create a window in memory instead of on the screen.
 
void setRenderingProperty (const String &id, int property, double value)
 Sets rendering property of a widget.
 
void setRepresentation (int representation)
 Sets geometry representation of the widgets to surface, wireframe or points.
 
void setViewerPose (const Affine3d &pose)
 Sets pose of the viewer.
 
void setWidgetPose (const String &id, const Affine3d &pose)
 Sets pose of a widget in the window.
 
void setWindowPosition (const Point &window_position)
 Sets the position of the window in the screen.
 
void setWindowSize (const Size &window_size)
 Sets the size of the window.
 
void showImage (InputArray image, const Size &window_size=Size(-1, -1))
 Removed all widgets and displays image scaled to whole window area.
 
void showWidget (const String &id, const Widget &widget, const Affine3d &pose=Affine3d::Identity())
 Shows a widget in the window.
 
void spin ()
 The window renders and starts the event loop.
 
void spinOnce (int time=1, bool force_redraw=false)
 Starts the event loop for a given time.
 
void updateWidgetPose (const String &id, const Affine3d &pose)
 Updates pose of a widget in the window by pre-multiplying its current pose.
 
bool wasStopped () const
 Returns whether the event loop has been stopped.
 

Friends

class VizStorage
 

Detailed Description

The Viz3d class represents a 3D visualizer window. This class is implicitly shared.

Member Typedef Documentation

◆ Color

◆ KeyboardCallback

void(*) cv::viz::Viz3d::KeyboardCallback(const KeyboardEvent &, void *)

◆ MouseCallback

void(*) cv::viz::Viz3d::MouseCallback(const MouseEvent &, void *)

Constructor & Destructor Documentation

◆ Viz3d() [1/2]

cv::viz::Viz3d::Viz3d ( const String & window_name = String())

The constructors.

Parameters
window_nameName of the window.

◆ Viz3d() [2/2]

cv::viz::Viz3d::Viz3d ( const Viz3d & )

◆ ~Viz3d()

cv::viz::Viz3d::~Viz3d ( )

Member Function Documentation

◆ addLight()

void cv::viz::Viz3d::addLight ( const Vec3d & position,
const Vec3d & focalPoint = Vec3d(0, 0, 0),
const Color & color = Color::white(),
const Color & diffuseColor = Color::white(),
const Color & ambientColor = Color::black(),
const Color & specularColor = Color::white() )

Add a light in the scene.

Parameters
positionThe position of the light.
focalPointThe point at which the light is shining
colorThe color of the light
diffuseColorThe diffuse color of the light
ambientColorThe ambient color of the light
specularColorThe specular color of the light

◆ close()

void cv::viz::Viz3d::close ( )

◆ converTo3DRay()

void cv::viz::Viz3d::converTo3DRay ( const Point3d & window_coord,
Point3d & origin,
Vec3d & direction )

Transforms a point in window coordinate system to a 3D ray in world coordinate system.

Parameters
window_coordPoint in window coordinate system.
originOutput origin of the ray.
directionOutput direction of the ray.

◆ convertToWindowCoordinates()

void cv::viz::Viz3d::convertToWindowCoordinates ( const Point3d & pt,
Point3d & window_coord )

Transforms a point in world coordinate system to window coordinate system.

Parameters
ptPoint in world coordinate system.
window_coordOutput point in window coordinate system.

◆ getCamera()

Camera cv::viz::Viz3d::getCamera ( ) const

Returns a camera object that contains intrinsic parameters of the current viewer.

◆ getRenderingProperty()

double cv::viz::Viz3d::getRenderingProperty ( const String & id,
int property )

Returns rendering property of a widget.

Parameters
idId of the widget.
propertyProperty.

Rendering property can be one of the following:

  • POINT_SIZE
  • OPACITY
  • LINE_WIDTH
  • FONT_SIZE

REPRESENTATION: Expected values are

  • REPRESENTATION_POINTS
  • REPRESENTATION_WIREFRAME
  • REPRESENTATION_SURFACE

IMMEDIATE_RENDERING:

  • Turn on immediate rendering by setting the value to 1.
  • Turn off immediate rendering by setting the value to 0.

SHADING: Expected values are

  • SHADING_FLAT
  • SHADING_GOURAUD
  • SHADING_PHONG

◆ getScreenshot()

cv::Mat cv::viz::Viz3d::getScreenshot ( ) const

Returns the Mat screenshot of the current scene.

◆ getViewerPose()

Affine3d cv::viz::Viz3d::getViewerPose ( ) const

Returns the current pose of the viewer.

◆ getWidget()

Widget cv::viz::Viz3d::getWidget ( const String & id) const

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.

Parameters
idThe id of the widget that will be returned.

◆ getWidgetPose()

Affine3d cv::viz::Viz3d::getWidgetPose ( const String & id) const

Returns the current pose of a widget in the window.

Parameters
idThe id of the widget whose pose will be returned.

◆ getWindowName()

String cv::viz::Viz3d::getWindowName ( ) const

Returns the name of the window which has been set in the constructor. Viz - is prepended to the name if necessary.

◆ getWindowSize()

Size cv::viz::Viz3d::getWindowSize ( ) const

Returns the current size of the window.

◆ operator=()

Viz3d & cv::viz::Viz3d::operator= ( const Viz3d & )

◆ registerKeyboardCallback()

void cv::viz::Viz3d::registerKeyboardCallback ( KeyboardCallback callback,
void * cookie = 0 )

Sets keyboard handler.

Parameters
callbackKeyboard callback (void (*KeyboardCallbackFunction(const KeyboardEvent&, void*)).
cookieThe optional parameter passed to the callback.

◆ registerMouseCallback()

void cv::viz::Viz3d::registerMouseCallback ( MouseCallback callback,
void * cookie = 0 )

Sets mouse handler.

Parameters
callbackMouse callback (void (*MouseCallback)(const MouseEvent&, void*)).
cookieThe optional parameter passed to the callback.

◆ removeAllLights()

void cv::viz::Viz3d::removeAllLights ( )

Remove all lights from the current scene.

◆ removeAllWidgets()

void cv::viz::Viz3d::removeAllWidgets ( )

Removes all widgets from the window.

◆ removeWidget()

void cv::viz::Viz3d::removeWidget ( const String & id)

Removes a widget from the window.

Parameters
idThe id of the widget that will be removed.

◆ resetCamera()

void cv::viz::Viz3d::resetCamera ( )

Resets camera.

◆ resetCameraViewpoint()

void cv::viz::Viz3d::resetCameraViewpoint ( const String & id)

Resets camera viewpoint to a 3D widget in the scene.

Parameters
idId of a 3D widget.

◆ saveScreenshot()

void cv::viz::Viz3d::saveScreenshot ( const String & file)

Saves screenshot of the current scene.

Parameters
fileName of the file.

◆ setBackgroundColor()

void cv::viz::Viz3d::setBackgroundColor ( const Color & color = Color::black(),
const Color & color2 = Color::not_set() )

Sets background color.

◆ setBackgroundMeshLab()

void cv::viz::Viz3d::setBackgroundMeshLab ( )

◆ setBackgroundTexture()

void cv::viz::Viz3d::setBackgroundTexture ( InputArray image = noArray())
Here is the call graph for this function:

◆ setCamera()

void cv::viz::Viz3d::setCamera ( const Camera & camera)

Sets the intrinsic parameters of the viewer using Camera.

Parameters
cameraCamera object wrapping intrinsic parameters.

◆ setFullScreen()

void cv::viz::Viz3d::setFullScreen ( bool mode = true)

Sets or unsets full-screen rendering mode.

Parameters
modeIf true, window will use full-screen mode.

◆ setGlobalWarnings()

void cv::viz::Viz3d::setGlobalWarnings ( bool enabled = false)

◆ setOffScreenRendering()

void cv::viz::Viz3d::setOffScreenRendering ( )

Create a window in memory instead of on the screen.

◆ setRenderingProperty()

void cv::viz::Viz3d::setRenderingProperty ( const String & id,
int property,
double value )

Sets rendering property of a widget.

Parameters
idId of the widget.
propertyProperty that will be modified.
valueThe new value of the property.

Rendering property can be one of the following:

  • POINT_SIZE
  • OPACITY
  • LINE_WIDTH
  • FONT_SIZE

REPRESENTATION: Expected values are

  • REPRESENTATION_POINTS
  • REPRESENTATION_WIREFRAME
  • REPRESENTATION_SURFACE

IMMEDIATE_RENDERING:

  • Turn on immediate rendering by setting the value to 1.
  • Turn off immediate rendering by setting the value to 0.

SHADING: Expected values are

  • SHADING_FLAT
  • SHADING_GOURAUD
  • SHADING_PHONG

◆ setRepresentation()

void cv::viz::Viz3d::setRepresentation ( int representation)

Sets geometry representation of the widgets to surface, wireframe or points.

Parameters
representationGeometry representation which can be one of the following:
  • REPRESENTATION_POINTS
  • REPRESENTATION_WIREFRAME
  • REPRESENTATION_SURFACE

◆ setViewerPose()

void cv::viz::Viz3d::setViewerPose ( const Affine3d & pose)

Sets pose of the viewer.

Parameters
poseThe new pose of the viewer.

◆ setWidgetPose()

void cv::viz::Viz3d::setWidgetPose ( const String & id,
const Affine3d & pose )

Sets pose of a widget in the window.

Parameters
idThe id of the widget whose pose will be set.
poseThe new pose of the widget.

◆ setWindowPosition()

void cv::viz::Viz3d::setWindowPosition ( const Point & window_position)

Sets the position of the window in the screen.

Parameters
window_positioncoordinates of the window

◆ setWindowSize()

void cv::viz::Viz3d::setWindowSize ( const Size & window_size)

Sets the size of the window.

Parameters
window_sizeNew size of the window.

◆ showImage()

void cv::viz::Viz3d::showImage ( InputArray image,
const Size & window_size = Size(-1, -1) )

Removed all widgets and displays image scaled to whole window area.

Parameters
imageImage to be displayed.
window_sizeSize of Viz3d window. Default value means no change.

◆ showWidget()

void cv::viz::Viz3d::showWidget ( const String & id,
const Widget & widget,
const Affine3d & pose = Affine3d::Identity() )

Shows a widget in the window.

Parameters
idA unique id for the widget.
widgetThe widget to be displayed in the window.
posePose of the widget.

◆ spin()

void cv::viz::Viz3d::spin ( )

The window renders and starts the event loop.

◆ spinOnce()

void cv::viz::Viz3d::spinOnce ( int time = 1,
bool force_redraw = false )

Starts the event loop for a given time.

Parameters
timeAmount of time in milliseconds for the event loop to keep running.
force_redrawIf true, window renders.

◆ updateWidgetPose()

void cv::viz::Viz3d::updateWidgetPose ( const String & id,
const Affine3d & pose )

Updates pose of a widget in the window by pre-multiplying its current pose.

Parameters
idThe id of the widget whose pose will be updated.
poseThe pose that the current pose of the widget will be pre-multiplied by.

◆ wasStopped()

bool cv::viz::Viz3d::wasStopped ( ) const

Returns whether the event loop has been stopped.

Friends And Related Symbol Documentation

◆ VizStorage

friend class VizStorage
friend

The documentation for this class was generated from the following file: