3D Visualizer

Overview

This section describes 3D visualization window as well as classes and methods that are used to interact with it. More…

// classes

class cv::viz::Camera;
class cv::viz::Color;
class cv::viz::KeyboardEvent;
class cv::viz::Mesh;
class cv::viz::MouseEvent;
class cv::viz::Viz3d;

// global functions

void
cv::viz::computeNormals(
    const Mesh& mesh,
    OutputArray normals
    );

Viz3d
cv::viz::getWindowByName(const String& window_name);

Viz3d
cv::viz::imshow(
    const String& window_name,
    InputArray image,
    const Size& window_size = Size(-1, -1)
    );

bool
cv::viz::isNan(float x);

bool
cv::viz::isNan(double x);

template <
    typename _Tp,
    int cn
    >
bool
cv::viz::isNan(const Vec<_Tp, cn>& v);

template <typename _Tp>
bool
cv::viz::isNan(const Point3_<_Tp>& p);

Affine3d
cv::viz::makeCameraPose(
    const Vec3d& position,
    const Vec3d& focal_point,
    const Vec3d& y_dir
    );

Affine3d
cv::viz::makeTransformToGlobal(
    const Vec3d& axis_x,
    const Vec3d& axis_y,
    const Vec3d& axis_z,
    const Vec3d& origin = Vec3d::all(0)
    );

Mat
cv::viz::readCloud(
    const String& file,
    OutputArray colors = noArray(),
    OutputArray normals = noArray()
    );

Mesh
cv::viz::readMesh(const String& file);

bool
cv::viz::readPose(
    const String& file,
    Affine3d& pose,
    const String& tag = "pose"
    );

void
cv::viz::readTrajectory(
    OutputArray traj,
    const String& files_format = "pose%05d.xml",
    int start = 0,
    int end = INT_MAX,
    const String& tag = "pose"
    );

void
cv::viz::unregisterAllWindows();

void
cv::viz::writeCloud(
    const String& file,
    InputArray cloud,
    InputArray colors = noArray(),
    InputArray normals = noArray(),
    bool binary = false
    );

void
cv::viz::writePose(
    const String& file,
    const Affine3d& pose,
    const String& tag = "pose"
    );

void
cv::viz::writeTrajectory(
    InputArray traj,
    const String& files_format = "pose%05d.xml",
    int start = 0,
    const String& tag = "pose"
    );

Detailed Documentation

This section describes 3D visualization window as well as classes and methods that are used to interact with it.

3D visualization window (see Viz3d) is used to display widgets (see Widget), and it provides several methods to interact with scene and widgets.

Global Functions

void
cv::viz::computeNormals(
    const Mesh& mesh,
    OutputArray normals
    )

Computing normals for mesh.

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

Retrieves a window by its name.

This function returns a Viz3d object with the given name.

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.

Window names are automatically prefixed by “Viz - ” if it is not done by the user.

/// window and window_2 are the same windows.
viz::Viz3d window   = viz::getWindowByName("myWindow");
viz::Viz3d window_2 = viz::getWindowByName("Viz - myWindow");

Parameters:

window_name Name of the window that is to be retrieved.
Viz3d
cv::viz::imshow(
    const String& window_name,
    InputArray image,
    const Size& window_size = Size(-1, -1)
    )

Displays image in specified window.

bool
cv::viz::isNan(float x)

Checks float/double value for nan.

Parameters:

x return true if nan.
bool
cv::viz::isNan(double x)

Checks float/double value for nan.

Parameters:

x return true if nan.
template <
    typename _Tp,
    int cn
    >
bool
cv::viz::isNan(const Vec<_Tp, cn>& v)

Checks float/double value for nan.

Parameters:

v return true if any of the elements of the vector is nan.
template <typename _Tp>
bool
cv::viz::isNan(const Point3_<_Tp>& p)

Checks float/double value for nan.

Parameters:

p return true if any of the elements of the point is nan.
Affine3d
cv::viz::makeCameraPose(
    const Vec3d& position,
    const Vec3d& focal_point,
    const Vec3d& y_dir
    )

Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation).

This function returns pose of the camera in global coordinate frame.

Parameters:

position Position of the camera in global coordinate frame.
focal_point Focal point of the camera in global coordinate frame.
y_dir Up vector of the camera in global coordinate frame.
Affine3d
cv::viz::makeTransformToGlobal(
    const Vec3d& axis_x,
    const Vec3d& axis_y,
    const Vec3d& axis_z,
    const Vec3d& origin = Vec3d::all(0)
    )

Takes coordinate frame data and builds transform to global coordinate frame.

This function returns affine transform that describes transformation between global coordinate frame and a given coordinate frame.

Parameters:

axis_x X axis vector in global coordinate frame.
axis_y Y axis vector in global coordinate frame.
axis_z Z axis vector in global coordinate frame.
origin Origin of the coordinate frame in global coordinate frame.
Mesh
cv::viz::readMesh(const String& file)

Reads mesh. Only ply format is supported now and no texture load support.

bool
cv::viz::readPose(
    const String& file,
    Affine3d& pose,
    const String& tag = "pose"
    )

Read/write poses and trajectories.

void
cv::viz::readTrajectory(
    OutputArray traj,
    const String& files_format = "pose%05d.xml",
    int start = 0,
    int end = INT_MAX,
    const String& tag = "pose"
    )

takes vector<Affine3<T>> with T = float/dobule and loads poses from sequence of files

void
cv::viz::unregisterAllWindows()

Unregisters all Viz windows from internal database. After it ‘ getWindowByName() ‘ will create new windows instead getting existing from the database.

void
cv::viz::writeCloud(
    const String& file,
    InputArray cloud,
    InputArray colors = noArray(),
    InputArray normals = noArray(),
    bool binary = false
    )

Read/write clouds. Supported formats: ply, xyz, obj and stl (readonly)

void
cv::viz::writeTrajectory(
    InputArray traj,
    const String& files_format = "pose%05d.xml",
    int start = 0,
    const String& tag = "pose"
    )

takes vector<Affine3<T>> with T = float/dobule and writes to a sequence of files with given filename format