static Color gray();
};
-viz::Mesh3d
+viz::Mesh
-----------
-.. ocv:class:: Mesh3d
+.. ocv:class:: Mesh
This class wraps mesh attributes, and it can load a mesh from a ``ply`` file. ::
- class CV_EXPORTS Mesh3d
+ class CV_EXPORTS Mesh
{
public:
- Mat cloud, colors;
+ Mat cloud, colors, normals;
+
+ //! Raw integer list of the form: (n,id1,id2,...,idn, n,id1,id2,...,idn, ...)
+ //! where n is the number of points in the poligon, and id is a zero-offset index into an associated cloud.
Mat polygons;
//! Loads mesh from a given ply file
- static Mesh3d load(const String& file);
-
- private:
- /* hidden */
+ static Mesh load(const String& file);
};
-viz::Mesh3d::load
+viz::Mesh::load
---------------------
Loads a mesh from a ``ply`` file.
-.. ocv:function:: static Mesh3d load(const String& file)
+.. ocv:function:: static Mesh load(const String& file)
:param file: File name (for no only PLY is supported)
public:
WPlane(const Vec4d& coefs, double size = 1.0, const Color &color = Color::white());
WPlane(const Vec4d& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
- private:
- /* hidden */
};
viz::WPlane::WPlane
{
public:
WPolyLine(InputArray points, const Color &color = Color::white());
-
- private:
- /* hidden */
};
viz::WPolyLine::WPolyLine
WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
//! Creates grid based on the plane equation
WGrid(const Vec4d &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
- private:
- /* hidden */
};
viz::WGrid::WGrid
enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH};
//! Displays trajectory of the given path either by coordinate frames or polyline
- WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.f, const Color &color = Color::white(),;
+ WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.0, const Color &color = Color::white(),;
};
viz::WTrajectory::WTrajectory
-----------------------------
Constructs a WTrajectory.
-.. ocv:function:: WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.f, const Color &color = Color::white())
+.. ocv:function:: WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.0, const Color &color = Color::white())
:param path: List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double]
:param display_mode: Display mode. This can be PATH, FRAMES, and BOTH.
WCloud(InputArray cloud, InputArray colors);
//! All points in cloud have the same color
WCloud(InputArray cloud, const Color &color = Color::white());
-
- private:
- /* hidden */
};
viz::WCloud::WCloud
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
//! All points in cloud have the same color
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3d &pose = Affine3d::Identity());
-
- private:
- /* hidden */
};
viz::WCloudCollection::WCloudCollection
{
public:
WCloudNormals(InputArray cloud, InputArray normals, int level = 100, double scale = 0.02f, const Color &color = Color::white());
-
- private:
- /* hidden */
};
viz::WCloudNormals::WCloudNormals
class CV_EXPORTS WMesh : public Widget3D
{
public:
- WMesh(const Mesh3d &mesh);
-
- private:
- /* hidden */
+ WMesh(const Mesh &mesh);
+ WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
};
viz::WMesh::WMesh
-----------------
Constructs a WMesh.
-.. ocv:function:: WMesh(const Mesh3d &mesh)
+.. ocv:function:: WMesh(const Mesh &mesh)
+
+ :param mesh: :ocv:class:`Mesh` object that will be displayed.
+
+.. ocv:function:: WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
- :param mesh: :ocv:class:`Mesh3d` object that will be displayed.
+ :param cloud: Points of the mesh object.
+ :param polygons: Points of the mesh object.
+ :param colors: Point colors.
+ :param normals: Point normals.
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// Computing normals for mesh
- CV_EXPORTS void computeNormals(const Mesh3d& mesh, OutputArray normals);
+ CV_EXPORTS void computeNormals(const Mesh& mesh, OutputArray normals);
} /* namespace viz */
} /* namespace cv */
static Color amethyst();
};
- class CV_EXPORTS Mesh3d
+ class CV_EXPORTS Mesh
{
public:
-
Mat cloud, colors, normals;
+
+ //! Raw integer list of the form: (n,id1,id2,...,idn, n,id1,id2,...,idn, ...)
+ //! where n is the number of points in the poligon, and id is a zero-offset index into an associated cloud.
Mat polygons;
//! Loads mesh from a given ply file
- static Mesh3d load(const String& file);
+ static Mesh load(const String& file);
};
class CV_EXPORTS Camera
explicit Camera(const Matx33d &K, const Size &window_size);
explicit Camera(const Matx44d &proj, const Size &window_size);
- inline const Vec2d & getClip() const { return clip_; }
- inline void setClip(const Vec2d &clip) { clip_ = clip; }
+ const Vec2d & getClip() const { return clip_; }
+ void setClip(const Vec2d &clip) { clip_ = clip; }
- inline const Size & getWindowSize() const { return window_size_; }
+ const Size & getWindowSize() const { return window_size_; }
void setWindowSize(const Size &window_size);
- inline const Vec2d& getFov() const { return fov_; }
- inline void setFov(const Vec2d& fov) { fov_ = fov; }
+ const Vec2d& getFov() const { return fov_; }
+ void setFov(const Vec2d& fov) { fov_ = fov; }
- inline const Vec2d& getPrincipalPoint() const { return principal_point_; }
- inline const Vec2d& getFocalLength() const { return focal_; }
+ const Vec2d& getPrincipalPoint() const { return principal_point_; }
+ const Vec2d& getFocalLength() const { return focal_; }
void computeProjectionMatrix(Matx44d &proj) const;
class CV_EXPORTS WMesh : public Widget3D
{
public:
- WMesh(const Mesh3d &mesh);
+ WMesh(const Mesh &mesh);
+ WMesh(InputArray cloud, InputArray polygons, InputArray colors = noArray(), InputArray normals = noArray());
};
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/// Mesh Widget implementation
-cv::viz::WMesh::WMesh(const Mesh3d &mesh)
+cv::viz::WMesh::WMesh(const Mesh &mesh)
{
CV_Assert(mesh.cloud.rows == 1 && mesh.polygons.type() == CV_32SC1);
vtkSmartPointer<vtkCellArray> cell_array = vtkSmartPointer<vtkCellArray>::New();
int idx = 0;
- int poly_size = mesh.polygons.total();
- for (int i = 0; i < poly_size; ++idx)
+ size_t polygons_size = mesh.polygons.total();
+ for (size_t i = 0; i < polygons_size; ++idx)
{
int n_points = polygons[i++];
WidgetAccessor::setProp(*this, actor);
}
+cv::viz::WMesh::WMesh(InputArray cloud, InputArray polygons, InputArray colors, InputArray normals)
+{
+ Mesh mesh;
+ mesh.cloud = cloud.getMat();
+ mesh.colors = colors.getMat();
+ mesh.normals = normals.getMat();
+ mesh.polygons = polygons.getMat();
+ *this = WMesh(mesh);
+}
+
template<> CV_EXPORTS cv::viz::WMesh cv::viz::Widget::cast<cv::viz::WMesh>()
{
Widget3D widget = this->cast<Widget3D>();
{
struct MeshUtils
{
- static Mesh3d loadMesh(const String &file)
+ static Mesh loadMesh(const String &file)
{
- Mesh3d mesh;
+ Mesh mesh;
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
reader->SetFileName(file.c_str());
};
}}}
-cv::viz::Mesh3d cv::viz::Mesh3d::load(const String& file)
+cv::viz::Mesh cv::viz::Mesh::load(const String& file)
{
return MeshUtils::loadMesh(file);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// Computing normals for mesh
-void cv::viz::computeNormals(const Mesh3d& mesh, OutputArray _normals)
+void cv::viz::computeNormals(const Mesh& mesh, OutputArray _normals)
{
vtkSmartPointer<vtkPolyData> polydata = getPolyData(WMesh(mesh));
vtkSmartPointer<vtkPolyData> with_normals = VtkUtils::ComputeNormals(polydata);
TEST(Viz, DISABLED_show_mesh)
{
- Mesh3d mesh = Mesh3d::load(get_dragon_ply_file_path());
+ Mesh mesh = Mesh::load(get_dragon_ply_file_path());
Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
TEST(Viz, DISABLED_show_mesh_random_colors)
{
- Mesh3d mesh = Mesh3d::load(get_dragon_ply_file_path());
+ Mesh mesh = Mesh::load(get_dragon_ply_file_path());
theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);
Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
TEST(Viz, DISABLED_show_sampled_normals)
{
- Mesh3d mesh = Mesh3d::load(get_dragon_ply_file_path());
+ Mesh mesh = Mesh::load(get_dragon_ply_file_path());
computeNormals(mesh, mesh.normals);
Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
TEST(Viz, DISABLED_spin_twice_____________________________TODO_UI_BUG)
{
- Mesh3d mesh = Mesh3d::load(get_dragon_ply_file_path());
+ Mesh mesh = Mesh::load(get_dragon_ply_file_path());
Viz3d viz("spin_twice");
viz.showWidget("coosys", WCoordinateSystem());