removed trailing spaces
This commit is contained in:
parent
824c28a588
commit
8de46e1f81
@ -21,7 +21,7 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
#include <opencv2/viz.hpp>
|
#include <opencv2/viz.hpp>
|
||||||
#include <opencv2/viz/widget_accessor.hpp>
|
#include <opencv2/viz/widget_accessor.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <vtkPoints.h>
|
#include <vtkPoints.h>
|
||||||
@ -43,7 +43,7 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
class WTriangle : public viz::Widget3D
|
class WTriangle : public viz::Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,22 +56,22 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
points->InsertNextPoint(pt1.x, pt1.y, pt1.z);
|
points->InsertNextPoint(pt1.x, pt1.y, pt1.z);
|
||||||
points->InsertNextPoint(pt2.x, pt2.y, pt2.z);
|
points->InsertNextPoint(pt2.x, pt2.y, pt2.z);
|
||||||
points->InsertNextPoint(pt3.x, pt3.y, pt3.z);
|
points->InsertNextPoint(pt3.x, pt3.y, pt3.z);
|
||||||
|
|
||||||
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
|
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
|
||||||
triangle->GetPointIds()->SetId(0,0);
|
triangle->GetPointIds()->SetId(0,0);
|
||||||
triangle->GetPointIds()->SetId(1,1);
|
triangle->GetPointIds()->SetId(1,1);
|
||||||
triangle->GetPointIds()->SetId(2,2);
|
triangle->GetPointIds()->SetId(2,2);
|
||||||
|
|
||||||
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
|
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
|
||||||
cells->InsertNextCell(triangle);
|
cells->InsertNextCell(triangle);
|
||||||
|
|
||||||
// Create a polydata object
|
// Create a polydata object
|
||||||
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
// Add the geometry and topology to the polydata
|
// Add the geometry and topology to the polydata
|
||||||
polyData->SetPoints(points);
|
polyData->SetPoints(points);
|
||||||
polyData->SetPolys(cells);
|
polyData->SetPolys(cells);
|
||||||
|
|
||||||
// Create mapper and actor
|
// Create mapper and actor
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
@ -79,13 +79,13 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
#else
|
#else
|
||||||
mapper->SetInputData(polyData);
|
mapper->SetInputData(polyData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
// Store this actor in the widget in order that visualizer can access it
|
// Store this actor in the widget in order that visualizer can access it
|
||||||
viz::WidgetAccessor::setProp(*this, actor);
|
viz::WidgetAccessor::setProp(*this, actor);
|
||||||
|
|
||||||
// Set the color of the widget. This has to be called after WidgetAccessor.
|
// Set the color of the widget. This has to be called after WidgetAccessor.
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
@ -94,22 +94,22 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
* @function main
|
* @function main
|
||||||
*/
|
*/
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Creating Widgets");
|
viz::Viz3d myWindow("Creating Widgets");
|
||||||
|
|
||||||
/// Create a triangle widget
|
/// Create a triangle widget
|
||||||
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
||||||
|
|
||||||
/// Show widget in the visualizer window
|
/// Show widget in the visualizer window
|
||||||
myWindow.showWidget("TRIANGLE", tw);
|
myWindow.showWidget("TRIANGLE", tw);
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@ -122,33 +122,33 @@ Here is the general structure of the program:
|
|||||||
class WTriangle : public viz::Widget3D
|
class WTriangle : public viz::Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
* Assign a VTK actor to the widget.
|
* Assign a VTK actor to the widget.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
// Store this actor in the widget in order that visualizer can access it
|
// Store this actor in the widget in order that visualizer can access it
|
||||||
viz::WidgetAccessor::setProp(*this, actor);
|
viz::WidgetAccessor::setProp(*this, actor);
|
||||||
|
|
||||||
* Set color of the widget.
|
* Set color of the widget.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
// Set the color of the widget. This has to be called after WidgetAccessor.
|
// Set the color of the widget. This has to be called after WidgetAccessor.
|
||||||
setColor(color);
|
setColor(color);
|
||||||
|
|
||||||
* Construct a triangle widget and display it in the window.
|
* Construct a triangle widget and display it in the window.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Create a triangle widget
|
/// Create a triangle widget
|
||||||
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
||||||
|
|
||||||
/// Show widget in the visualizer window
|
/// Show widget in the visualizer window
|
||||||
myWindow.showWidget("TRIANGLE", tw);
|
myWindow.showWidget("TRIANGLE", tw);
|
||||||
|
|
||||||
Results
|
Results
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function main
|
* @function main
|
||||||
*/
|
*/
|
||||||
@ -35,38 +35,38 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
{
|
{
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Viz Demo");
|
viz::Viz3d myWindow("Viz Demo");
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
cout << "First event loop is over" << endl;
|
cout << "First event loop is over" << endl;
|
||||||
|
|
||||||
/// Access window via its name
|
/// Access window via its name
|
||||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
sameWindow.spin();
|
sameWindow.spin();
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
cout << "Second event loop is over" << endl;
|
cout << "Second event loop is over" << endl;
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
/// Start event loop once for 1 millisecond
|
/// Start event loop once for 1 millisecond
|
||||||
sameWindow.spinOnce(1, true);
|
sameWindow.spinOnce(1, true);
|
||||||
while(!sameWindow.wasStopped())
|
while(!sameWindow.wasStopped())
|
||||||
{
|
{
|
||||||
/// Interact with window
|
/// Interact with window
|
||||||
|
|
||||||
/// Event loop for 1 millisecond
|
/// Event loop for 1 millisecond
|
||||||
sameWindow.spinOnce(1, true);
|
sameWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Once more event loop is stopped
|
/// Once more event loop is stopped
|
||||||
cout << "Last event loop is over" << endl;
|
cout << "Last event loop is over" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@ -78,21 +78,21 @@ Here is the general structure of the program:
|
|||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Viz Demo");
|
viz::Viz3d myWindow("Viz Demo");
|
||||||
|
|
||||||
* Start event loop. This event loop will run until user terminates it by pressing **e**, **E**, **q**, **Q**.
|
* Start event loop. This event loop will run until user terminates it by pressing **e**, **E**, **q**, **Q**.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
myWindow.spin();
|
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.
|
* 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
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Access window via its name
|
/// Access window via its name
|
||||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
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.
|
* 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
|
.. code-block:: cpp
|
||||||
@ -103,11 +103,11 @@ Here is the general structure of the program:
|
|||||||
while(!sameWindow.wasStopped())
|
while(!sameWindow.wasStopped())
|
||||||
{
|
{
|
||||||
/// Interact with window
|
/// Interact with window
|
||||||
|
|
||||||
/// Event loop for 1 millisecond
|
/// Event loop for 1 millisecond
|
||||||
sameWindow.spinOnce(1, true);
|
sameWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Results
|
Results
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
float dummy1, dummy2;
|
float dummy1, dummy2;
|
||||||
for(size_t i = 0; i < 1889; ++i)
|
for(size_t i = 0; i < 1889; ++i)
|
||||||
ifs >> data[i].x >> data[i].y >> data[i].z >> dummy1 >> dummy2;
|
ifs >> data[i].x >> data[i].y >> data[i].z >> dummy1 >> dummy2;
|
||||||
|
|
||||||
cloud *= 5.0f;
|
cloud *= 5.0f;
|
||||||
return cloud;
|
return cloud;
|
||||||
}
|
}
|
||||||
@ -54,40 +54,40 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
* @function main
|
* @function main
|
||||||
*/
|
*/
|
||||||
int main(int argn, char **argv)
|
int main(int argn, char **argv)
|
||||||
{
|
{
|
||||||
if (argn < 2)
|
if (argn < 2)
|
||||||
{
|
{
|
||||||
cout << "Usage: " << endl << "./transformations [ G | C ]" << endl;
|
cout << "Usage: " << endl << "./transformations [ G | C ]" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool camera_pov = (argv[1][0] == 'C');
|
bool camera_pov = (argv[1][0] == 'C');
|
||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Coordinate Frame");
|
viz::Viz3d myWindow("Coordinate Frame");
|
||||||
|
|
||||||
/// Add coordinate axes
|
/// Add coordinate axes
|
||||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||||
|
|
||||||
/// Let's assume camera has the following properties
|
/// Let's assume camera has the following properties
|
||||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||||
|
|
||||||
/// We can get the pose of the cam using makeCameraPose
|
/// We can get the pose of the cam using makeCameraPose
|
||||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||||
|
|
||||||
/// We can get the transformation matrix from camera coordinate system to global using
|
/// We can get the transformation matrix from camera coordinate system to global using
|
||||||
/// - makeTransformToGlobal. We need the axes of the camera
|
/// - makeTransformToGlobal. We need the axes of the camera
|
||||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||||
|
|
||||||
/// Create a cloud widget.
|
/// Create a cloud widget.
|
||||||
Mat bunny_cloud = cvcloud_load();
|
Mat bunny_cloud = cvcloud_load();
|
||||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||||
|
|
||||||
/// Pose of the widget in camera frame
|
/// Pose of the widget in camera frame
|
||||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||||
/// Pose of the widget in global frame
|
/// Pose of the widget in global frame
|
||||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||||
|
|
||||||
/// Visualize camera frame
|
/// Visualize camera frame
|
||||||
if (!camera_pov)
|
if (!camera_pov)
|
||||||
{
|
{
|
||||||
@ -96,21 +96,21 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visualize widget
|
/// Visualize widget
|
||||||
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
||||||
|
|
||||||
/// Set the viewer pose to that of camera
|
/// Set the viewer pose to that of camera
|
||||||
if (camera_pov)
|
if (camera_pov)
|
||||||
myWindow.setViewerPose(cam_pose);
|
myWindow.setViewerPose(cam_pose);
|
||||||
|
|
||||||
/// Start event loop.
|
/// Start event loop.
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@ -122,17 +122,17 @@ Here is the general structure of the program:
|
|||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Transformations");
|
viz::Viz3d myWindow("Transformations");
|
||||||
|
|
||||||
* Get camera pose from camera position, camera focal point and y direction.
|
* Get camera pose from camera position, camera focal point and y direction.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Let's assume camera has the following properties
|
/// Let's assume camera has the following properties
|
||||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||||
|
|
||||||
/// We can get the pose of the cam using makeCameraPose
|
/// We can get the pose of the cam using makeCameraPose
|
||||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||||
|
|
||||||
* Obtain transform matrix knowing the axes of camera coordinate system.
|
* Obtain transform matrix knowing the axes of camera coordinate system.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -140,7 +140,7 @@ Here is the general structure of the program:
|
|||||||
/// We can get the transformation matrix from camera coordinate system to global using
|
/// We can get the transformation matrix from camera coordinate system to global using
|
||||||
/// - makeTransformToGlobal. We need the axes of the camera
|
/// - makeTransformToGlobal. We need the axes of the camera
|
||||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||||
|
|
||||||
* Create a cloud widget from bunny.ply file
|
* Create a cloud widget from bunny.ply file
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -148,16 +148,16 @@ Here is the general structure of the program:
|
|||||||
/// Create a cloud widget.
|
/// Create a cloud widget.
|
||||||
Mat bunny_cloud = cvcloud_load();
|
Mat bunny_cloud = cvcloud_load();
|
||||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||||
|
|
||||||
* Given the pose in camera coordinate system, estimate the global pose.
|
* Given the pose in camera coordinate system, estimate the global pose.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Pose of the widget in camera frame
|
/// Pose of the widget in camera frame
|
||||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||||
/// Pose of the widget in global frame
|
/// Pose of the widget in global frame
|
||||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||||
|
|
||||||
* If the view point is set to be global, visualize camera coordinate frame and viewing frustum.
|
* If the view point is set to be global, visualize camera coordinate frame and viewing frustum.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -170,22 +170,22 @@ Here is the general structure of the program:
|
|||||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
* Visualize the cloud widget with the estimated global pose
|
* Visualize the cloud widget with the estimated global pose
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Visualize widget
|
/// Visualize widget
|
||||||
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
||||||
|
|
||||||
* If the view point is set to be camera's, set viewer pose to **cam_pose**.
|
* If the view point is set to be camera's, set viewer pose to **cam_pose**.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Set the viewer pose to that of camera
|
/// Set the viewer pose to that of camera
|
||||||
if (camera_pov)
|
if (camera_pov)
|
||||||
myWindow.setViewerPose(cam_pose);
|
myWindow.setViewerPose(cam_pose);
|
||||||
|
|
||||||
Results
|
Results
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
@ -35,22 +35,22 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
{
|
{
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Coordinate Frame");
|
viz::Viz3d myWindow("Coordinate Frame");
|
||||||
|
|
||||||
/// Add coordinate axes
|
/// Add coordinate axes
|
||||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||||
|
|
||||||
/// Add line to represent (1,1,1) axis
|
/// Add line to represent (1,1,1) axis
|
||||||
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
||||||
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
myWindow.showWidget("Line Widget", axis);
|
myWindow.showWidget("Line Widget", axis);
|
||||||
|
|
||||||
/// Construct a cube widget
|
/// Construct a cube widget
|
||||||
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
||||||
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
|
|
||||||
/// Display widget (update if already displayed)
|
/// Display widget (update if already displayed)
|
||||||
myWindow.showWidget("Cube Widget", cube_widget);
|
myWindow.showWidget("Cube Widget", cube_widget);
|
||||||
|
|
||||||
/// Rodrigues vector
|
/// Rodrigues vector
|
||||||
Mat rot_vec = Mat::zeros(1,3,CV_32F);
|
Mat rot_vec = Mat::zeros(1,3,CV_32F);
|
||||||
float translation_phase = 0.0, translation = 0.0;
|
float translation_phase = 0.0, translation = 0.0;
|
||||||
@ -61,25 +61,25 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
|
|||||||
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
||||||
|
|
||||||
/// Shift on (1,1,1)
|
/// Shift on (1,1,1)
|
||||||
translation_phase += CV_PI * 0.01f;
|
translation_phase += CV_PI * 0.01f;
|
||||||
translation = sin(translation_phase);
|
translation = sin(translation_phase);
|
||||||
|
|
||||||
Mat rot_mat;
|
Mat rot_mat;
|
||||||
Rodrigues(rot_vec, rot_mat);
|
Rodrigues(rot_vec, rot_mat);
|
||||||
|
|
||||||
/// Construct pose
|
/// Construct pose
|
||||||
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
||||||
|
|
||||||
myWindow.setWidgetPose("Cube Widget", pose);
|
myWindow.setWidgetPose("Cube Widget", pose);
|
||||||
|
|
||||||
myWindow.spinOnce(1, true);
|
myWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@ -91,14 +91,14 @@ Here is the general structure of the program:
|
|||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Coordinate Frame");
|
viz::Viz3d myWindow("Coordinate Frame");
|
||||||
|
|
||||||
* Show coordinate axes in the window using CoordinateSystemWidget.
|
* Show coordinate axes in the window using CoordinateSystemWidget.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Add coordinate axes
|
/// Add coordinate axes
|
||||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||||
|
|
||||||
* Display a line representing the axis (1,1,1).
|
* Display a line representing the axis (1,1,1).
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -107,7 +107,7 @@ Here is the general structure of the program:
|
|||||||
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
||||||
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
myWindow.showWidget("Line Widget", axis);
|
myWindow.showWidget("Line Widget", axis);
|
||||||
|
|
||||||
* Construct a cube.
|
* Construct a cube.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -115,8 +115,8 @@ Here is the general structure of the program:
|
|||||||
/// Construct a cube widget
|
/// Construct a cube widget
|
||||||
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
||||||
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
myWindow.showWidget("Cube Widget", cube_widget);
|
myWindow.showWidget("Cube Widget", cube_widget);
|
||||||
|
|
||||||
* Create rotation matrix from rodrigues vector
|
* Create rotation matrix from rodrigues vector
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -125,20 +125,20 @@ Here is the general structure of the program:
|
|||||||
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
Mat rot_mat;
|
|
||||||
Rodrigues(rot_vec, rot_mat);
|
|
||||||
|
|
||||||
* Use Affine3f to set pose of the cube.
|
...
|
||||||
|
|
||||||
|
Mat rot_mat;
|
||||||
|
Rodrigues(rot_vec, rot_mat);
|
||||||
|
|
||||||
|
* Use Affine3f to set pose of the cube.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// Construct pose
|
/// Construct pose
|
||||||
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
||||||
myWindow.setWidgetPose("Cube Widget", pose);
|
myWindow.setWidgetPose("Cube Widget", pose);
|
||||||
|
|
||||||
* Animate the rotation using wasStopped and spinOnce
|
* Animate the rotation using wasStopped and spinOnce
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -146,10 +146,10 @@ Here is the general structure of the program:
|
|||||||
while(!myWindow.wasStopped())
|
while(!myWindow.wasStopped())
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
|
|
||||||
myWindow.spinOnce(1, true);
|
myWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Results
|
Results
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ macro(find_qvtk)
|
|||||||
find_path (QVTK_INCLUDE_DIR QVTKWidget.h HINT ${VTK_INCLUDE_DIRS})
|
find_path (QVTK_INCLUDE_DIR QVTKWidget.h HINT ${VTK_INCLUDE_DIRS})
|
||||||
find_package_handle_standard_args(QVTK DEFAULT_MSG QVTK_LIBRARY QVTK_INCLUDE_DIR)
|
find_package_handle_standard_args(QVTK DEFAULT_MSG QVTK_LIBRARY QVTK_INCLUDE_DIR)
|
||||||
|
|
||||||
if(QVTK_FOUND)
|
if(QVTK_FOUND)
|
||||||
get_filename_component (QVTK_LIBRARY_DIR ${QVTK_LIBRARY} PATH)
|
get_filename_component (QVTK_LIBRARY_DIR ${QVTK_LIBRARY} PATH)
|
||||||
list(APPEND VTK_LIBRARY_DIRS ${QVTK_LIBRARY_DIR})
|
list(APPEND VTK_LIBRARY_DIRS ${QVTK_LIBRARY_DIR})
|
||||||
list(APPEND VTK_INCLUDE_DIRS ${QVTK_INCLUDE_DIR})
|
list(APPEND VTK_INCLUDE_DIRS ${QVTK_INCLUDE_DIR})
|
||||||
@ -22,7 +22,7 @@ macro(find_vtk)
|
|||||||
message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARY_DIRS})")
|
message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARY_DIRS})")
|
||||||
link_directories(${VTK_LIBRARY_DIRS})
|
link_directories(${VTK_LIBRARY_DIRS})
|
||||||
include_directories(SYSTEM ${VTK_INCLUDE_DIRS})
|
include_directories(SYSTEM ${VTK_INCLUDE_DIRS})
|
||||||
set(HAVE_VTK ON)
|
set(HAVE_VTK ON)
|
||||||
else ()
|
else ()
|
||||||
set(HAVE_VTK OFF)
|
set(HAVE_VTK OFF)
|
||||||
message (FATAL_ERROR "VTK disabled. You are to build OpenCV in STATIC but VTK is SHARED!")
|
message (FATAL_ERROR "VTK disabled. You are to build OpenCV in STATIC but VTK is SHARED!")
|
||||||
@ -39,7 +39,7 @@ if(DEFINED HAVE_VTK AND HAVE_VTK)
|
|||||||
include (${VTK_USE_FILE})
|
include (${VTK_USE_FILE})
|
||||||
add_definitions(-DHAVE_VTK)
|
add_definitions(-DHAVE_VTK)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(the_description "Viz")
|
set(the_description "Viz")
|
||||||
set(BUILD_opencv_viz_INIT OFF)
|
set(BUILD_opencv_viz_INIT OFF)
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
|
@ -4,6 +4,6 @@ viz. 3D Visualizer
|
|||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
viz3d.rst
|
viz3d.rst
|
||||||
widget.rst
|
widget.rst
|
||||||
|
@ -4,7 +4,7 @@ Viz
|
|||||||
.. highlight:: cpp
|
.. highlight:: cpp
|
||||||
|
|
||||||
This section describes 3D visualization window as well as classes and methods
|
This section describes 3D visualization window as well as classes and methods
|
||||||
that are used to interact with it.
|
that are used to interact with it.
|
||||||
|
|
||||||
3D visualization window (see :ocv:class:`Viz3d`) is used to display widgets (see :ocv:class:`Widget`), and it provides
|
3D visualization window (see :ocv:class:`Viz3d`) is used to display widgets (see :ocv:class:`Widget`), and it provides
|
||||||
several methods to interact with scene and widgets.
|
several methods to interact with scene and widgets.
|
||||||
@ -21,17 +21,17 @@ Takes coordinate frame data and builds transform to global coordinate frame.
|
|||||||
:param origin: Origin of the coordinate frame in global coordinate frame.
|
:param origin: Origin of the coordinate frame in global coordinate frame.
|
||||||
|
|
||||||
This function returns affine transform that describes transformation between global coordinate frame and a given coordinate frame.
|
This function returns affine transform that describes transformation between global coordinate frame and a given coordinate frame.
|
||||||
|
|
||||||
viz::makeCameraPose
|
viz::makeCameraPose
|
||||||
-------------------
|
-------------------
|
||||||
Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation).
|
Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation).
|
||||||
|
|
||||||
.. ocv:function:: Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& y_dir)
|
.. ocv:function:: Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& y_dir)
|
||||||
|
|
||||||
:param position: Position of the camera in global coordinate frame.
|
:param position: Position of the camera in global coordinate frame.
|
||||||
:param focal_point: Focal point of the camera in global coordinate frame.
|
:param focal_point: Focal point of the camera in global coordinate frame.
|
||||||
:param y_dir: Up vector of the camera in global coordinate frame.
|
:param y_dir: Up vector of the camera in global coordinate frame.
|
||||||
|
|
||||||
This function returns pose of the camera in global coordinate frame.
|
This function returns pose of the camera in global coordinate frame.
|
||||||
|
|
||||||
viz::get
|
viz::get
|
||||||
@ -41,15 +41,15 @@ Retrieves a window by its name.
|
|||||||
.. ocv:function:: Viz3d get(const String &window_name)
|
.. ocv:function:: Viz3d get(const String &window_name)
|
||||||
|
|
||||||
:param window_name: Name of the window that is to be retrieved.
|
:param window_name: Name of the window that is to be retrieved.
|
||||||
|
|
||||||
This function returns a :ocv:class:`Viz3d` object with the given name.
|
This function returns a :ocv:class:`Viz3d` object with the given name.
|
||||||
|
|
||||||
.. note:: If the window with that name already exists, that window is returned. Otherwise, new window is created with the given name, and it is returned.
|
.. note:: If the window with that name already exists, that window is returned. Otherwise, new window is created with the given name, and it is returned.
|
||||||
|
|
||||||
.. note:: Window names are automatically prefixed by "Viz - " if it is not done by the user.
|
.. note:: Window names are automatically prefixed by "Viz - " if it is not done by the user.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// window and window_2 are the same windows.
|
/// window and window_2 are the same windows.
|
||||||
viz::Viz3d window = viz::get("myWindow");
|
viz::Viz3d window = viz::get("myWindow");
|
||||||
viz::Viz3d window_2 = viz::get("Viz - myWindow");
|
viz::Viz3d window_2 = viz::get("Viz - myWindow");
|
||||||
@ -75,7 +75,7 @@ Checks **point** for nan
|
|||||||
.. ocv:function:: bool isNan(const Point3_<_Tp>& p)
|
.. ocv:function:: bool isNan(const Point3_<_Tp>& p)
|
||||||
|
|
||||||
:param p: return true if **any** of the elements of the point is *nan*.
|
:param p: return true if **any** of the elements of the point is *nan*.
|
||||||
|
|
||||||
viz::VizAccessor
|
viz::VizAccessor
|
||||||
----------------
|
----------------
|
||||||
.. ocv:class:: VizAccessor
|
.. ocv:class:: VizAccessor
|
||||||
@ -87,16 +87,16 @@ A singleton class that provides access by name infrastructure for 3D visualizati
|
|||||||
public:
|
public:
|
||||||
static VizAccessor & getInstance();
|
static VizAccessor & getInstance();
|
||||||
static void release();
|
static void release();
|
||||||
|
|
||||||
Viz3d get(const String &window_name);
|
Viz3d get(const String &window_name);
|
||||||
|
|
||||||
//! window names automatically have Viz - prefix even though not provided by the users
|
//! window names automatically have Viz - prefix even though not provided by the users
|
||||||
static void generateWindowName(const String &window_name, String &output);
|
static void generateWindowName(const String &window_name, String &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::VizAccessor::getInstance
|
viz::VizAccessor::getInstance
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Returns the single instance of VizAccessor.
|
Returns the single instance of VizAccessor.
|
||||||
@ -116,15 +116,15 @@ Retrieves a window by its name.
|
|||||||
.. ocv:function:: Viz3d get(const String &window_name)
|
.. ocv:function:: Viz3d get(const String &window_name)
|
||||||
|
|
||||||
:param window_name: Name of the window that is to be retrieved.
|
:param window_name: Name of the window that is to be retrieved.
|
||||||
|
|
||||||
This function returns a :ocv:class:`Viz3d` object with the given name.
|
This function returns a :ocv:class:`Viz3d` object with the given name.
|
||||||
|
|
||||||
.. note:: If the window with that name already exists, that window is returned. Otherwise, new window is created with the given name, and it is returned.
|
.. note:: If the window with that name already exists, that window is returned. Otherwise, new window is created with the given name, and it is returned.
|
||||||
|
|
||||||
.. note:: Window names are automatically prefixed by "Viz - " if it is not done by the user.
|
.. note:: Window names are automatically prefixed by "Viz - " if it is not done by the user.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
/// window and window_2 are the same windows.
|
/// window and window_2 are the same windows.
|
||||||
viz::Viz3d window = viz::get("myWindow");
|
viz::Viz3d window = viz::get("myWindow");
|
||||||
viz::Viz3d window_2 = viz::get("Viz - myWindow");
|
viz::Viz3d window_2 = viz::get("Viz - myWindow");
|
||||||
@ -134,7 +134,7 @@ viz::VizAccessor::generateWindowName
|
|||||||
Generates a window name by prefixing "Viz - " if it has not already been prefixed.
|
Generates a window name by prefixing "Viz - " if it has not already been prefixed.
|
||||||
|
|
||||||
.. ocv:function:: static void generateWindowName(const String &window_name, String &output)
|
.. ocv:function:: static void generateWindowName(const String &window_name, String &output)
|
||||||
|
|
||||||
:param window_name: Window name
|
:param window_name: Window name
|
||||||
:param output: Prefixed window name
|
:param output: Prefixed window name
|
||||||
|
|
||||||
@ -164,18 +164,18 @@ The Viz3d class represents a 3D visualizer window. This class is implicitly shar
|
|||||||
void setWidgetPose(const String &id, const Affine3f &pose);
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
|
||||||
void setCamera(const Camera &camera);
|
void setCamera(const Camera &camera);
|
||||||
Camera getCamera() const;
|
Camera getCamera() const;
|
||||||
Affine3f getViewerPose();
|
Affine3f getViewerPose();
|
||||||
void setViewerPose(const Affine3f &pose);
|
void setViewerPose(const Affine3f &pose);
|
||||||
|
|
||||||
void resetCameraViewpoint (const String &id);
|
void resetCameraViewpoint (const String &id);
|
||||||
void resetCamera();
|
void resetCamera();
|
||||||
|
|
||||||
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
|
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
|
||||||
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
|
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
|
||||||
|
|
||||||
Size getWindowSize() const;
|
Size getWindowSize() const;
|
||||||
void setWindowSize(const Size &window_size);
|
void setWindowSize(const Size &window_size);
|
||||||
String getWindowName() const;
|
String getWindowName() const;
|
||||||
@ -190,13 +190,13 @@ The Viz3d class represents a 3D visualizer window. This class is implicitly shar
|
|||||||
|
|
||||||
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
|
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
|
||||||
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
|
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
|
||||||
|
|
||||||
void setRenderingProperty(const String &id, int property, double value);
|
void setRenderingProperty(const String &id, int property, double value);
|
||||||
double getRenderingProperty(const String &id, int property);
|
double getRenderingProperty(const String &id, int property);
|
||||||
|
|
||||||
void setDesiredUpdateRate(double rate);
|
void setDesiredUpdateRate(double rate);
|
||||||
double getDesiredUpdateRate();
|
double getDesiredUpdateRate();
|
||||||
|
|
||||||
void setRepresentation(int representation);
|
void setRepresentation(int representation);
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
@ -219,7 +219,7 @@ Shows a widget in the window.
|
|||||||
:param id: A unique id for the widget.
|
:param id: A unique id for the widget.
|
||||||
:param widget: The widget to be displayed in the window.
|
:param widget: The widget to be displayed in the window.
|
||||||
:param pose: Pose of the widget.
|
:param pose: Pose of the widget.
|
||||||
|
|
||||||
viz::Viz3d::removeWidget
|
viz::Viz3d::removeWidget
|
||||||
------------------------
|
------------------------
|
||||||
Removes a widget from the window.
|
Removes a widget from the window.
|
||||||
@ -227,17 +227,17 @@ Removes a widget from the window.
|
|||||||
.. ocv:function:: void removeWidget(const String &id)
|
.. ocv:function:: void removeWidget(const String &id)
|
||||||
|
|
||||||
:param id: The id of the widget that will be removed.
|
:param id: The id of the widget that will be removed.
|
||||||
|
|
||||||
viz::Viz3d::getWidget
|
viz::Viz3d::getWidget
|
||||||
---------------------
|
---------------------
|
||||||
Retrieves a widget from the window. A widget is implicitly shared;
|
Retrieves a widget from the window. A widget is implicitly shared;
|
||||||
that is, if the returned widget is modified, the changes will be
|
that is, if the returned widget is modified, the changes will be
|
||||||
immediately visible in the window.
|
immediately visible in the window.
|
||||||
|
|
||||||
.. ocv:function:: Widget getWidget(const String &id) const
|
.. ocv:function:: Widget getWidget(const String &id) const
|
||||||
|
|
||||||
:param id: The id of the widget that will be returned.
|
:param id: The id of the widget that will be returned.
|
||||||
|
|
||||||
viz::Viz3d::removeAllWidgets
|
viz::Viz3d::removeAllWidgets
|
||||||
----------------------------
|
----------------------------
|
||||||
Removes all widgets from the window.
|
Removes all widgets from the window.
|
||||||
@ -305,7 +305,7 @@ Resets camera viewpoint to a 3D widget in the scene.
|
|||||||
.. ocv:function:: void resetCameraViewpoint (const String &id)
|
.. ocv:function:: void resetCameraViewpoint (const String &id)
|
||||||
|
|
||||||
:param pose: Id of a 3D widget.
|
:param pose: Id of a 3D widget.
|
||||||
|
|
||||||
viz::Viz3d::resetCamera
|
viz::Viz3d::resetCamera
|
||||||
-----------------------
|
-----------------------
|
||||||
Resets camera.
|
Resets camera.
|
||||||
@ -320,7 +320,7 @@ Transforms a point in world coordinate system to window coordinate system.
|
|||||||
|
|
||||||
:param pt: Point in world coordinate system.
|
:param pt: Point in world coordinate system.
|
||||||
:param window_coord: Output point in window coordinate system.
|
:param window_coord: Output point in window coordinate system.
|
||||||
|
|
||||||
viz::Viz3d::converTo3DRay
|
viz::Viz3d::converTo3DRay
|
||||||
-------------------------
|
-------------------------
|
||||||
Transforms a point in window coordinate system to a 3D ray in world coordinate system.
|
Transforms a point in window coordinate system to a 3D ray in world coordinate system.
|
||||||
@ -330,7 +330,7 @@ Transforms a point in window coordinate system to a 3D ray in world coordinate s
|
|||||||
:param window_coord: Point in window coordinate system.
|
:param window_coord: Point in window coordinate system.
|
||||||
:param origin: Output origin of the ray.
|
:param origin: Output origin of the ray.
|
||||||
:param direction: Output direction of the ray.
|
:param direction: Output direction of the ray.
|
||||||
|
|
||||||
viz::Viz3d::getWindowSize
|
viz::Viz3d::getWindowSize
|
||||||
-------------------------
|
-------------------------
|
||||||
Returns the current size of the window.
|
Returns the current size of the window.
|
||||||
@ -344,7 +344,7 @@ Sets the size of the window.
|
|||||||
.. ocv:function:: void setWindowSize(const Size &window_size)
|
.. ocv:function:: void setWindowSize(const Size &window_size)
|
||||||
|
|
||||||
:param window_size: New size of the window.
|
:param window_size: New size of the window.
|
||||||
|
|
||||||
viz::Viz3d::getWindowName
|
viz::Viz3d::getWindowName
|
||||||
-------------------------
|
-------------------------
|
||||||
Returns the name of the window which has been set in the constructor.
|
Returns the name of the window which has been set in the constructor.
|
||||||
@ -358,7 +358,7 @@ Saves screenshot of the current scene.
|
|||||||
.. ocv:function:: void saveScreenshot(const String &file)
|
.. ocv:function:: void saveScreenshot(const String &file)
|
||||||
|
|
||||||
:param file: Name of the file.
|
:param file: Name of the file.
|
||||||
|
|
||||||
viz::Viz3d::setWindowPosition
|
viz::Viz3d::setWindowPosition
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Sets the position of the window in the screen.
|
Sets the position of the window in the screen.
|
||||||
@ -367,7 +367,7 @@ Sets the position of the window in the screen.
|
|||||||
|
|
||||||
:param x: x coordinate of the window
|
:param x: x coordinate of the window
|
||||||
:param y: y coordinate of the window
|
:param y: y coordinate of the window
|
||||||
|
|
||||||
viz::Viz3d::setFullScreen
|
viz::Viz3d::setFullScreen
|
||||||
-------------------------
|
-------------------------
|
||||||
Sets or unsets full-screen rendering mode.
|
Sets or unsets full-screen rendering mode.
|
||||||
@ -375,7 +375,7 @@ Sets or unsets full-screen rendering mode.
|
|||||||
.. ocv:function:: void setFullScreen(bool mode)
|
.. ocv:function:: void setFullScreen(bool mode)
|
||||||
|
|
||||||
:param mode: If true, window will use full-screen mode.
|
:param mode: If true, window will use full-screen mode.
|
||||||
|
|
||||||
viz::Viz3d::setBackgroundColor
|
viz::Viz3d::setBackgroundColor
|
||||||
------------------------------
|
------------------------------
|
||||||
Sets background color.
|
Sets background color.
|
||||||
@ -411,7 +411,7 @@ Sets keyboard handler.
|
|||||||
|
|
||||||
:param callback: Keyboard callback ``(void (*KeyboardCallbackFunction(const KeyboardEvent&, void*))``.
|
:param callback: Keyboard callback ``(void (*KeyboardCallbackFunction(const KeyboardEvent&, void*))``.
|
||||||
:param cookie: The optional parameter passed to the callback.
|
:param cookie: The optional parameter passed to the callback.
|
||||||
|
|
||||||
viz::Viz3d::registerMouseCallback
|
viz::Viz3d::registerMouseCallback
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Sets mouse handler.
|
Sets mouse handler.
|
||||||
@ -430,9 +430,9 @@ Sets rendering property of a widget.
|
|||||||
:param id: Id of the widget.
|
:param id: Id of the widget.
|
||||||
:param property: Property that will be modified.
|
:param property: Property that will be modified.
|
||||||
:param value: The new value of the property.
|
:param value: The new value of the property.
|
||||||
|
|
||||||
**Rendering property** can be one of the following:
|
**Rendering property** can be one of the following:
|
||||||
|
|
||||||
* **POINT_SIZE**
|
* **POINT_SIZE**
|
||||||
* **OPACITY**
|
* **OPACITY**
|
||||||
* **LINE_WIDTH**
|
* **LINE_WIDTH**
|
||||||
@ -441,14 +441,14 @@ Sets rendering property of a widget.
|
|||||||
* **REPRESENTATION_POINTS**
|
* **REPRESENTATION_POINTS**
|
||||||
* **REPRESENTATION_WIREFRAME**
|
* **REPRESENTATION_WIREFRAME**
|
||||||
* **REPRESENTATION_SURFACE**
|
* **REPRESENTATION_SURFACE**
|
||||||
* **IMMEDIATE_RENDERING**:
|
* **IMMEDIATE_RENDERING**:
|
||||||
* Turn on immediate rendering by setting the value to ``1``.
|
* Turn on immediate rendering by setting the value to ``1``.
|
||||||
* Turn off immediate rendering by setting the value to ``0``.
|
* Turn off immediate rendering by setting the value to ``0``.
|
||||||
* **SHADING**: Expected values are
|
* **SHADING**: Expected values are
|
||||||
* **SHADING_FLAT**
|
* **SHADING_FLAT**
|
||||||
* **SHADING_GOURAUD**
|
* **SHADING_GOURAUD**
|
||||||
* **SHADING_PHONG**
|
* **SHADING_PHONG**
|
||||||
|
|
||||||
viz::Viz3d::getRenderingProperty
|
viz::Viz3d::getRenderingProperty
|
||||||
--------------------------------
|
--------------------------------
|
||||||
Returns rendering property of a widget.
|
Returns rendering property of a widget.
|
||||||
@ -457,9 +457,9 @@ Returns rendering property of a widget.
|
|||||||
|
|
||||||
:param id: Id of the widget.
|
:param id: Id of the widget.
|
||||||
:param property: Property.
|
:param property: Property.
|
||||||
|
|
||||||
**Rendering property** can be one of the following:
|
**Rendering property** can be one of the following:
|
||||||
|
|
||||||
* **POINT_SIZE**
|
* **POINT_SIZE**
|
||||||
* **OPACITY**
|
* **OPACITY**
|
||||||
* **LINE_WIDTH**
|
* **LINE_WIDTH**
|
||||||
@ -468,7 +468,7 @@ Returns rendering property of a widget.
|
|||||||
* **REPRESENTATION_POINTS**
|
* **REPRESENTATION_POINTS**
|
||||||
* **REPRESENTATION_WIREFRAME**
|
* **REPRESENTATION_WIREFRAME**
|
||||||
* **REPRESENTATION_SURFACE**
|
* **REPRESENTATION_SURFACE**
|
||||||
* **IMMEDIATE_RENDERING**:
|
* **IMMEDIATE_RENDERING**:
|
||||||
* Turn on immediate rendering by setting the value to ``1``.
|
* Turn on immediate rendering by setting the value to ``1``.
|
||||||
* Turn off immediate rendering by setting the value to ``0``.
|
* Turn off immediate rendering by setting the value to ``0``.
|
||||||
* **SHADING**: Expected values are
|
* **SHADING**: Expected values are
|
||||||
@ -483,7 +483,7 @@ Sets desired update rate of the window.
|
|||||||
.. ocv:function:: void setDesiredUpdateRate(double rate)
|
.. ocv:function:: void setDesiredUpdateRate(double rate)
|
||||||
|
|
||||||
:param rate: Desired update rate. The default is 30.
|
:param rate: Desired update rate. The default is 30.
|
||||||
|
|
||||||
viz::Viz3d::getDesiredUpdateRate
|
viz::Viz3d::getDesiredUpdateRate
|
||||||
--------------------------------
|
--------------------------------
|
||||||
Returns desired update rate of the window.
|
Returns desired update rate of the window.
|
||||||
@ -497,11 +497,11 @@ Sets geometry representation of the widgets to surface, wireframe or points.
|
|||||||
.. ocv:function:: void setRepresentation(int representation)
|
.. ocv:function:: void setRepresentation(int representation)
|
||||||
|
|
||||||
:param representation: Geometry representation which can be one of the following:
|
:param representation: Geometry representation which can be one of the following:
|
||||||
|
|
||||||
* **REPRESENTATION_POINTS**
|
* **REPRESENTATION_POINTS**
|
||||||
* **REPRESENTATION_WIREFRAME**
|
* **REPRESENTATION_WIREFRAME**
|
||||||
* **REPRESENTATION_SURFACE**
|
* **REPRESENTATION_SURFACE**
|
||||||
|
|
||||||
viz::Color
|
viz::Color
|
||||||
----------
|
----------
|
||||||
.. ocv:class:: Color
|
.. ocv:class:: Color
|
||||||
@ -545,11 +545,11 @@ This class wraps mesh attributes, and it can load a mesh from a ``ply`` file. ::
|
|||||||
|
|
||||||
//! Loads mesh from a given ply file
|
//! Loads mesh from a given ply file
|
||||||
static Mesh3d loadMesh(const String& file);
|
static Mesh3d loadMesh(const String& file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::Mesh3d::loadMesh
|
viz::Mesh3d::loadMesh
|
||||||
---------------------
|
---------------------
|
||||||
Loads a mesh from a ``ply`` file.
|
Loads a mesh from a ``ply`` file.
|
||||||
@ -557,8 +557,8 @@ Loads a mesh from a ``ply`` file.
|
|||||||
.. ocv:function:: static Mesh3d loadMesh(const String& file)
|
.. ocv:function:: static Mesh3d loadMesh(const String& file)
|
||||||
|
|
||||||
:param file: File name.
|
:param file: File name.
|
||||||
|
|
||||||
|
|
||||||
viz::KeyboardEvent
|
viz::KeyboardEvent
|
||||||
------------------
|
------------------
|
||||||
.. ocv:class:: KeyboardEvent
|
.. ocv:class:: KeyboardEvent
|
||||||
@ -602,7 +602,7 @@ Constructs a KeyboardEvent.
|
|||||||
:param alt: If true, ``alt`` is pressed.
|
:param alt: If true, ``alt`` is pressed.
|
||||||
:param ctrl: If true, ``ctrl`` is pressed.
|
:param ctrl: If true, ``ctrl`` is pressed.
|
||||||
:param shift: If true, ``shift`` is pressed.
|
:param shift: If true, ``shift`` is pressed.
|
||||||
|
|
||||||
viz::MouseEvent
|
viz::MouseEvent
|
||||||
---------------
|
---------------
|
||||||
.. ocv:class:: MouseEvent
|
.. ocv:class:: MouseEvent
|
||||||
@ -622,7 +622,7 @@ This class represents a mouse event. ::
|
|||||||
Point pointer;
|
Point pointer;
|
||||||
unsigned int key_state;
|
unsigned int key_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::MouseEvent::MouseEvent
|
viz::MouseEvent::MouseEvent
|
||||||
---------------------------
|
---------------------------
|
||||||
Constructs a MouseEvent.
|
Constructs a MouseEvent.
|
||||||
@ -635,7 +635,7 @@ Constructs a MouseEvent.
|
|||||||
:param alt: If true, ``alt`` is pressed.
|
:param alt: If true, ``alt`` is pressed.
|
||||||
:param ctrl: If true, ``ctrl`` is pressed.
|
:param ctrl: If true, ``ctrl`` is pressed.
|
||||||
:param shift: If true, ``shift`` is pressed.
|
:param shift: If true, ``shift`` is pressed.
|
||||||
|
|
||||||
viz::Camera
|
viz::Camera
|
||||||
-----------
|
-----------
|
||||||
.. ocv:class:: Camera
|
.. ocv:class:: Camera
|
||||||
@ -651,23 +651,23 @@ that can extract the intrinsic parameters from ``field of view``, ``intrinsic ma
|
|||||||
Camera(const Vec2f &fov, const Size &window_size);
|
Camera(const Vec2f &fov, const Size &window_size);
|
||||||
Camera(const cv::Matx33f &K, const Size &window_size);
|
Camera(const cv::Matx33f &K, const Size &window_size);
|
||||||
Camera(const cv::Matx44f &proj, const Size &window_size);
|
Camera(const cv::Matx44f &proj, const Size &window_size);
|
||||||
|
|
||||||
inline const Vec2d & getClip() const { return clip_; }
|
inline const Vec2d & getClip() const { return clip_; }
|
||||||
inline void setClip(const Vec2d &clip) { clip_ = clip; }
|
inline void setClip(const Vec2d &clip) { clip_ = clip; }
|
||||||
|
|
||||||
inline const Size & getWindowSize() const { return window_size_; }
|
inline const Size & getWindowSize() const { return window_size_; }
|
||||||
void setWindowSize(const Size &window_size);
|
void setWindowSize(const Size &window_size);
|
||||||
|
|
||||||
inline const Vec2f & getFov() const { return fov_; }
|
inline const Vec2f & getFov() const { return fov_; }
|
||||||
inline void setFov(const Vec2f & fov) { fov_ = fov; }
|
inline void setFov(const Vec2f & fov) { fov_ = fov; }
|
||||||
|
|
||||||
inline const Vec2f & getPrincipalPoint() const { return principal_point_; }
|
inline const Vec2f & getPrincipalPoint() const { return principal_point_; }
|
||||||
inline const Vec2f & getFocalLength() const { return focal_; }
|
inline const Vec2f & getFocalLength() const { return focal_; }
|
||||||
|
|
||||||
void computeProjectionMatrix(Matx44f &proj) const;
|
void computeProjectionMatrix(Matx44f &proj) const;
|
||||||
|
|
||||||
static Camera KinectCamera(const Size &window_size);
|
static Camera KinectCamera(const Size &window_size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
@ -690,7 +690,7 @@ Constructs a Camera.
|
|||||||
:param window_size: Size of the window.
|
:param window_size: Size of the window.
|
||||||
|
|
||||||
Principal point is at the center of the window by default.
|
Principal point is at the center of the window by default.
|
||||||
|
|
||||||
.. ocv:function:: Camera(const cv::Matx33f &K, const Size &window_size)
|
.. ocv:function:: Camera(const cv::Matx33f &K, const Size &window_size)
|
||||||
|
|
||||||
:param K: Intrinsic matrix of the camera.
|
:param K: Intrinsic matrix of the camera.
|
||||||
@ -708,7 +708,7 @@ Computes projection matrix using intrinsic parameters of the camera.
|
|||||||
.. ocv:function:: void computeProjectionMatrix(Matx44f &proj) const
|
.. ocv:function:: void computeProjectionMatrix(Matx44f &proj) const
|
||||||
|
|
||||||
:param proj: Output projection matrix.
|
:param proj: Output projection matrix.
|
||||||
|
|
||||||
viz::Camera::KinectCamera
|
viz::Camera::KinectCamera
|
||||||
-------------------------
|
-------------------------
|
||||||
Creates a Kinect Camera.
|
Creates a Kinect Camera.
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
Widget
|
Widget
|
||||||
======
|
======
|
||||||
|
|
||||||
.. highlight:: cpp
|
.. highlight:: cpp
|
||||||
|
|
||||||
In this section, the widget framework is explained. Widgets represent
|
In this section, the widget framework is explained. Widgets represent
|
||||||
2D or 3D objects, varying from simple ones such as lines to complex one such as
|
2D or 3D objects, varying from simple ones such as lines to complex one such as
|
||||||
point clouds and meshes.
|
point clouds and meshes.
|
||||||
|
|
||||||
Widgets are **implicitly shared**. Therefore, one can add a widget to the scene,
|
Widgets are **implicitly shared**. Therefore, one can add a widget to the scene,
|
||||||
and modify the widget without re-adding the widget.
|
and modify the widget without re-adding the widget.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -34,10 +34,10 @@ Base class of all widgets. Widget is implicitly shared. ::
|
|||||||
Widget(const Widget& other);
|
Widget(const Widget& other);
|
||||||
Widget& operator=(const Widget& other);
|
Widget& operator=(const Widget& other);
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
||||||
//! Create a widget directly from ply file
|
//! Create a widget directly from ply file
|
||||||
static Widget fromPlyFile(const String &file_name);
|
static Widget fromPlyFile(const String &file_name);
|
||||||
|
|
||||||
//! Rendering properties of this particular widget
|
//! Rendering properties of this particular widget
|
||||||
void setRenderingProperty(int property, double value);
|
void setRenderingProperty(int property, double value);
|
||||||
double getRenderingProperty(int property) const;
|
double getRenderingProperty(int property) const;
|
||||||
@ -55,7 +55,7 @@ Creates a widget from ply file.
|
|||||||
.. ocv:function:: static Widget fromPlyFile(const String &file_name)
|
.. ocv:function:: static Widget fromPlyFile(const String &file_name)
|
||||||
|
|
||||||
:param file_name: Ply file name.
|
:param file_name: Ply file name.
|
||||||
|
|
||||||
viz::Widget::setRenderingProperty
|
viz::Widget::setRenderingProperty
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Sets rendering property of the widget.
|
Sets rendering property of the widget.
|
||||||
@ -64,9 +64,9 @@ Sets rendering property of the widget.
|
|||||||
|
|
||||||
:param property: Property that will be modified.
|
:param property: Property that will be modified.
|
||||||
:param value: The new value of the property.
|
:param value: The new value of the property.
|
||||||
|
|
||||||
**Rendering property** can be one of the following:
|
**Rendering property** can be one of the following:
|
||||||
|
|
||||||
* **POINT_SIZE**
|
* **POINT_SIZE**
|
||||||
* **OPACITY**
|
* **OPACITY**
|
||||||
* **LINE_WIDTH**
|
* **LINE_WIDTH**
|
||||||
@ -75,14 +75,14 @@ Sets rendering property of the widget.
|
|||||||
* **REPRESENTATION_POINTS**
|
* **REPRESENTATION_POINTS**
|
||||||
* **REPRESENTATION_WIREFRAME**
|
* **REPRESENTATION_WIREFRAME**
|
||||||
* **REPRESENTATION_SURFACE**
|
* **REPRESENTATION_SURFACE**
|
||||||
* **IMMEDIATE_RENDERING**:
|
* **IMMEDIATE_RENDERING**:
|
||||||
* Turn on immediate rendering by setting the value to ``1``.
|
* Turn on immediate rendering by setting the value to ``1``.
|
||||||
* Turn off immediate rendering by setting the value to ``0``.
|
* Turn off immediate rendering by setting the value to ``0``.
|
||||||
* **SHADING**: Expected values are
|
* **SHADING**: Expected values are
|
||||||
* **SHADING_FLAT**
|
* **SHADING_FLAT**
|
||||||
* **SHADING_GOURAUD**
|
* **SHADING_GOURAUD**
|
||||||
* **SHADING_PHONG**
|
* **SHADING_PHONG**
|
||||||
|
|
||||||
viz::Widget::getRenderingProperty
|
viz::Widget::getRenderingProperty
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Returns rendering property of the widget.
|
Returns rendering property of the widget.
|
||||||
@ -90,9 +90,9 @@ Returns rendering property of the widget.
|
|||||||
.. ocv:function:: double getRenderingProperty(int property) const
|
.. ocv:function:: double getRenderingProperty(int property) const
|
||||||
|
|
||||||
:param property: Property.
|
:param property: Property.
|
||||||
|
|
||||||
**Rendering property** can be one of the following:
|
**Rendering property** can be one of the following:
|
||||||
|
|
||||||
* **POINT_SIZE**
|
* **POINT_SIZE**
|
||||||
* **OPACITY**
|
* **OPACITY**
|
||||||
* **LINE_WIDTH**
|
* **LINE_WIDTH**
|
||||||
@ -101,14 +101,14 @@ Returns rendering property of the widget.
|
|||||||
* **REPRESENTATION_POINTS**
|
* **REPRESENTATION_POINTS**
|
||||||
* **REPRESENTATION_WIREFRAME**
|
* **REPRESENTATION_WIREFRAME**
|
||||||
* **REPRESENTATION_SURFACE**
|
* **REPRESENTATION_SURFACE**
|
||||||
* **IMMEDIATE_RENDERING**:
|
* **IMMEDIATE_RENDERING**:
|
||||||
* Turn on immediate rendering by setting the value to ``1``.
|
* Turn on immediate rendering by setting the value to ``1``.
|
||||||
* Turn off immediate rendering by setting the value to ``0``.
|
* Turn off immediate rendering by setting the value to ``0``.
|
||||||
* **SHADING**: Expected values are
|
* **SHADING**: Expected values are
|
||||||
* **SHADING_FLAT**
|
* **SHADING_FLAT**
|
||||||
* **SHADING_GOURAUD**
|
* **SHADING_GOURAUD**
|
||||||
* **SHADING_PHONG**
|
* **SHADING_PHONG**
|
||||||
|
|
||||||
viz::Widget::cast
|
viz::Widget::cast
|
||||||
-----------------
|
-----------------
|
||||||
Casts a widget to another.
|
Casts a widget to another.
|
||||||
@ -135,7 +135,7 @@ This class is for users who want to develop their own widgets using VTK library
|
|||||||
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
|
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
|
||||||
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
|
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WidgetAccessor::getProp
|
viz::WidgetAccessor::getProp
|
||||||
----------------------------
|
----------------------------
|
||||||
Returns ``vtkProp`` of a given widget.
|
Returns ``vtkProp`` of a given widget.
|
||||||
@ -147,9 +147,9 @@ Returns ``vtkProp`` of a given widget.
|
|||||||
.. note:: vtkProp has to be down cast appropriately to be modified.
|
.. note:: vtkProp has to be down cast appropriately to be modified.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
vtkActor * actor = vtkActor::SafeDownCast(viz::WidgetAccessor::getProp(widget));
|
vtkActor * actor = vtkActor::SafeDownCast(viz::WidgetAccessor::getProp(widget));
|
||||||
|
|
||||||
viz::WidgetAccessor::setProp
|
viz::WidgetAccessor::setProp
|
||||||
----------------------------
|
----------------------------
|
||||||
Sets ``vtkProp`` of a given widget.
|
Sets ``vtkProp`` of a given widget.
|
||||||
@ -158,7 +158,7 @@ Sets ``vtkProp`` of a given widget.
|
|||||||
|
|
||||||
:param widget: Widget whose ``vtkProp`` is to be set.
|
:param widget: Widget whose ``vtkProp`` is to be set.
|
||||||
:param prop: A ``vtkProp``.
|
:param prop: A ``vtkProp``.
|
||||||
|
|
||||||
viz::Widget3D
|
viz::Widget3D
|
||||||
-------------
|
-------------
|
||||||
.. ocv:class:: Widget3D
|
.. ocv:class:: Widget3D
|
||||||
@ -186,7 +186,7 @@ Sets pose of the widget.
|
|||||||
.. ocv:function:: void setPose(const Affine3f &pose)
|
.. ocv:function:: void setPose(const Affine3f &pose)
|
||||||
|
|
||||||
:param pose: The new pose of the widget.
|
:param pose: The new pose of the widget.
|
||||||
|
|
||||||
viz::Widget3D::updateWidgetPose
|
viz::Widget3D::updateWidgetPose
|
||||||
-------------------------------
|
-------------------------------
|
||||||
Updates pose of the widget by pre-multiplying its current pose.
|
Updates pose of the widget by pre-multiplying its current pose.
|
||||||
@ -207,8 +207,8 @@ Sets the color of the widget.
|
|||||||
|
|
||||||
.. ocv:function:: void setColor(const Color &color)
|
.. ocv:function:: void setColor(const Color &color)
|
||||||
|
|
||||||
:param color: color of type :ocv:class:`Color`
|
:param color: color of type :ocv:class:`Color`
|
||||||
|
|
||||||
viz::Widget2D
|
viz::Widget2D
|
||||||
-------------
|
-------------
|
||||||
.. ocv:class:: Widget2D
|
.. ocv:class:: Widget2D
|
||||||
@ -222,7 +222,7 @@ Base class of all 2D widgets. ::
|
|||||||
|
|
||||||
void setColor(const Color &color);
|
void setColor(const Color &color);
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::Widget2D::setColor
|
viz::Widget2D::setColor
|
||||||
-----------------------
|
-----------------------
|
||||||
Sets the color of the widget.
|
Sets the color of the widget.
|
||||||
@ -242,7 +242,7 @@ This 3D Widget defines a finite line. ::
|
|||||||
public:
|
public:
|
||||||
WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
|
WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WLine::WLine
|
viz::WLine::WLine
|
||||||
-----------------
|
-----------------
|
||||||
Constructs a WLine.
|
Constructs a WLine.
|
||||||
@ -252,7 +252,7 @@ Constructs a WLine.
|
|||||||
:param pt1: Start point of the line.
|
:param pt1: Start point of the line.
|
||||||
:param pt2: End point of the line.
|
:param pt2: End point of the line.
|
||||||
:param color: :ocv:class:`Color` of the line.
|
:param color: :ocv:class:`Color` of the line.
|
||||||
|
|
||||||
viz::WPlane
|
viz::WPlane
|
||||||
-----------
|
-----------
|
||||||
.. ocv:class:: WPlane
|
.. ocv:class:: WPlane
|
||||||
@ -267,13 +267,13 @@ This 3D Widget defines a finite plane. ::
|
|||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WPlane::WPlane
|
viz::WPlane::WPlane
|
||||||
-------------------
|
-------------------
|
||||||
Constructs a WPlane.
|
Constructs a WPlane.
|
||||||
|
|
||||||
.. ocv:function:: WPlane(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white())
|
.. ocv:function:: WPlane(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 coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0.
|
||||||
:param size: Size of the plane.
|
:param size: Size of the plane.
|
||||||
:param color: :ocv:class:`Color` of the plane.
|
:param color: :ocv:class:`Color` of the plane.
|
||||||
@ -284,7 +284,7 @@ Constructs a WPlane.
|
|||||||
:param pt: Position of the plane.
|
:param pt: Position of the plane.
|
||||||
:param size: Size of the plane.
|
:param size: Size of the plane.
|
||||||
:param color: :ocv:class:`Color` of the plane.
|
:param color: :ocv:class:`Color` of the plane.
|
||||||
|
|
||||||
viz::WSphere
|
viz::WSphere
|
||||||
------------
|
------------
|
||||||
.. ocv:class:: WSphere
|
.. ocv:class:: WSphere
|
||||||
@ -319,7 +319,7 @@ This 3D Widget defines an arrow. ::
|
|||||||
public:
|
public:
|
||||||
WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white());
|
WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WArrow::WArrow
|
viz::WArrow::WArrow
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Constructs an WArrow.
|
Constructs an WArrow.
|
||||||
@ -330,9 +330,9 @@ Constructs an WArrow.
|
|||||||
:param pt2: End 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 thickness: Thickness of the arrow. Thickness of arrow head is also adjusted accordingly.
|
||||||
:param color: :ocv:class:`Color` of the arrow.
|
:param color: :ocv:class:`Color` of the arrow.
|
||||||
|
|
||||||
Arrow head is located at the end point of the arrow.
|
Arrow head is located at the end point of the arrow.
|
||||||
|
|
||||||
viz::WCircle
|
viz::WCircle
|
||||||
-----------------
|
-----------------
|
||||||
.. ocv:class:: WCircle
|
.. ocv:class:: WCircle
|
||||||
@ -344,7 +344,7 @@ This 3D Widget defines a circle. ::
|
|||||||
public:
|
public:
|
||||||
WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCircle::WCircle
|
viz::WCircle::WCircle
|
||||||
-------------------------------
|
-------------------------------
|
||||||
Constructs a WCircle.
|
Constructs a WCircle.
|
||||||
@ -355,7 +355,7 @@ Constructs a WCircle.
|
|||||||
:param radius: Radius of the circle.
|
:param radius: Radius of the circle.
|
||||||
:param thickness: Thickness of the circle.
|
:param thickness: Thickness of the circle.
|
||||||
:param color: :ocv:class:`Color` of the circle.
|
:param color: :ocv:class:`Color` of the circle.
|
||||||
|
|
||||||
viz::WCylinder
|
viz::WCylinder
|
||||||
--------------
|
--------------
|
||||||
.. ocv:class:: WCylinder
|
.. ocv:class:: WCylinder
|
||||||
@ -379,7 +379,7 @@ Constructs a WCylinder.
|
|||||||
:param radius: Radius of the cylinder.
|
:param radius: Radius of the cylinder.
|
||||||
:param numsides: Resolution of the cylinder.
|
:param numsides: Resolution of the cylinder.
|
||||||
:param color: :ocv:class:`Color` of the cylinder.
|
:param color: :ocv:class:`Color` of the cylinder.
|
||||||
|
|
||||||
viz::WCube
|
viz::WCube
|
||||||
----------
|
----------
|
||||||
.. ocv:class:: WCube
|
.. ocv:class:: WCube
|
||||||
@ -391,7 +391,7 @@ This 3D Widget defines a cube. ::
|
|||||||
public:
|
public:
|
||||||
WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCube::WCube
|
viz::WCube::WCube
|
||||||
---------------------------
|
---------------------------
|
||||||
Constructs a WCube.
|
Constructs a WCube.
|
||||||
@ -402,11 +402,11 @@ Constructs a WCube.
|
|||||||
:param pt_max: Specifies maximum 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 wire_frame: If true, cube is represented as wireframe.
|
||||||
:param color: :ocv:class:`Color` of the cube.
|
:param color: :ocv:class:`Color` of the cube.
|
||||||
|
|
||||||
.. image:: images/cube_widget.png
|
.. image:: images/cube_widget.png
|
||||||
:alt: Cube Widget
|
:alt: Cube Widget
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
viz::WCoordinateSystem
|
viz::WCoordinateSystem
|
||||||
----------------------
|
----------------------
|
||||||
.. ocv:class:: WCoordinateSystem
|
.. ocv:class:: WCoordinateSystem
|
||||||
@ -418,7 +418,7 @@ This 3D Widget represents a coordinate system. ::
|
|||||||
public:
|
public:
|
||||||
WCoordinateSystem(double scale = 1.0);
|
WCoordinateSystem(double scale = 1.0);
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCoordinateSystem::WCoordinateSystem
|
viz::WCoordinateSystem::WCoordinateSystem
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
Constructs a WCoordinateSystem.
|
Constructs a WCoordinateSystem.
|
||||||
@ -426,7 +426,7 @@ Constructs a WCoordinateSystem.
|
|||||||
.. ocv:function:: WCoordinateSystem(double scale = 1.0)
|
.. ocv:function:: WCoordinateSystem(double scale = 1.0)
|
||||||
|
|
||||||
:param scale: Determines the size of the axes.
|
:param scale: Determines the size of the axes.
|
||||||
|
|
||||||
viz::WPolyLine
|
viz::WPolyLine
|
||||||
--------------
|
--------------
|
||||||
.. ocv:class:: WPolyLine
|
.. ocv:class:: WPolyLine
|
||||||
@ -447,10 +447,10 @@ viz::WPolyLine::WPolyLine
|
|||||||
Constructs a WPolyLine.
|
Constructs a WPolyLine.
|
||||||
|
|
||||||
.. ocv:function:: WPolyLine(InputArray points, const Color &color = Color::white())
|
.. ocv:function:: WPolyLine(InputArray points, const Color &color = Color::white())
|
||||||
|
|
||||||
:param points: Point set.
|
:param points: Point set.
|
||||||
:param color: :ocv:class:`Color` of the poly line.
|
:param color: :ocv:class:`Color` of the poly line.
|
||||||
|
|
||||||
viz::WGrid
|
viz::WGrid
|
||||||
----------
|
----------
|
||||||
.. ocv:class:: WGrid
|
.. ocv:class:: WGrid
|
||||||
@ -467,7 +467,7 @@ This 3D Widget defines a grid. ::
|
|||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WGrid::WGrid
|
viz::WGrid::WGrid
|
||||||
---------------------------
|
---------------------------
|
||||||
Constructs a WGrid.
|
Constructs a WGrid.
|
||||||
@ -477,14 +477,14 @@ Constructs a WGrid.
|
|||||||
:param dimensions: Number of columns and rows, respectively.
|
:param dimensions: Number of columns and rows, respectively.
|
||||||
:param spacing: Size of each column and row, respectively.
|
:param spacing: Size of each column and row, respectively.
|
||||||
:param color: :ocv:class:`Color` of the grid.
|
:param color: :ocv:class:`Color` of the grid.
|
||||||
|
|
||||||
.. ocv:function: WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white())
|
.. ocv:function: WGrid(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 coeffs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0.
|
||||||
:param dimensions: Number of columns and rows, respectively.
|
:param dimensions: Number of columns and rows, respectively.
|
||||||
:param spacing: Size of each column and row, respectively.
|
:param spacing: Size of each column and row, respectively.
|
||||||
:param color: :ocv:class:`Color` of the grid.
|
:param color: :ocv:class:`Color` of the grid.
|
||||||
|
|
||||||
viz::WText3D
|
viz::WText3D
|
||||||
------------
|
------------
|
||||||
.. ocv:class:: WText3D
|
.. ocv:class:: WText3D
|
||||||
@ -499,7 +499,7 @@ This 3D Widget represents 3D text. The text always faces the camera. ::
|
|||||||
void setText(const String &text);
|
void setText(const String &text);
|
||||||
String getText() const;
|
String getText() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WText3D::WText3D
|
viz::WText3D::WText3D
|
||||||
-------------------------------
|
-------------------------------
|
||||||
Constructs a WText3D.
|
Constructs a WText3D.
|
||||||
@ -511,7 +511,7 @@ Constructs a WText3D.
|
|||||||
:param text_scale: Size of the text.
|
:param text_scale: Size of the text.
|
||||||
:param face_camera: If true, text always faces the camera.
|
:param face_camera: If true, text always faces the camera.
|
||||||
:param color: :ocv:class:`Color` of the text.
|
:param color: :ocv:class:`Color` of the text.
|
||||||
|
|
||||||
viz::WText3D::setText
|
viz::WText3D::setText
|
||||||
---------------------
|
---------------------
|
||||||
Sets the text content of the widget.
|
Sets the text content of the widget.
|
||||||
@ -540,7 +540,7 @@ This 2D Widget represents text overlay. ::
|
|||||||
void setText(const String &text);
|
void setText(const String &text);
|
||||||
String getText() const;
|
String getText() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WText::WText
|
viz::WText::WText
|
||||||
-----------------
|
-----------------
|
||||||
Constructs a WText.
|
Constructs a WText.
|
||||||
@ -551,7 +551,7 @@ Constructs a WText.
|
|||||||
:param pos: Position of the text.
|
:param pos: Position of the text.
|
||||||
:param font_size: Font size.
|
:param font_size: Font size.
|
||||||
:param color: :ocv:class:`Color` of the text.
|
:param color: :ocv:class:`Color` of the text.
|
||||||
|
|
||||||
viz::WText::setText
|
viz::WText::setText
|
||||||
-------------------
|
-------------------
|
||||||
Sets the text content of the widget.
|
Sets the text content of the widget.
|
||||||
@ -576,10 +576,10 @@ This 2D Widget represents an image overlay. ::
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WImageOverlay(const Mat &image, const Rect &rect);
|
WImageOverlay(const Mat &image, const Rect &rect);
|
||||||
|
|
||||||
void setImage(const Mat &image);
|
void setImage(const Mat &image);
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WImageOverlay::WImageOverlay
|
viz::WImageOverlay::WImageOverlay
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Constructs an WImageOverlay.
|
Constructs an WImageOverlay.
|
||||||
@ -588,7 +588,7 @@ Constructs an WImageOverlay.
|
|||||||
|
|
||||||
:param image: BGR or Gray-Scale image.
|
:param image: BGR or Gray-Scale image.
|
||||||
:param rect: Image is scaled and positioned based on rect.
|
:param rect: Image is scaled and positioned based on rect.
|
||||||
|
|
||||||
viz::WImageOverlay::setImage
|
viz::WImageOverlay::setImage
|
||||||
----------------------------
|
----------------------------
|
||||||
Sets the image content of the widget.
|
Sets the image content of the widget.
|
||||||
@ -596,7 +596,7 @@ Sets the image content of the widget.
|
|||||||
.. ocv:function:: void setImage(const Mat &image)
|
.. ocv:function:: void setImage(const Mat &image)
|
||||||
|
|
||||||
:param image: BGR or Gray-Scale image.
|
:param image: BGR or Gray-Scale image.
|
||||||
|
|
||||||
viz::WImage3D
|
viz::WImage3D
|
||||||
-------------
|
-------------
|
||||||
.. ocv:class:: WImage3D
|
.. ocv:class:: WImage3D
|
||||||
@ -610,7 +610,7 @@ This 3D Widget represents an image in 3D space. ::
|
|||||||
WImage3D(const Mat &image, const Size &size);
|
WImage3D(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
|
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
|
||||||
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size);
|
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size);
|
||||||
|
|
||||||
void setImage(const Mat &image);
|
void setImage(const Mat &image);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -619,10 +619,10 @@ viz::WImage3D::WImage3D
|
|||||||
Constructs an WImage3D.
|
Constructs an WImage3D.
|
||||||
|
|
||||||
.. ocv:function:: WImage3D(const Mat &image, const Size &size)
|
.. ocv:function:: WImage3D(const Mat &image, const Size &size)
|
||||||
|
|
||||||
:param image: BGR or Gray-Scale image.
|
:param image: BGR or Gray-Scale image.
|
||||||
:param size: Size of the image.
|
:param size: Size of the image.
|
||||||
|
|
||||||
.. ocv:function:: WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size)
|
.. ocv:function:: WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size)
|
||||||
|
|
||||||
:param position: Position of the image.
|
:param position: Position of the image.
|
||||||
@ -630,7 +630,7 @@ Constructs an WImage3D.
|
|||||||
:param up_vector: Determines orientation of the image.
|
:param up_vector: Determines orientation of the image.
|
||||||
:param image: BGR or Gray-Scale image.
|
:param image: BGR or Gray-Scale image.
|
||||||
:param size: Size of the image.
|
:param size: Size of the image.
|
||||||
|
|
||||||
viz::WImage3D::setImage
|
viz::WImage3D::setImage
|
||||||
-----------------------
|
-----------------------
|
||||||
Sets the image content of the widget.
|
Sets the image content of the widget.
|
||||||
@ -638,7 +638,7 @@ Sets the image content of the widget.
|
|||||||
.. ocv:function:: void setImage(const Mat &image)
|
.. ocv:function:: void setImage(const Mat &image)
|
||||||
|
|
||||||
:param image: BGR or Gray-Scale image.
|
:param image: BGR or Gray-Scale image.
|
||||||
|
|
||||||
viz::WCameraPosition
|
viz::WCameraPosition
|
||||||
--------------------
|
--------------------
|
||||||
.. ocv:class:: WCameraPosition
|
.. ocv:class:: WCameraPosition
|
||||||
@ -659,7 +659,7 @@ This 3D Widget represents camera position in a scene by its axes or viewing frus
|
|||||||
//! Creates frustum and display given image at the far plane
|
//! Creates frustum and display given image at the far plane
|
||||||
WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCameraPosition::WCameraPosition
|
viz::WCameraPosition::WCameraPosition
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
Constructs a WCameraPosition.
|
Constructs a WCameraPosition.
|
||||||
@ -669,7 +669,7 @@ Constructs a WCameraPosition.
|
|||||||
.. ocv:function:: WCameraPosition(double scale = 1.0)
|
.. ocv:function:: WCameraPosition(double scale = 1.0)
|
||||||
|
|
||||||
Creates camera coordinate frame at the origin.
|
Creates camera coordinate frame at the origin.
|
||||||
|
|
||||||
.. image:: images/cpw1.png
|
.. image:: images/cpw1.png
|
||||||
:alt: Camera coordinate frame
|
:alt: Camera coordinate frame
|
||||||
:align: center
|
:align: center
|
||||||
@ -681,15 +681,15 @@ Constructs a WCameraPosition.
|
|||||||
:param K: Intrinsic matrix of the camera.
|
:param K: Intrinsic matrix of the camera.
|
||||||
:param scale: Scale of the frustum.
|
:param scale: Scale of the frustum.
|
||||||
:param color: :ocv:class:`Color` of the frustum.
|
:param color: :ocv:class:`Color` of the frustum.
|
||||||
|
|
||||||
Creates viewing frustum of the camera based on its intrinsic matrix K.
|
Creates viewing frustum of the camera based on its intrinsic matrix K.
|
||||||
|
|
||||||
.. ocv:function:: WCameraPosition(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white())
|
.. ocv:function:: WCameraPosition(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white())
|
||||||
|
|
||||||
:param fov: Field of view of the camera (horizontal, vertical).
|
:param fov: Field of view of the camera (horizontal, vertical).
|
||||||
:param scale: Scale of the frustum.
|
:param scale: Scale of the frustum.
|
||||||
:param color: :ocv:class:`Color` of the frustum.
|
:param color: :ocv:class:`Color` of the frustum.
|
||||||
|
|
||||||
Creates viewing frustum of the camera based on its field of view fov.
|
Creates viewing frustum of the camera based on its field of view fov.
|
||||||
|
|
||||||
.. image:: images/cpw2.png
|
.. image:: images/cpw2.png
|
||||||
@ -704,7 +704,7 @@ Constructs a WCameraPosition.
|
|||||||
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
|
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
|
||||||
:param scale: Scale of the frustum and image.
|
:param scale: Scale of the frustum and image.
|
||||||
:param color: :ocv:class:`Color` of the frustum.
|
:param color: :ocv:class:`Color` of the frustum.
|
||||||
|
|
||||||
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.
|
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.
|
||||||
|
|
||||||
.. ocv:function:: WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white())
|
.. ocv:function:: WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white())
|
||||||
@ -713,9 +713,9 @@ Constructs a WCameraPosition.
|
|||||||
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
|
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
|
||||||
:param scale: Scale of the frustum and image.
|
:param scale: Scale of the frustum and image.
|
||||||
:param color: :ocv:class:`Color` of the frustum.
|
:param color: :ocv:class:`Color` of the frustum.
|
||||||
|
|
||||||
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.
|
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.
|
||||||
|
|
||||||
.. image:: images/cpw3.png
|
.. image:: images/cpw3.png
|
||||||
:alt: Camera viewing frustum with image
|
:alt: Camera viewing frustum with image
|
||||||
:align: center
|
:align: center
|
||||||
@ -730,18 +730,18 @@ This 3D Widget represents a trajectory. ::
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2};
|
enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2};
|
||||||
|
|
||||||
//! Displays trajectory of the given path either by coordinate frames or polyline
|
//! Displays trajectory of the given path either by coordinate frames or polyline
|
||||||
WTrajectory(const std::vector<Affine3f> &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0);
|
WTrajectory(const std::vector<Affine3f> &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0);
|
||||||
//! Displays trajectory of the given path by frustums
|
//! Displays trajectory of the given path by frustums
|
||||||
WTrajectory(const std::vector<Affine3f> &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white());
|
WTrajectory(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
|
//! Displays trajectory of the given path by frustums
|
||||||
WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WTrajectory::WTrajectory
|
viz::WTrajectory::WTrajectory
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Constructs a WTrajectory.
|
Constructs a WTrajectory.
|
||||||
@ -752,29 +752,29 @@ Constructs a WTrajectory.
|
|||||||
:param display_mode: Display mode. This can be DISPLAY_PATH, DISPLAY_FRAMES, DISPLAY_PATH & DISPLAY_FRAMES.
|
:param display_mode: Display mode. This can be DISPLAY_PATH, DISPLAY_FRAMES, DISPLAY_PATH & DISPLAY_FRAMES.
|
||||||
:param color: :ocv:class:`Color` of the polyline that represents path. Frames are not affected.
|
:param color: :ocv:class:`Color` of the polyline that represents path. Frames are not affected.
|
||||||
:param scale: Scale of the frames. Polyline is not affected.
|
:param scale: Scale of the frames. Polyline is not affected.
|
||||||
|
|
||||||
Displays trajectory of the given path as follows:
|
Displays trajectory of the given path as follows:
|
||||||
|
|
||||||
* DISPLAY_PATH : Displays a poly line that represents the path.
|
* DISPLAY_PATH : Displays a poly line that represents the path.
|
||||||
* DISPLAY_FRAMES : Displays coordinate frames at each pose.
|
* DISPLAY_FRAMES : Displays coordinate frames at each pose.
|
||||||
* DISPLAY_PATH & DISPLAY_FRAMES : Displays both poly line and coordinate frames.
|
* DISPLAY_PATH & DISPLAY_FRAMES : Displays both poly line and coordinate frames.
|
||||||
|
|
||||||
.. ocv:function:: WTrajectory(const std::vector<Affine3f> &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white())
|
.. ocv:function:: WTrajectory(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 path: List of poses on a trajectory.
|
||||||
:param K: Intrinsic matrix of the camera.
|
:param K: Intrinsic matrix of the camera.
|
||||||
:param scale: Scale of the frustums.
|
:param scale: Scale of the frustums.
|
||||||
:param color: :ocv:class:`Color` of the frustums.
|
:param color: :ocv:class:`Color` of the frustums.
|
||||||
|
|
||||||
Displays frustums at each pose of the trajectory.
|
Displays frustums at each pose of the trajectory.
|
||||||
|
|
||||||
.. ocv:function:: WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white())
|
.. ocv:function:: WTrajectory(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 path: List of poses on a trajectory.
|
||||||
:param fov: Field of view of the camera (horizontal, vertical).
|
:param fov: Field of view of the camera (horizontal, vertical).
|
||||||
:param scale: Scale of the frustums.
|
:param scale: Scale of the frustums.
|
||||||
:param color: :ocv:class:`Color` of the frustums.
|
:param color: :ocv:class:`Color` of the frustums.
|
||||||
|
|
||||||
Displays frustums at each pose of the trajectory.
|
Displays frustums at each pose of the trajectory.
|
||||||
|
|
||||||
viz::WSpheresTrajectory
|
viz::WSpheresTrajectory
|
||||||
@ -787,24 +787,24 @@ represent the direction from previous position to the current. ::
|
|||||||
class CV_EXPORTS WSpheresTrajectory : public Widget3D
|
class CV_EXPORTS WSpheresTrajectory : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WSpheresTrajectory(const std::vector<Affine3f> &path, float line_length = 0.05f,
|
WSpheresTrajectory(const std::vector<Affine3f> &path, float line_length = 0.05f,
|
||||||
double init_sphere_radius = 0.021, sphere_radius = 0.007,
|
double init_sphere_radius = 0.021, sphere_radius = 0.007,
|
||||||
Color &line_color = Color::white(), const Color &sphere_color = Color::white());
|
Color &line_color = Color::white(), const Color &sphere_color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WSpheresTrajectory::WSpheresTrajectory
|
viz::WSpheresTrajectory::WSpheresTrajectory
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
Constructs a WSpheresTrajectory.
|
Constructs a WSpheresTrajectory.
|
||||||
|
|
||||||
.. ocv:function:: WSpheresTrajectory(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())
|
.. ocv:function:: WSpheresTrajectory(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 path: List of poses on a trajectory.
|
||||||
:param line_length: Length of the lines.
|
: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 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 sphere_radius: Radius of the rest of the spheres.
|
||||||
:param line_color: :ocv:class:`Color` of the lines.
|
:param line_color: :ocv:class:`Color` of the lines.
|
||||||
:param sphere_color: :ocv:class:`Color` of the spheres.
|
:param sphere_color: :ocv:class:`Color` of the spheres.
|
||||||
|
|
||||||
viz::WCloud
|
viz::WCloud
|
||||||
-----------
|
-----------
|
||||||
.. ocv:class:: WCloud
|
.. ocv:class:: WCloud
|
||||||
@ -822,7 +822,7 @@ This 3D Widget defines a point cloud. ::
|
|||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCloud::WCloud
|
viz::WCloud::WCloud
|
||||||
-------------------
|
-------------------
|
||||||
Constructs a WCloud.
|
Constructs a WCloud.
|
||||||
@ -831,16 +831,16 @@ Constructs a WCloud.
|
|||||||
|
|
||||||
:param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
|
:param cloud: Set of points 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 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).
|
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
||||||
|
|
||||||
.. ocv:function:: WCloud(InputArray cloud, const Color &color = Color::white())
|
.. ocv:function:: WCloud(InputArray cloud, const Color &color = Color::white())
|
||||||
|
|
||||||
:param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
|
:param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
|
||||||
:param color: A single :ocv:class:`Color` for the whole cloud.
|
:param color: A single :ocv:class:`Color` for the whole cloud.
|
||||||
|
|
||||||
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
||||||
|
|
||||||
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
||||||
|
|
||||||
viz::WCloudCollection
|
viz::WCloudCollection
|
||||||
@ -853,16 +853,16 @@ This 3D Widget defines a collection of clouds. ::
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WCloudCollection();
|
WCloudCollection();
|
||||||
|
|
||||||
//! Each point in cloud is mapped to a color in colors
|
//! Each point in cloud is mapped to a color in colors
|
||||||
void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity());
|
void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity());
|
||||||
//! All points in cloud have the same color
|
//! All points in cloud have the same color
|
||||||
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3f &pose = Affine3f::Identity());
|
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3f &pose = Affine3f::Identity());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCloudCollection::WCloudCollection
|
viz::WCloudCollection::WCloudCollection
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
Constructs a WCloudCollection.
|
Constructs a WCloudCollection.
|
||||||
@ -878,19 +878,19 @@ Adds a cloud to the collection.
|
|||||||
:param cloud: Point set which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
|
: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 colors: Set of colors. It has to be of the same size with cloud.
|
||||||
:param pose: Pose of the cloud.
|
:param pose: Pose of the cloud.
|
||||||
|
|
||||||
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
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())
|
.. 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 cloud: Point set which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
|
||||||
:param colors: A single :ocv:class:`Color` for the whole cloud.
|
:param colors: A single :ocv:class:`Color` for the whole cloud.
|
||||||
:param pose: Pose of the cloud.
|
:param pose: Pose of the cloud.
|
||||||
|
|
||||||
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
Points in the cloud belong to mask when they are set to (NaN, NaN, NaN).
|
||||||
|
|
||||||
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
||||||
|
|
||||||
viz::WCloudNormals
|
viz::WCloudNormals
|
||||||
------------------
|
------------------
|
||||||
.. ocv:class:: WCloudNormals
|
.. ocv:class:: WCloudNormals
|
||||||
@ -905,36 +905,36 @@ This 3D Widget represents normals of a point cloud. ::
|
|||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCloudNormals::WCloudNormals
|
viz::WCloudNormals::WCloudNormals
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Constructs a WCloudNormals.
|
Constructs a WCloudNormals.
|
||||||
|
|
||||||
.. ocv:function:: WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white())
|
.. ocv:function:: WCloudNormals(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 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 normals: A set of normals that has to be of same type with cloud.
|
||||||
:param level: Display only every ``level`` th normal.
|
:param level: Display only every ``level`` th normal.
|
||||||
:param scale: Scale of the arrows that represent normals.
|
:param scale: Scale of the arrows that represent normals.
|
||||||
:param color: :ocv:class:`Color` of the arrows that represent normals.
|
:param color: :ocv:class:`Color` of the arrows that represent normals.
|
||||||
|
|
||||||
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
||||||
|
|
||||||
viz::WMesh
|
viz::WMesh
|
||||||
----------
|
----------
|
||||||
.. ocv:class:: WMesh
|
.. ocv:class:: WMesh
|
||||||
|
|
||||||
This 3D Widget defines a mesh. ::
|
This 3D Widget defines a mesh. ::
|
||||||
|
|
||||||
class CV_EXPORTS WMesh : public Widget3D
|
class CV_EXPORTS WMesh : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WMesh(const Mesh3d &mesh);
|
WMesh(const Mesh3d &mesh);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* hidden */
|
/* hidden */
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WMesh::WMesh
|
viz::WMesh::WMesh
|
||||||
-----------------
|
-----------------
|
||||||
Constructs a WMesh.
|
Constructs a WMesh.
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
namespace viz
|
namespace viz
|
||||||
{
|
{
|
||||||
//! takes coordiante frame data and builds transfrom to global coordinate frame
|
//! takes coordiante frame data and builds transfrom to global coordinate frame
|
||||||
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
|
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
|
||||||
|
|
||||||
@ -87,32 +87,32 @@ namespace cv
|
|||||||
//! checks point for Nans
|
//! checks point for Nans
|
||||||
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
|
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
|
||||||
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
|
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
|
||||||
|
|
||||||
//! helper class that provides access by name infrastructure
|
//! helper class that provides access by name infrastructure
|
||||||
class CV_EXPORTS VizAccessor
|
class CV_EXPORTS VizAccessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static VizAccessor & getInstance();
|
static VizAccessor & getInstance();
|
||||||
static void release();
|
static void release();
|
||||||
|
|
||||||
Viz3d get(const String &window_name);
|
Viz3d get(const String &window_name);
|
||||||
|
|
||||||
//! window names automatically have Viz - prefix even though not provided by the users
|
//! window names automatically have Viz - prefix even though not provided by the users
|
||||||
static void generateWindowName(const String &window_name, String &output);
|
static void generateWindowName(const String &window_name, String &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VizAccessor(); // Singleton
|
VizAccessor(); // Singleton
|
||||||
~VizAccessor();
|
~VizAccessor();
|
||||||
|
|
||||||
void add(Viz3d window);
|
void add(Viz3d window);
|
||||||
void remove(const String &window_name);
|
void remove(const String &window_name);
|
||||||
|
|
||||||
static VizAccessor * instance_;
|
static VizAccessor * instance_;
|
||||||
static bool is_instantiated_;
|
static bool is_instantiated_;
|
||||||
|
|
||||||
struct VizAccessorImpl;
|
struct VizAccessorImpl;
|
||||||
static VizAccessorImpl * impl_;
|
static VizAccessorImpl * impl_;
|
||||||
|
|
||||||
friend class Viz3d;
|
friend class Viz3d;
|
||||||
};
|
};
|
||||||
} /* namespace viz */
|
} /* namespace viz */
|
||||||
|
@ -88,7 +88,7 @@ namespace cv
|
|||||||
|
|
||||||
//! Loads mesh from a given ply file
|
//! Loads mesh from a given ply file
|
||||||
static cv::viz::Mesh3d loadMesh(const String& file);
|
static cv::viz::Mesh3d loadMesh(const String& file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct loadMeshImpl;
|
struct loadMeshImpl;
|
||||||
};
|
};
|
||||||
@ -135,7 +135,7 @@ namespace cv
|
|||||||
Point pointer;
|
Point pointer;
|
||||||
unsigned int key_state;
|
unsigned int key_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS Camera
|
class CV_EXPORTS Camera
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -143,26 +143,26 @@ namespace cv
|
|||||||
Camera(const Vec2f &fov, const Size &window_size);
|
Camera(const Vec2f &fov, const Size &window_size);
|
||||||
Camera(const cv::Matx33f &K, const Size &window_size);
|
Camera(const cv::Matx33f &K, const Size &window_size);
|
||||||
Camera(const cv::Matx44f &proj, const Size &window_size);
|
Camera(const cv::Matx44f &proj, const Size &window_size);
|
||||||
|
|
||||||
inline const Vec2d & getClip() const { return clip_; }
|
inline const Vec2d & getClip() const { return clip_; }
|
||||||
inline void setClip(const Vec2d &clip) { clip_ = clip; }
|
inline void setClip(const Vec2d &clip) { clip_ = clip; }
|
||||||
|
|
||||||
inline const Size & getWindowSize() const { return window_size_; }
|
inline const Size & getWindowSize() const { return window_size_; }
|
||||||
void setWindowSize(const Size &window_size);
|
void setWindowSize(const Size &window_size);
|
||||||
|
|
||||||
inline const Vec2f & getFov() const { return fov_; }
|
inline const Vec2f & getFov() const { return fov_; }
|
||||||
inline void setFov(const Vec2f & fov) { fov_ = fov; }
|
inline void setFov(const Vec2f & fov) { fov_ = fov; }
|
||||||
|
|
||||||
inline const Vec2f & getPrincipalPoint() const { return principal_point_; }
|
inline const Vec2f & getPrincipalPoint() const { return principal_point_; }
|
||||||
inline const Vec2f & getFocalLength() const { return focal_; }
|
inline const Vec2f & getFocalLength() const { return focal_; }
|
||||||
|
|
||||||
void computeProjectionMatrix(Matx44f &proj) const;
|
void computeProjectionMatrix(Matx44f &proj) const;
|
||||||
|
|
||||||
static Camera KinectCamera(const Size &window_size);
|
static Camera KinectCamera(const Size &window_size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(float f_x, float f_y, float c_x, float c_y, const Size &window_size);
|
void init(float f_x, float f_y, float c_x, float c_y, const Size &window_size);
|
||||||
|
|
||||||
Vec2d clip_;
|
Vec2d clip_;
|
||||||
Vec2f fov_;
|
Vec2f fov_;
|
||||||
Size window_size_;
|
Size window_size_;
|
||||||
|
@ -81,18 +81,18 @@ namespace cv
|
|||||||
void setWidgetPose(const String &id, const Affine3f &pose);
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
|
||||||
void setCamera(const Camera &camera);
|
void setCamera(const Camera &camera);
|
||||||
Camera getCamera() const;
|
Camera getCamera() const;
|
||||||
Affine3f getViewerPose();
|
Affine3f getViewerPose();
|
||||||
void setViewerPose(const Affine3f &pose);
|
void setViewerPose(const Affine3f &pose);
|
||||||
|
|
||||||
void resetCameraViewpoint(const String &id);
|
void resetCameraViewpoint(const String &id);
|
||||||
void resetCamera();
|
void resetCamera();
|
||||||
|
|
||||||
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
|
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
|
||||||
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
|
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
|
||||||
|
|
||||||
Size getWindowSize() const;
|
Size getWindowSize() const;
|
||||||
void setWindowSize(const Size &window_size);
|
void setWindowSize(const Size &window_size);
|
||||||
String getWindowName() const;
|
String getWindowName() const;
|
||||||
@ -107,19 +107,19 @@ namespace cv
|
|||||||
|
|
||||||
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
|
void registerKeyboardCallback(KeyboardCallback callback, void* cookie = 0);
|
||||||
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
|
void registerMouseCallback(MouseCallback callback, void* cookie = 0);
|
||||||
|
|
||||||
void setRenderingProperty(const String &id, int property, double value);
|
void setRenderingProperty(const String &id, int property, double value);
|
||||||
double getRenderingProperty(const String &id, int property);
|
double getRenderingProperty(const String &id, int property);
|
||||||
|
|
||||||
void setDesiredUpdateRate(double rate);
|
void setDesiredUpdateRate(double rate);
|
||||||
double getDesiredUpdateRate();
|
double getDesiredUpdateRate();
|
||||||
|
|
||||||
void setRepresentation(int representation);
|
void setRepresentation(int representation);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct VizImpl;
|
struct VizImpl;
|
||||||
VizImpl* impl_;
|
VizImpl* impl_;
|
||||||
|
|
||||||
void create(const String &window_name);
|
void create(const String &window_name);
|
||||||
void release();
|
void release();
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,7 @@ namespace cv
|
|||||||
SHADING_GOURAUD,
|
SHADING_GOURAUD,
|
||||||
SHADING_PHONG
|
SHADING_PHONG
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/// The base class for all widgets
|
/// The base class for all widgets
|
||||||
class CV_EXPORTS Widget
|
class CV_EXPORTS Widget
|
||||||
@ -91,10 +91,10 @@ namespace cv
|
|||||||
Widget(const Widget& other);
|
Widget(const Widget& other);
|
||||||
Widget& operator=(const Widget& other);
|
Widget& operator=(const Widget& other);
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
||||||
//! Create a widget directly from ply file
|
//! Create a widget directly from ply file
|
||||||
static Widget fromPlyFile(const String &file_name);
|
static Widget fromPlyFile(const String &file_name);
|
||||||
|
|
||||||
//! Rendering properties of this particular widget
|
//! Rendering properties of this particular widget
|
||||||
void setRenderingProperty(int property, double value);
|
void setRenderingProperty(int property, double value);
|
||||||
double getRenderingProperty(int property) const;
|
double getRenderingProperty(int property) const;
|
||||||
@ -201,10 +201,10 @@ namespace cv
|
|||||||
WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
||||||
//! Creates grid based on the plane equation
|
//! Creates grid based on the plane equation
|
||||||
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct GridImpl;
|
struct GridImpl;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WText3D : public Widget3D
|
class CV_EXPORTS WText3D : public Widget3D
|
||||||
@ -224,15 +224,15 @@ namespace cv
|
|||||||
void setText(const String &text);
|
void setText(const String &text);
|
||||||
String getText() const;
|
String getText() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WImageOverlay : public Widget2D
|
class CV_EXPORTS WImageOverlay : public Widget2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WImageOverlay(const Mat &image, const Rect &rect);
|
WImageOverlay(const Mat &image, const Rect &rect);
|
||||||
|
|
||||||
void setImage(const Mat &image);
|
void setImage(const Mat &image);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WImage3D : public Widget3D
|
class CV_EXPORTS WImage3D : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -240,10 +240,10 @@ namespace cv
|
|||||||
WImage3D(const Mat &image, const Size &size);
|
WImage3D(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
|
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
|
||||||
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size);
|
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size);
|
||||||
|
|
||||||
void setImage(const Mat &image);
|
void setImage(const Mat &image);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WCameraPosition : public Widget3D
|
class CV_EXPORTS WCameraPosition : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -257,27 +257,27 @@ namespace cv
|
|||||||
WCameraPosition(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
WCameraPosition(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
||||||
//! Creates frustum and display given image at the far plane
|
//! Creates frustum and display given image at the far plane
|
||||||
WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
WCameraPosition(const Vec2f &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ProjectImage;
|
struct ProjectImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WTrajectory : public Widget3D
|
class CV_EXPORTS WTrajectory : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2};
|
enum {DISPLAY_FRAMES = 1, DISPLAY_PATH = 2};
|
||||||
|
|
||||||
//! Displays trajectory of the given path either by coordinate frames or polyline
|
//! Displays trajectory of the given path either by coordinate frames or polyline
|
||||||
WTrajectory(const std::vector<Affine3f> &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0);
|
WTrajectory(const std::vector<Affine3f> &path, int display_mode = WTrajectory::DISPLAY_PATH, const Color &color = Color::white(), double scale = 1.0);
|
||||||
//! Displays trajectory of the given path by frustums
|
//! Displays trajectory of the given path by frustums
|
||||||
WTrajectory(const std::vector<Affine3f> &path, const Matx33f &K, double scale = 1.0, const Color &color = Color::white());
|
WTrajectory(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
|
//! Displays trajectory of the given path by frustums
|
||||||
WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
WTrajectory(const std::vector<Affine3f> &path, const Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ApplyPath;
|
struct ApplyPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WSpheresTrajectory: public Widget3D
|
class CV_EXPORTS WSpheresTrajectory: public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -301,16 +301,16 @@ namespace cv
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WCloudCollection();
|
WCloudCollection();
|
||||||
|
|
||||||
//! Each point in cloud is mapped to a color in colors
|
//! Each point in cloud is mapped to a color in colors
|
||||||
void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity());
|
void addCloud(InputArray cloud, InputArray colors, const Affine3f &pose = Affine3f::Identity());
|
||||||
//! All points in cloud have the same color
|
//! All points in cloud have the same color
|
||||||
void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3f &pose = Affine3f::Identity());
|
void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3f &pose = Affine3f::Identity());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CreateCloudWidget;
|
struct CreateCloudWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WCloudNormals : public Widget3D
|
class CV_EXPORTS WCloudNormals : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -319,12 +319,12 @@ namespace cv
|
|||||||
private:
|
private:
|
||||||
struct ApplyCloudNormals;
|
struct ApplyCloudNormals;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WMesh : public Widget3D
|
class CV_EXPORTS WMesh : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WMesh(const Mesh3d &mesh);
|
WMesh(const Mesh3d &mesh);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CopyImpl;
|
struct CopyImpl;
|
||||||
};
|
};
|
||||||
|
@ -327,7 +327,7 @@ struct cv::viz::WCloudCollection::CreateCloudWidget
|
|||||||
vertices->SetCells(nr_points, cells);
|
vertices->SetCells(nr_points, cells);
|
||||||
return polydata;
|
return polydata;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createMapper(vtkSmartPointer<vtkLODActor> actor, vtkSmartPointer<vtkPolyData> poly_data, Vec3d& minmax)
|
static void createMapper(vtkSmartPointer<vtkLODActor> actor, vtkSmartPointer<vtkPolyData> poly_data, Vec3d& minmax)
|
||||||
{
|
{
|
||||||
vtkDataSetMapper *mapper = vtkDataSetMapper::SafeDownCast(actor->GetMapper());
|
vtkDataSetMapper *mapper = vtkDataSetMapper::SafeDownCast(actor->GetMapper());
|
||||||
@ -349,17 +349,17 @@ struct cv::viz::WCloudCollection::CreateCloudWidget
|
|||||||
mapper_new->SetInterpolateScalarsBeforeMapping(interpolation);
|
mapper_new->SetInterpolateScalarsBeforeMapping(interpolation);
|
||||||
mapper_new->ScalarVisibilityOn();
|
mapper_new->ScalarVisibilityOn();
|
||||||
mapper_new->ImmediateModeRenderingOff();
|
mapper_new->ImmediateModeRenderingOff();
|
||||||
|
|
||||||
actor->SetNumberOfCloudPoints(int(std::max<vtkIdType>(1, poly_data->GetNumberOfPoints() / 10)));
|
actor->SetNumberOfCloudPoints(int(std::max<vtkIdType>(1, poly_data->GetNumberOfPoints() / 10)));
|
||||||
actor->GetProperty()->SetInterpolationToFlat();
|
actor->GetProperty()->SetInterpolationToFlat();
|
||||||
actor->GetProperty()->BackfaceCullingOn();
|
actor->GetProperty()->BackfaceCullingOn();
|
||||||
actor->SetMapper(mapper_new);
|
actor->SetMapper(mapper_new);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData *data = vtkPolyData::SafeDownCast(mapper->GetInput());
|
vtkPolyData *data = vtkPolyData::SafeDownCast(mapper->GetInput());
|
||||||
CV_Assert("Cloud Widget without data" && data);
|
CV_Assert("Cloud Widget without data" && data);
|
||||||
|
|
||||||
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
|
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
appendFilter->AddInputConnection(mapper->GetInput()->GetProducerPort());
|
appendFilter->AddInputConnection(mapper->GetInput()->GetProducerPort());
|
||||||
@ -369,7 +369,7 @@ struct cv::viz::WCloudCollection::CreateCloudWidget
|
|||||||
appendFilter->AddInputData(poly_data);
|
appendFilter->AddInputData(poly_data);
|
||||||
#endif
|
#endif
|
||||||
mapper->SetInputConnection(appendFilter->GetOutputPort());
|
mapper->SetInputConnection(appendFilter->GetOutputPort());
|
||||||
|
|
||||||
// Update the number of cloud points
|
// Update the number of cloud points
|
||||||
vtkIdType old_cloud_points = actor->GetNumberOfCloudPoints();
|
vtkIdType old_cloud_points = actor->GetNumberOfCloudPoints();
|
||||||
actor->SetNumberOfCloudPoints(int(std::max<vtkIdType>(1, old_cloud_points+poly_data->GetNumberOfPoints() / 10)));
|
actor->SetNumberOfCloudPoints(int(std::max<vtkIdType>(1, old_cloud_points+poly_data->GetNumberOfPoints() / 10)));
|
||||||
@ -389,7 +389,7 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
|
|||||||
Mat colors = _colors.getMat();
|
Mat colors = _colors.getMat();
|
||||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||||
CV_Assert(colors.type() == CV_8UC3 && cloud.size() == colors.size());
|
CV_Assert(colors.type() == CV_8UC3 && cloud.size() == colors.size());
|
||||||
|
|
||||||
if (cloud.isContinuous() && colors.isContinuous())
|
if (cloud.isContinuous() && colors.isContinuous())
|
||||||
{
|
{
|
||||||
cloud.reshape(cloud.channels(), 1);
|
cloud.reshape(cloud.channels(), 1);
|
||||||
@ -410,12 +410,12 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
|
|||||||
|
|
||||||
// Assign the colors
|
// Assign the colors
|
||||||
polydata->GetPointData()->SetScalars(scalars);
|
polydata->GetPointData()->SetScalars(scalars);
|
||||||
|
|
||||||
// Transform the poly data based on the pose
|
// Transform the poly data based on the pose
|
||||||
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
||||||
transform->PreMultiply();
|
transform->PreMultiply();
|
||||||
transform->SetMatrix(convertToVtkMatrix(pose.matrix));
|
transform->SetMatrix(convertToVtkMatrix(pose.matrix));
|
||||||
|
|
||||||
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
||||||
transform_filter->SetTransform(transform);
|
transform_filter->SetTransform(transform);
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
@ -424,10 +424,10 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
|
|||||||
transform_filter->SetInputData(polydata);
|
transform_filter->SetInputData(polydata);
|
||||||
#endif
|
#endif
|
||||||
transform_filter->Update();
|
transform_filter->Update();
|
||||||
|
|
||||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Incompatible widget type." && actor);
|
CV_Assert("Incompatible widget type." && actor);
|
||||||
|
|
||||||
Vec3d minmax(scalars->GetRange());
|
Vec3d minmax(scalars->GetRange());
|
||||||
CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax);
|
CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax);
|
||||||
}
|
}
|
||||||
@ -449,12 +449,12 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, const Color &color,
|
|||||||
|
|
||||||
// Assign the colors
|
// Assign the colors
|
||||||
polydata->GetPointData()->SetScalars(scalars);
|
polydata->GetPointData()->SetScalars(scalars);
|
||||||
|
|
||||||
// Transform the poly data based on the pose
|
// Transform the poly data based on the pose
|
||||||
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
||||||
transform->PreMultiply();
|
transform->PreMultiply();
|
||||||
transform->SetMatrix(convertToVtkMatrix(pose.matrix));
|
transform->SetMatrix(convertToVtkMatrix(pose.matrix));
|
||||||
|
|
||||||
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
||||||
transform_filter->SetTransform(transform);
|
transform_filter->SetTransform(transform);
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
@ -463,10 +463,10 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, const Color &color,
|
|||||||
transform_filter->SetInputData(polydata);
|
transform_filter->SetInputData(polydata);
|
||||||
#endif
|
#endif
|
||||||
transform_filter->Update();
|
transform_filter->Update();
|
||||||
|
|
||||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Incompatible widget type." && actor);
|
CV_Assert("Incompatible widget type." && actor);
|
||||||
|
|
||||||
Vec3d minmax(scalars->GetRange());
|
Vec3d minmax(scalars->GetRange());
|
||||||
CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax);
|
CreateCloudWidget::createMapper(actor, transform_filter->GetOutput(), minmax);
|
||||||
}
|
}
|
||||||
@ -634,7 +634,7 @@ struct cv::viz::WMesh::CopyImpl
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
const _Tp* srow = source.ptr<_Tp>(0);
|
const _Tp* srow = source.ptr<_Tp>(0);
|
||||||
const _Tp* mrow = nan_mask.ptr<_Tp>(0);
|
const _Tp* mrow = nan_mask.ptr<_Tp>(0);
|
||||||
|
|
||||||
for (int x = 0; x < source.cols; ++x, srow += s_chs, mrow += m_chs)
|
for (int x = 0; x < source.cols; ++x, srow += s_chs, mrow += m_chs)
|
||||||
{
|
{
|
||||||
if (!isNan(mrow[0]) && !isNan(mrow[1]) && !isNan(mrow[2]))
|
if (!isNan(mrow[0]) && !isNan(mrow[1]) && !isNan(mrow[2]))
|
||||||
@ -653,13 +653,13 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
CV_Assert(mesh.cloud.rows == 1 && (mesh.cloud.type() == CV_32FC3 || mesh.cloud.type() == CV_64FC3 || mesh.cloud.type() == CV_32FC4 || mesh.cloud.type() == CV_64FC4));
|
CV_Assert(mesh.cloud.rows == 1 && (mesh.cloud.type() == CV_32FC3 || mesh.cloud.type() == CV_64FC3 || mesh.cloud.type() == CV_32FC4 || mesh.cloud.type() == CV_64FC4));
|
||||||
CV_Assert(mesh.colors.empty() || (mesh.colors.type() == CV_8UC3 && mesh.cloud.size() == mesh.colors.size()));
|
CV_Assert(mesh.colors.empty() || (mesh.colors.type() == CV_8UC3 && mesh.cloud.size() == mesh.colors.size()));
|
||||||
CV_Assert(!mesh.polygons.empty() && mesh.polygons.type() == CV_32SC1);
|
CV_Assert(!mesh.polygons.empty() && mesh.polygons.type() == CV_32SC1);
|
||||||
|
|
||||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||||
vtkIdType nr_points = mesh.cloud.total();
|
vtkIdType nr_points = mesh.cloud.total();
|
||||||
Mat look_up_mat(1, nr_points, CV_32SC1);
|
Mat look_up_mat(1, nr_points, CV_32SC1);
|
||||||
int * look_up = look_up_mat.ptr<int>();
|
int * look_up = look_up_mat.ptr<int>();
|
||||||
points->SetNumberOfPoints(nr_points);
|
points->SetNumberOfPoints(nr_points);
|
||||||
|
|
||||||
// Copy data from cloud to vtkPoints
|
// Copy data from cloud to vtkPoints
|
||||||
if (mesh.cloud.depth() == CV_32F)
|
if (mesh.cloud.depth() == CV_32F)
|
||||||
{
|
{
|
||||||
@ -675,36 +675,36 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
Vec3d *data_end = CopyImpl::copy(mesh.cloud, data_beg, look_up, mesh.cloud);
|
Vec3d *data_end = CopyImpl::copy(mesh.cloud, data_beg, look_up, mesh.cloud);
|
||||||
nr_points = data_end - data_beg;
|
nr_points = data_end - data_beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnsignedCharArray> scalars;
|
vtkSmartPointer<vtkUnsignedCharArray> scalars;
|
||||||
|
|
||||||
if (!mesh.colors.empty())
|
if (!mesh.colors.empty())
|
||||||
{
|
{
|
||||||
Vec3b * colors_data = 0;
|
Vec3b * colors_data = 0;
|
||||||
colors_data = new Vec3b[nr_points];
|
colors_data = new Vec3b[nr_points];
|
||||||
NanFilter::copyColor(mesh.colors, colors_data, mesh.cloud);
|
NanFilter::copyColor(mesh.colors, colors_data, mesh.cloud);
|
||||||
|
|
||||||
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
|
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
|
||||||
scalars->SetNumberOfComponents(3);
|
scalars->SetNumberOfComponents(3);
|
||||||
scalars->SetNumberOfTuples(nr_points);
|
scalars->SetNumberOfTuples(nr_points);
|
||||||
scalars->SetArray(colors_data->val, 3 * nr_points, 0);
|
scalars->SetArray(colors_data->val, 3 * nr_points, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
points->SetNumberOfPoints(nr_points);
|
points->SetNumberOfPoints(nr_points);
|
||||||
|
|
||||||
vtkSmartPointer<vtkPointSet> data;
|
vtkSmartPointer<vtkPointSet> data;
|
||||||
|
|
||||||
if (mesh.polygons.size().area() > 1)
|
if (mesh.polygons.size().area() > 1)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkCellArray> cell_array = vtkSmartPointer<vtkCellArray>::New();
|
vtkSmartPointer<vtkCellArray> cell_array = vtkSmartPointer<vtkCellArray>::New();
|
||||||
const int * polygons = mesh.polygons.ptr<int>();
|
const int * polygons = mesh.polygons.ptr<int>();
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int poly_size = mesh.polygons.total();
|
int poly_size = mesh.polygons.total();
|
||||||
for (int i = 0; i < poly_size; ++idx)
|
for (int i = 0; i < poly_size; ++idx)
|
||||||
{
|
{
|
||||||
int n_points = polygons[i++];
|
int n_points = polygons[i++];
|
||||||
|
|
||||||
cell_array->InsertNextCell(n_points);
|
cell_array->InsertNextCell(n_points);
|
||||||
for (int j = 0; j < n_points; ++j, ++idx)
|
for (int j = 0; j < n_points; ++j, ++idx)
|
||||||
cell_array->InsertCellPoint(look_up[polygons[i++]]);
|
cell_array->InsertCellPoint(look_up[polygons[i++]]);
|
||||||
@ -717,7 +717,7 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
|
|
||||||
if (scalars)
|
if (scalars)
|
||||||
polydata->GetPointData()->SetScalars(scalars);
|
polydata->GetPointData()->SetScalars(scalars);
|
||||||
|
|
||||||
data = polydata;
|
data = polydata;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -726,20 +726,20 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
|
vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
|
||||||
const int * polygons = mesh.polygons.ptr<int>();
|
const int * polygons = mesh.polygons.ptr<int>();
|
||||||
int n_points = polygons[0];
|
int n_points = polygons[0];
|
||||||
|
|
||||||
polygon->GetPointIds()->SetNumberOfIds(n_points);
|
polygon->GetPointIds()->SetNumberOfIds(n_points);
|
||||||
|
|
||||||
for (int j = 1; j < n_points+1; ++j)
|
for (int j = 1; j < n_points+1; ++j)
|
||||||
polygon->GetPointIds()->SetId(j, look_up[polygons[j]]);
|
polygon->GetPointIds()->SetId(j, look_up[polygons[j]]);
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnstructuredGrid> poly_grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
|
vtkSmartPointer<vtkUnstructuredGrid> poly_grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
|
||||||
poly_grid->Allocate(1, 1);
|
poly_grid->Allocate(1, 1);
|
||||||
poly_grid->InsertNextCell(polygon->GetCellType(), polygon->GetPointIds());
|
poly_grid->InsertNextCell(polygon->GetCellType(), polygon->GetPointIds());
|
||||||
poly_grid->SetPoints(points);
|
poly_grid->SetPoints(points);
|
||||||
|
|
||||||
if (scalars)
|
if (scalars)
|
||||||
poly_grid->GetPointData()->SetScalars(scalars);
|
poly_grid->GetPointData()->SetScalars(scalars);
|
||||||
|
|
||||||
data = poly_grid;
|
data = poly_grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
actor->GetProperty()->SetInterpolationToFlat();
|
actor->GetProperty()->SetInterpolationToFlat();
|
||||||
actor->GetProperty()->EdgeVisibilityOff();
|
actor->GetProperty()->EdgeVisibilityOff();
|
||||||
actor->GetProperty()->ShadingOff();
|
actor->GetProperty()->ShadingOff();
|
||||||
|
|
||||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
mapper->SetInput(data);
|
mapper->SetInput(data);
|
||||||
@ -758,11 +758,11 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
|
|||||||
mapper->SetInputData(data);
|
mapper->SetInputData(data);
|
||||||
#endif
|
#endif
|
||||||
mapper->ImmediateModeRenderingOff();
|
mapper->ImmediateModeRenderingOff();
|
||||||
|
|
||||||
vtkIdType numberOfCloudPoints = nr_points * 0.1;
|
vtkIdType numberOfCloudPoints = nr_points * 0.1;
|
||||||
actor->SetNumberOfCloudPoints(int(numberOfCloudPoints > 1 ? numberOfCloudPoints : 1));
|
actor->SetNumberOfCloudPoints(int(numberOfCloudPoints > 1 ? numberOfCloudPoints : 1));
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ void cv::viz::InteractorStyle::Initialize()
|
|||||||
|
|
||||||
init_ = true;
|
init_ = true;
|
||||||
stereo_anaglyph_mask_default_ = true;
|
stereo_anaglyph_mask_default_ = true;
|
||||||
|
|
||||||
// Initialize the keyboard event callback as none
|
// Initialize the keyboard event callback as none
|
||||||
keyboardCallback_ = 0;
|
keyboardCallback_ = 0;
|
||||||
keyboard_callback_cookie_ = 0;
|
keyboard_callback_cookie_ = 0;
|
||||||
|
|
||||||
// Initialize the mouse event callback as none
|
// Initialize the mouse event callback as none
|
||||||
mouseCallback_ = 0;
|
mouseCallback_ = 0;
|
||||||
mouse_callback_cookie_ = 0;
|
mouse_callback_cookie_ = 0;
|
||||||
@ -197,7 +197,7 @@ void cv::viz::InteractorStyle::registerKeyboardCallback(void (*callback)(const K
|
|||||||
void
|
void
|
||||||
cv::viz::InteractorStyle::OnKeyDown()
|
cv::viz::InteractorStyle::OnKeyDown()
|
||||||
{
|
{
|
||||||
|
|
||||||
CV_Assert("Interactor style not initialized. Please call Initialize() before continuing" && init_);
|
CV_Assert("Interactor style not initialized. Please call Initialize() before continuing" && init_);
|
||||||
CV_Assert("No renderer given! Use SetRendererCollection() before continuing." && renderer_);
|
CV_Assert("No renderer given! Use SetRendererCollection() before continuing." && renderer_);
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ cv::viz::InteractorStyle::OnKeyDown()
|
|||||||
{
|
{
|
||||||
if (it == widget_actor_map_->end())
|
if (it == widget_actor_map_->end())
|
||||||
it = widget_actor_map_->begin();
|
it = widget_actor_map_->begin();
|
||||||
|
|
||||||
vtkProp3D * actor = vtkProp3D::SafeDownCast(it->second);
|
vtkProp3D * actor = vtkProp3D::SafeDownCast(it->second);
|
||||||
if (actor && actor->GetUserMatrix())
|
if (actor && actor->GetUserMatrix())
|
||||||
{
|
{
|
||||||
@ -554,7 +554,7 @@ void cv::viz::InteractorStyle::OnKeyUp()
|
|||||||
// Check if there is a keyboard callback registered
|
// Check if there is a keyboard callback registered
|
||||||
if (keyboardCallback_)
|
if (keyboardCallback_)
|
||||||
keyboardCallback_(event, keyboard_callback_cookie_);
|
keyboardCallback_(event, keyboard_callback_cookie_);
|
||||||
|
|
||||||
Superclass::OnKeyUp();
|
Superclass::OnKeyUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,10 +673,10 @@ void cv::viz::InteractorStyle::OnMouseWheelBackward()
|
|||||||
// If a mouse callback registered, call it!
|
// If a mouse callback registered, call it!
|
||||||
if (mouseCallback_)
|
if (mouseCallback_)
|
||||||
mouseCallback_(event, mouse_callback_cookie_);
|
mouseCallback_(event, mouse_callback_cookie_);
|
||||||
|
|
||||||
if (Interactor->GetRepeatCount() && mouseCallback_)
|
if (Interactor->GetRepeatCount() && mouseCallback_)
|
||||||
mouseCallback_(event, mouse_callback_cookie_);
|
mouseCallback_(event, mouse_callback_cookie_);
|
||||||
|
|
||||||
if (Interactor->GetAltKey())
|
if (Interactor->GetAltKey())
|
||||||
{
|
{
|
||||||
// zoom
|
// zoom
|
||||||
|
@ -85,7 +85,7 @@ namespace cv
|
|||||||
|
|
||||||
/** \brief Change the default keyboard modified from ALT to a different special key.*/
|
/** \brief Change the default keyboard modified from ALT to a different special key.*/
|
||||||
inline void setKeyboardModifier(const KeyboardModifier &modifier) { modifier_ = modifier; }
|
inline void setKeyboardModifier(const KeyboardModifier &modifier) { modifier_ = modifier; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \brief Set to true after initialization is complete. */
|
/** \brief Set to true after initialization is complete. */
|
||||||
bool init_;
|
bool init_;
|
||||||
@ -95,7 +95,7 @@ namespace cv
|
|||||||
|
|
||||||
/** \brief Actor map stored internally. */
|
/** \brief Actor map stored internally. */
|
||||||
cv::Ptr<WidgetActorMap> widget_actor_map_;
|
cv::Ptr<WidgetActorMap> widget_actor_map_;
|
||||||
|
|
||||||
/** \brief The current window width/height. */
|
/** \brief The current window width/height. */
|
||||||
Vec2i win_size_;
|
Vec2i win_size_;
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ namespace cv
|
|||||||
|
|
||||||
/** \brief A PNG writer for screenshot captures. */
|
/** \brief A PNG writer for screenshot captures. */
|
||||||
vtkSmartPointer<vtkPNGWriter> snapshot_writer_;
|
vtkSmartPointer<vtkPNGWriter> snapshot_writer_;
|
||||||
|
|
||||||
/** \brief Internal window to image filter. Needed by \a snapshot_writer_. */
|
/** \brief Internal window to image filter. Needed by \a snapshot_writer_. */
|
||||||
vtkSmartPointer<vtkWindowToImageFilter> wif_;
|
vtkSmartPointer<vtkWindowToImageFilter> wif_;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -120,10 +120,10 @@ struct cv::viz::Mesh3d::loadMeshImpl
|
|||||||
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
|
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
|
||||||
reader->SetFileName(file.c_str());
|
reader->SetFileName(file.c_str());
|
||||||
reader->Update();
|
reader->Update();
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyData> poly_data = reader->GetOutput();
|
vtkSmartPointer<vtkPolyData> poly_data = reader->GetOutput();
|
||||||
CV_Assert("File does not exist or file format is not supported." && poly_data);
|
CV_Assert("File does not exist or file format is not supported." && poly_data);
|
||||||
|
|
||||||
vtkSmartPointer<vtkPoints> mesh_points = poly_data->GetPoints();
|
vtkSmartPointer<vtkPoints> mesh_points = poly_data->GetPoints();
|
||||||
vtkIdType nr_points = mesh_points->GetNumberOfPoints();
|
vtkIdType nr_points = mesh_points->GetNumberOfPoints();
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ struct cv::viz::Mesh3d::loadMeshImpl
|
|||||||
vtkUnsignedCharArray* poly_colors = 0;
|
vtkUnsignedCharArray* poly_colors = 0;
|
||||||
if (poly_data->GetPointData())
|
if (poly_data->GetPointData())
|
||||||
poly_colors = vtkUnsignedCharArray::SafeDownCast(poly_data->GetPointData()->GetScalars());
|
poly_colors = vtkUnsignedCharArray::SafeDownCast(poly_data->GetPointData()->GetScalars());
|
||||||
|
|
||||||
if (poly_colors && (poly_colors->GetNumberOfComponents() == 3))
|
if (poly_colors && (poly_colors->GetNumberOfComponents() == 3))
|
||||||
{
|
{
|
||||||
mesh.colors.create(1, nr_points, CV_8UC3);
|
mesh.colors.create(1, nr_points, CV_8UC3);
|
||||||
@ -164,9 +164,9 @@ struct cv::viz::Mesh3d::loadMeshImpl
|
|||||||
vtkIdType nr_cell_points;
|
vtkIdType nr_cell_points;
|
||||||
vtkCellArray * mesh_polygons = poly_data->GetPolys();
|
vtkCellArray * mesh_polygons = poly_data->GetPolys();
|
||||||
mesh_polygons->InitTraversal();
|
mesh_polygons->InitTraversal();
|
||||||
|
|
||||||
mesh.polygons.create(1, mesh_polygons->GetSize(), CV_32SC1);
|
mesh.polygons.create(1, mesh_polygons->GetSize(), CV_32SC1);
|
||||||
|
|
||||||
int* polygons = mesh.polygons.ptr<int>();
|
int* polygons = mesh.polygons.ptr<int>();
|
||||||
while (mesh_polygons->GetNextCell(nr_cell_points, cell_points))
|
while (mesh_polygons->GetNextCell(nr_cell_points, cell_points))
|
||||||
{
|
{
|
||||||
@ -213,30 +213,30 @@ cv::viz::Camera::Camera(const cv::Matx33f & K, const Size &window_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cv::viz::Camera::Camera(const Matx44f &proj, const Size &window_size)
|
cv::viz::Camera::Camera(const Matx44f &proj, const Size &window_size)
|
||||||
{
|
{
|
||||||
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
||||||
|
|
||||||
double near = proj(2,3) / (proj(2,2) - 1.0);
|
double near = proj(2,3) / (proj(2,2) - 1.0);
|
||||||
double far = near * (proj(2,2) - 1.0) / (proj(2,2) + 1.0);
|
double far = near * (proj(2,2) - 1.0) / (proj(2,2) + 1.0);
|
||||||
double left = near * (proj(0,2)-1) / proj(0,0);
|
double left = near * (proj(0,2)-1) / proj(0,0);
|
||||||
double right = 2.0 * near / proj(0,0) + left;
|
double right = 2.0 * near / proj(0,0) + left;
|
||||||
double bottom = near * (proj(1,2)-1) / proj(1,1);
|
double bottom = near * (proj(1,2)-1) / proj(1,1);
|
||||||
double top = 2.0 * near / proj(1,1) + bottom;
|
double top = 2.0 * near / proj(1,1) + bottom;
|
||||||
|
|
||||||
double epsilon = 2.2204460492503131e-16;
|
double epsilon = 2.2204460492503131e-16;
|
||||||
|
|
||||||
if (fabs(left-right) < epsilon) principal_point_[0] = static_cast<float>(window_size.width) * 0.5f;
|
if (fabs(left-right) < epsilon) principal_point_[0] = static_cast<float>(window_size.width) * 0.5f;
|
||||||
else principal_point_[0] = (left * static_cast<float>(window_size.width)) / (left - right);
|
else principal_point_[0] = (left * static_cast<float>(window_size.width)) / (left - right);
|
||||||
focal_[0] = -near * principal_point_[0] / left;
|
focal_[0] = -near * principal_point_[0] / left;
|
||||||
|
|
||||||
if (fabs(top-bottom) < epsilon) principal_point_[1] = static_cast<float>(window_size.height) * 0.5f;
|
if (fabs(top-bottom) < epsilon) principal_point_[1] = static_cast<float>(window_size.height) * 0.5f;
|
||||||
else principal_point_[1] = (top * static_cast<float>(window_size.height)) / (top - bottom);
|
else principal_point_[1] = (top * static_cast<float>(window_size.height)) / (top - bottom);
|
||||||
focal_[1] = near * principal_point_[1] / top;
|
focal_[1] = near * principal_point_[1] / top;
|
||||||
|
|
||||||
setClip(Vec2d(near, far));
|
setClip(Vec2d(near, far));
|
||||||
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0]));
|
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0]));
|
||||||
fov_[1] = (atan2(principal_point_[1],focal_[1]) + atan2(window_size.height-principal_point_[1],focal_[1]));
|
fov_[1] = (atan2(principal_point_[1],focal_[1]) + atan2(window_size.height-principal_point_[1],focal_[1]));
|
||||||
|
|
||||||
window_size_ = window_size;
|
window_size_ = window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,33 +244,33 @@ void cv::viz::Camera::init(float f_x, float f_y, float c_x, float c_y, const Siz
|
|||||||
{
|
{
|
||||||
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
||||||
setClip(Vec2d(0.01, 1000.01));// Default clipping
|
setClip(Vec2d(0.01, 1000.01));// Default clipping
|
||||||
|
|
||||||
fov_[0] = (atan2(c_x,f_x) + atan2(window_size.width-c_x,f_x));
|
fov_[0] = (atan2(c_x,f_x) + atan2(window_size.width-c_x,f_x));
|
||||||
fov_[1] = (atan2(c_y,f_y) + atan2(window_size.height-c_y,f_y));
|
fov_[1] = (atan2(c_y,f_y) + atan2(window_size.height-c_y,f_y));
|
||||||
|
|
||||||
principal_point_[0] = c_x;
|
principal_point_[0] = c_x;
|
||||||
principal_point_[1] = c_y;
|
principal_point_[1] = c_y;
|
||||||
|
|
||||||
focal_[0] = f_x;
|
focal_[0] = f_x;
|
||||||
focal_[1] = f_y;
|
focal_[1] = f_y;
|
||||||
|
|
||||||
window_size_ = window_size;
|
window_size_ = window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::viz::Camera::setWindowSize(const Size &window_size)
|
void cv::viz::Camera::setWindowSize(const Size &window_size)
|
||||||
{
|
{
|
||||||
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
CV_Assert(window_size.width > 0 && window_size.height > 0);
|
||||||
|
|
||||||
// Get the scale factor and update the principal points
|
// Get the scale factor and update the principal points
|
||||||
float scalex = static_cast<float>(window_size.width) / static_cast<float>(window_size_.width);
|
float scalex = static_cast<float>(window_size.width) / static_cast<float>(window_size_.width);
|
||||||
float scaley = static_cast<float>(window_size.height) / static_cast<float>(window_size_.height);
|
float scaley = static_cast<float>(window_size.height) / static_cast<float>(window_size_.height);
|
||||||
|
|
||||||
principal_point_[0] *= scalex;
|
principal_point_[0] *= scalex;
|
||||||
principal_point_[1] *= scaley;
|
principal_point_[1] *= scaley;
|
||||||
focal_ *= scaley;
|
focal_ *= scaley;
|
||||||
// Vertical field of view is fixed! Update horizontal field of view
|
// Vertical field of view is fixed! Update horizontal field of view
|
||||||
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0]));
|
fov_[0] = (atan2(principal_point_[0],focal_[0]) + atan2(window_size.width-principal_point_[0],focal_[0]));
|
||||||
|
|
||||||
window_size_ = window_size;
|
window_size_ = window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,12 +280,12 @@ void cv::viz::Camera::computeProjectionMatrix(Matx44f &proj) const
|
|||||||
double left = -clip_[0] * principal_point_[0] / focal_[0];
|
double left = -clip_[0] * principal_point_[0] / focal_[0];
|
||||||
double right = clip_[0] * (window_size_.width - principal_point_[0]) / focal_[0];
|
double right = clip_[0] * (window_size_.width - principal_point_[0]) / focal_[0];
|
||||||
double bottom = -clip_[0] * (window_size_.height - principal_point_[1]) / focal_[1];
|
double bottom = -clip_[0] * (window_size_.height - principal_point_[1]) / focal_[1];
|
||||||
|
|
||||||
double temp1 = 2.0 * clip_[0];
|
double temp1 = 2.0 * clip_[0];
|
||||||
double temp2 = 1.0 / (right - left);
|
double temp2 = 1.0 / (right - left);
|
||||||
double temp3 = 1.0 / (top - bottom);
|
double temp3 = 1.0 / (top - bottom);
|
||||||
double temp4 = 1.0 / (clip_[0] - clip_[1]);
|
double temp4 = 1.0 / (clip_[0] - clip_[1]);
|
||||||
|
|
||||||
proj = Matx44d::zeros();
|
proj = Matx44d::zeros();
|
||||||
proj(0,0) = temp1 * temp2;
|
proj(0,0) = temp1 * temp2;
|
||||||
proj(1,1) = temp1 * temp3;
|
proj(1,1) = temp1 * temp3;
|
||||||
@ -300,7 +300,7 @@ cv::viz::Camera cv::viz::Camera::KinectCamera(const Size &window_size)
|
|||||||
{
|
{
|
||||||
// Without distortion, RGB Camera
|
// Without distortion, RGB Camera
|
||||||
// Received from http://nicolas.burrus.name/index.php/Research/KinectCalibration
|
// Received from http://nicolas.burrus.name/index.php/Research/KinectCalibration
|
||||||
Matx33f K = Matx33f::zeros();
|
Matx33f K = Matx33f::zeros();
|
||||||
K(0,0) = 5.2921508098293293e+02;
|
K(0,0) = 5.2921508098293293e+02;
|
||||||
K(0,2) = 3.2894272028759258e+02;
|
K(0,2) = 3.2894272028759258e+02;
|
||||||
K(1,1) = 5.2556393630057437e+02;
|
K(1,1) = 5.2556393630057437e+02;
|
||||||
|
@ -72,7 +72,7 @@ cv::Affine3f cv::viz::makeCameraPose(const Vec3f& position, const Vec3f& focal_p
|
|||||||
Vec3f n = normalize(focal_point - position);
|
Vec3f n = normalize(focal_point - position);
|
||||||
Vec3f u = normalize(y_dir.cross(n));
|
Vec3f u = normalize(y_dir.cross(n));
|
||||||
Vec3f v = n.cross(u);
|
Vec3f v = n.cross(u);
|
||||||
|
|
||||||
Matx44f pose_mat = Matx44f::zeros();
|
Matx44f pose_mat = Matx44f::zeros();
|
||||||
pose_mat(0,0) = u[0];
|
pose_mat(0,0) = u[0];
|
||||||
pose_mat(0,1) = u[1];
|
pose_mat(0,1) = u[1];
|
||||||
@ -147,9 +147,9 @@ struct cv::viz::VizAccessor::VizAccessorImpl
|
|||||||
|
|
||||||
cv::viz::VizAccessor::VizAccessor() { impl_ = new cv::viz::VizAccessor::VizAccessorImpl;}
|
cv::viz::VizAccessor::VizAccessor() { impl_ = new cv::viz::VizAccessor::VizAccessorImpl;}
|
||||||
|
|
||||||
cv::viz::VizAccessor::~VizAccessor()
|
cv::viz::VizAccessor::~VizAccessor()
|
||||||
{
|
{
|
||||||
if(impl_)
|
if(impl_)
|
||||||
{
|
{
|
||||||
delete impl_;
|
delete impl_;
|
||||||
impl_ = 0;
|
impl_ = 0;
|
||||||
@ -202,7 +202,7 @@ void cv::viz::VizAccessor::remove(const String &window_name)
|
|||||||
// Add the prefix Viz
|
// Add the prefix Viz
|
||||||
String name;
|
String name;
|
||||||
generateWindowName(window_name, name);
|
generateWindowName(window_name, name);
|
||||||
|
|
||||||
VizMap::iterator vm_itr = impl_->viz_map.find(name);
|
VizMap::iterator vm_itr = impl_->viz_map.find(name);
|
||||||
bool exists = vm_itr != impl_->viz_map.end();
|
bool exists = vm_itr != impl_->viz_map.end();
|
||||||
if (!exists) return ;
|
if (!exists) return ;
|
||||||
@ -214,7 +214,7 @@ void cv::viz::VizAccessor::generateWindowName(const String &window_name, String
|
|||||||
output = "Viz";
|
output = "Viz";
|
||||||
// Already is Viz
|
// Already is Viz
|
||||||
if (window_name == output) return;
|
if (window_name == output) return;
|
||||||
|
|
||||||
String prefixed = output + " - ";
|
String prefixed = output + " - ";
|
||||||
if (window_name.substr(0, prefixed.length()) == prefixed) output = window_name; // Already has "Viz - "
|
if (window_name.substr(0, prefixed.length()) == prefixed) output = window_name; // Already has "Viz - "
|
||||||
else if (window_name.substr(0, output.length()) == output) output = prefixed + window_name; // Doesn't have prefix
|
else if (window_name.substr(0, output.length()) == output) output = prefixed + window_name; // Doesn't have prefix
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name); }
|
cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name); }
|
||||||
|
|
||||||
cv::viz::Viz3d::Viz3d(const Viz3d& other) : impl_(other.impl_)
|
cv::viz::Viz3d::Viz3d(const Viz3d& other) : impl_(other.impl_)
|
||||||
{
|
{
|
||||||
if (impl_) CV_XADD(&impl_->ref_counter, 1);
|
if (impl_) CV_XADD(&impl_->ref_counter, 1);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ cv::viz::Viz3d::VizImpl::VizImpl(const String &name)
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
cv::viz::Viz3d::VizImpl::~VizImpl()
|
cv::viz::Viz3d::VizImpl::~VizImpl()
|
||||||
{
|
{
|
||||||
if (interactor_)
|
if (interactor_)
|
||||||
interactor_->DestroyTimer(timer_id_);
|
interactor_->DestroyTimer(timer_id_);
|
||||||
if (renderer_) renderer_->Clear();
|
if (renderer_) renderer_->Clear();
|
||||||
}
|
}
|
||||||
@ -368,11 +368,11 @@ void cv::viz::Viz3d::VizImpl::setBackgroundColor(const Color& color)
|
|||||||
void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
|
void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
|
||||||
{
|
{
|
||||||
vtkCamera& active_camera = *renderer_->GetActiveCamera();
|
vtkCamera& active_camera = *renderer_->GetActiveCamera();
|
||||||
|
|
||||||
// Set the intrinsic parameters of the camera
|
// Set the intrinsic parameters of the camera
|
||||||
window_->SetSize(camera.getWindowSize().width, camera.getWindowSize().height);
|
window_->SetSize(camera.getWindowSize().width, camera.getWindowSize().height);
|
||||||
double aspect_ratio = static_cast<double>(camera.getWindowSize().width)/static_cast<double>(camera.getWindowSize().height);
|
double aspect_ratio = static_cast<double>(camera.getWindowSize().width)/static_cast<double>(camera.getWindowSize().height);
|
||||||
|
|
||||||
Matx44f proj_mat;
|
Matx44f proj_mat;
|
||||||
camera.computeProjectionMatrix(proj_mat);
|
camera.computeProjectionMatrix(proj_mat);
|
||||||
// Use the intrinsic parameters of the camera to simulate more realistically
|
// Use the intrinsic parameters of the camera to simulate more realistically
|
||||||
@ -382,7 +382,7 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
|
|||||||
transform->SetMatrix(convertToVtkMatrix(proj_mat * old_proj_mat.inv()));
|
transform->SetMatrix(convertToVtkMatrix(proj_mat * old_proj_mat.inv()));
|
||||||
active_camera.SetUserTransform(transform);
|
active_camera.SetUserTransform(transform);
|
||||||
transform->Delete();
|
transform->Delete();
|
||||||
|
|
||||||
renderer_->ResetCameraClippingRange();
|
renderer_->ResetCameraClippingRange();
|
||||||
renderer_->Render();
|
renderer_->Render();
|
||||||
}
|
}
|
||||||
@ -391,11 +391,11 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
|
|||||||
cv::viz::Camera cv::viz::Viz3d::VizImpl::getCamera() const
|
cv::viz::Camera cv::viz::Viz3d::VizImpl::getCamera() const
|
||||||
{
|
{
|
||||||
vtkCamera& active_camera = *renderer_->GetActiveCamera();
|
vtkCamera& active_camera = *renderer_->GetActiveCamera();
|
||||||
|
|
||||||
Size window_size(renderer_->GetRenderWindow()->GetSize()[0],
|
Size window_size(renderer_->GetRenderWindow()->GetSize()[0],
|
||||||
renderer_->GetRenderWindow()->GetSize()[1]);
|
renderer_->GetRenderWindow()->GetSize()[1]);
|
||||||
double aspect_ratio = static_cast<double>(window_size.width) / static_cast<double>(window_size.height);
|
double aspect_ratio = static_cast<double>(window_size.width) / static_cast<double>(window_size.height);
|
||||||
|
|
||||||
Matx44f proj_matrix = convertToMatx(active_camera.GetProjectionTransformMatrix(aspect_ratio, -1.0f, 1.0f));
|
Matx44f proj_matrix = convertToMatx(active_camera.GetProjectionTransformMatrix(aspect_ratio, -1.0f, 1.0f));
|
||||||
Camera camera(proj_matrix, window_size);
|
Camera camera(proj_matrix, window_size);
|
||||||
return camera;
|
return camera;
|
||||||
@ -405,7 +405,7 @@ cv::viz::Camera cv::viz::Viz3d::VizImpl::getCamera() const
|
|||||||
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
vtkCamera& camera = *renderer_->GetActiveCamera();
|
vtkCamera& camera = *renderer_->GetActiveCamera();
|
||||||
|
|
||||||
// Position = extrinsic translation
|
// Position = extrinsic translation
|
||||||
cv::Vec3f pos_vec = pose.translation();
|
cv::Vec3f pos_vec = pose.translation();
|
||||||
|
|
||||||
@ -417,11 +417,11 @@ void cv::viz::Viz3d::VizImpl::setViewerPose(const Affine3f &pose)
|
|||||||
// Compute the new focal point
|
// Compute the new focal point
|
||||||
cv::Vec3f z_axis(0.f, 0.f, 1.f);
|
cv::Vec3f z_axis(0.f, 0.f, 1.f);
|
||||||
cv::Vec3f focal_vec = pos_vec + rotation * z_axis;
|
cv::Vec3f focal_vec = pos_vec + rotation * z_axis;
|
||||||
|
|
||||||
camera.SetPosition(pos_vec[0], pos_vec[1], pos_vec[2]);
|
camera.SetPosition(pos_vec[0], pos_vec[1], pos_vec[2]);
|
||||||
camera.SetFocalPoint(focal_vec[0], focal_vec[1], focal_vec[2]);
|
camera.SetFocalPoint(focal_vec[0], focal_vec[1], focal_vec[2]);
|
||||||
camera.SetViewUp(up_vec[0], up_vec[1], up_vec[2]);
|
camera.SetViewUp(up_vec[0], up_vec[1], up_vec[2]);
|
||||||
|
|
||||||
renderer_->ResetCameraClippingRange();
|
renderer_->ResetCameraClippingRange();
|
||||||
renderer_->Render();
|
renderer_->Render();
|
||||||
}
|
}
|
||||||
@ -465,10 +465,10 @@ void cv::viz::Viz3d::VizImpl::convertToWindowCoordinates(const Point3d &pt, Poin
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void cv::viz::Viz3d::VizImpl::converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction)
|
void cv::viz::Viz3d::VizImpl::converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction)
|
||||||
{
|
{
|
||||||
Vec4d world_pt;
|
Vec4d world_pt;
|
||||||
vtkInteractorObserver::ComputeDisplayToWorld(renderer_, window_coord.x, window_coord.y, window_coord.z, world_pt.val);
|
vtkInteractorObserver::ComputeDisplayToWorld(renderer_, window_coord.x, window_coord.y, window_coord.z, world_pt.val);
|
||||||
|
|
||||||
vtkCamera &active_camera = *renderer_->GetActiveCamera();
|
vtkCamera &active_camera = *renderer_->GetActiveCamera();
|
||||||
Vec3d cam_pos;
|
Vec3d cam_pos;
|
||||||
active_camera.GetPosition(cam_pos.val);
|
active_camera.GetPosition(cam_pos.val);
|
||||||
@ -525,19 +525,19 @@ void cv::viz::Viz3d::VizImpl::setRepresentation(int representation)
|
|||||||
vtkActor * actor;
|
vtkActor * actor;
|
||||||
switch (representation)
|
switch (representation)
|
||||||
{
|
{
|
||||||
case REPRESENTATION_POINTS:
|
case REPRESENTATION_POINTS:
|
||||||
{
|
{
|
||||||
while ((actor = actors->GetNextActor()) != NULL)
|
while ((actor = actors->GetNextActor()) != NULL)
|
||||||
actor->GetProperty()->SetRepresentationToPoints();
|
actor->GetProperty()->SetRepresentationToPoints();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REPRESENTATION_SURFACE:
|
case REPRESENTATION_SURFACE:
|
||||||
{
|
{
|
||||||
while ((actor = actors->GetNextActor()) != NULL)
|
while ((actor = actors->GetNextActor()) != NULL)
|
||||||
actor->GetProperty()->SetRepresentationToSurface();
|
actor->GetProperty()->SetRepresentationToSurface();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REPRESENTATION_WIREFRAME:
|
case REPRESENTATION_WIREFRAME:
|
||||||
{
|
{
|
||||||
while ((actor = actors->GetNextActor()) != NULL)
|
while ((actor = actors->GetNextActor()) != NULL)
|
||||||
actor->GetProperty()->SetRepresentationToWireframe();
|
actor->GetProperty()->SetRepresentationToWireframe();
|
||||||
|
@ -58,20 +58,20 @@ public:
|
|||||||
typedef cv::Ptr<VizImpl> Ptr;
|
typedef cv::Ptr<VizImpl> Ptr;
|
||||||
typedef Viz3d::KeyboardCallback KeyboardCallback;
|
typedef Viz3d::KeyboardCallback KeyboardCallback;
|
||||||
typedef Viz3d::MouseCallback MouseCallback;
|
typedef Viz3d::MouseCallback MouseCallback;
|
||||||
|
|
||||||
int ref_counter;
|
int ref_counter;
|
||||||
|
|
||||||
VizImpl(const String &name);
|
VizImpl(const String &name);
|
||||||
virtual ~VizImpl();
|
virtual ~VizImpl();
|
||||||
|
|
||||||
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
||||||
void removeWidget(const String &id);
|
void removeWidget(const String &id);
|
||||||
Widget getWidget(const String &id) const;
|
Widget getWidget(const String &id) const;
|
||||||
void removeAllWidgets();
|
void removeAllWidgets();
|
||||||
|
|
||||||
void setWidgetPose(const String &id, const Affine3f &pose);
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
|
||||||
void setDesiredUpdateRate(double rate);
|
void setDesiredUpdateRate(double rate);
|
||||||
double getDesiredUpdateRate();
|
double getDesiredUpdateRate();
|
||||||
@ -86,7 +86,7 @@ public:
|
|||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
stopped_ = true;
|
stopped_ = true;
|
||||||
if (interactor_)
|
if (interactor_)
|
||||||
{
|
{
|
||||||
interactor_->GetRenderWindow()->Finalize();
|
interactor_->GetRenderWindow()->Finalize();
|
||||||
interactor_->TerminateApp(); // This tends to close the window...
|
interactor_->TerminateApp(); // This tends to close the window...
|
||||||
@ -94,14 +94,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setRepresentation(int representation);
|
void setRepresentation(int representation);
|
||||||
|
|
||||||
void setCamera(const Camera &camera);
|
void setCamera(const Camera &camera);
|
||||||
Camera getCamera() const;
|
Camera getCamera() const;
|
||||||
|
|
||||||
/** \brief Reset the camera to a given widget */
|
/** \brief Reset the camera to a given widget */
|
||||||
void resetCameraViewpoint(const String& id);
|
void resetCameraViewpoint(const String& id);
|
||||||
void resetCamera();
|
void resetCamera();
|
||||||
|
|
||||||
void setViewerPose(const Affine3f &pose);
|
void setViewerPose(const Affine3f &pose);
|
||||||
Affine3f getViewerPose();
|
Affine3f getViewerPose();
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ private:
|
|||||||
|
|
||||||
/** \brief The render window interactor style. */
|
/** \brief The render window interactor style. */
|
||||||
vtkSmartPointer<InteractorStyle> style_;
|
vtkSmartPointer<InteractorStyle> style_;
|
||||||
|
|
||||||
/** \brief Internal list with actor pointers and name IDs for all widget actors */
|
/** \brief Internal list with actor pointers and name IDs for all widget actors */
|
||||||
cv::Ptr<WidgetActorMap> widget_actor_map_;
|
cv::Ptr<WidgetActorMap> widget_actor_map_;
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ namespace cv
|
|||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _Out* copyColor(const Mat& source, _Out* output, const Mat& nan_mask)
|
static _Out* copyColor(const Mat& source, _Out* output, const Mat& nan_mask)
|
||||||
{
|
{
|
||||||
CV_Assert(DataDepth<_Tp>::value == source.depth() && source.size() == nan_mask.size());
|
CV_Assert(DataDepth<_Tp>::value == source.depth() && source.size() == nan_mask.size());
|
||||||
@ -282,7 +282,7 @@ namespace cv
|
|||||||
|
|
||||||
return table[nan_mask.depth() - 5](source, output, nan_mask);
|
return table[nan_mask.depth() - 5](source, output, nan_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static inline Vec<_Tp, 3>* copyColor(const Mat& source, Vec<_Tp, 3>* output, const Mat& nan_mask)
|
static inline Vec<_Tp, 3>* copyColor(const Mat& source, Vec<_Tp, 3>* output, const Mat& nan_mask)
|
||||||
{
|
{
|
||||||
@ -328,7 +328,7 @@ namespace cv
|
|||||||
|
|
||||||
inline Vec3d vtkpoint(const Point3f& point) { return Vec3d(point.x, point.y, point.z); }
|
inline Vec3d vtkpoint(const Point3f& point) { return Vec3d(point.x, point.y, point.z); }
|
||||||
template<typename _Tp> inline _Tp normalized(const _Tp& v) { return v * 1/cv::norm(v); }
|
template<typename _Tp> inline _Tp normalized(const _Tp& v) { return v * 1/cv::norm(v); }
|
||||||
|
|
||||||
struct ConvertToVtkImage
|
struct ConvertToVtkImage
|
||||||
{
|
{
|
||||||
struct Impl
|
struct Impl
|
||||||
@ -336,7 +336,7 @@ namespace cv
|
|||||||
static void copyImageMultiChannel(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
static void copyImageMultiChannel(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
||||||
{
|
{
|
||||||
int i_chs = image.channels();
|
int i_chs = image.channels();
|
||||||
|
|
||||||
for (int i = 0; i < image.rows; ++i)
|
for (int i = 0; i < image.rows; ++i)
|
||||||
{
|
{
|
||||||
const unsigned char * irows = image.ptr<unsigned char>(i);
|
const unsigned char * irows = image.ptr<unsigned char>(i);
|
||||||
@ -349,7 +349,7 @@ namespace cv
|
|||||||
}
|
}
|
||||||
output->Modified();
|
output->Modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyImageSingleChannel(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
static void copyImageSingleChannel(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < image.rows; ++i)
|
for (int i = 0; i < image.rows; ++i)
|
||||||
@ -364,7 +364,7 @@ namespace cv
|
|||||||
output->Modified();
|
output->Modified();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void convert(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
static void convert(const Mat &image, vtkSmartPointer<vtkImageData> output)
|
||||||
{
|
{
|
||||||
// Create the vtk image
|
// Create the vtk image
|
||||||
@ -376,7 +376,7 @@ namespace cv
|
|||||||
#else
|
#else
|
||||||
output->AllocateScalars(VTK_UNSIGNED_CHAR, image.channels());
|
output->AllocateScalars(VTK_UNSIGNED_CHAR, image.channels());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int i_chs = image.channels();
|
int i_chs = image.channels();
|
||||||
if (i_chs > 1)
|
if (i_chs > 1)
|
||||||
{
|
{
|
||||||
|
@ -55,14 +55,14 @@ class cv::viz::Widget::Impl
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkSmartPointer<vtkProp> prop;
|
vtkSmartPointer<vtkProp> prop;
|
||||||
|
|
||||||
Impl() : prop(0) {}
|
Impl() : prop(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
cv::viz::Widget::Widget() : impl_( new Impl() ) { }
|
cv::viz::Widget::Widget() : impl_( new Impl() ) { }
|
||||||
|
|
||||||
cv::viz::Widget::Widget(const Widget& other) : impl_( new Impl() )
|
cv::viz::Widget::Widget(const Widget& other) : impl_( new Impl() )
|
||||||
{
|
{
|
||||||
if (other.impl_ && other.impl_->prop) impl_->prop = other.impl_->prop;
|
if (other.impl_ && other.impl_->prop) impl_->prop = other.impl_->prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ cv::viz::Widget& cv::viz::Widget::operator=(const Widget& other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::viz::Widget::~Widget()
|
cv::viz::Widget::~Widget()
|
||||||
{
|
{
|
||||||
if (impl_)
|
if (impl_)
|
||||||
{
|
{
|
||||||
delete impl_;
|
delete impl_;
|
||||||
@ -86,7 +86,7 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
|
|||||||
{
|
{
|
||||||
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
|
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
|
||||||
reader->SetFileName(file_name.c_str());
|
reader->SetFileName(file_name.c_str());
|
||||||
|
|
||||||
vtkSmartPointer<vtkDataSet> data = reader->GetOutput();
|
vtkSmartPointer<vtkDataSet> data = reader->GetOutput();
|
||||||
CV_Assert("File does not exist or file format is not supported." && data);
|
CV_Assert("File does not exist or file format is not supported." && data);
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
|
|||||||
actor->GetProperty()->BackfaceCullingOn();
|
actor->GetProperty()->BackfaceCullingOn();
|
||||||
|
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
Widget widget;
|
Widget widget;
|
||||||
widget.impl_->prop = actor;
|
widget.impl_->prop = actor;
|
||||||
return widget;
|
return widget;
|
||||||
@ -130,7 +130,7 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
|
|||||||
{
|
{
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget type is not supported." && actor);
|
CV_Assert("Widget type is not supported." && actor);
|
||||||
|
|
||||||
switch (property)
|
switch (property)
|
||||||
{
|
{
|
||||||
case POINT_SIZE:
|
case POINT_SIZE:
|
||||||
@ -218,8 +218,8 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
|
|||||||
actor->Modified();
|
actor->Modified();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
CV_Assert("setPointCloudRenderingProperties: Unknown property");
|
CV_Assert("setPointCloudRenderingProperties: Unknown property");
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ double cv::viz::Widget::getRenderingProperty(int property) const
|
|||||||
{
|
{
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget type is not supported." && actor);
|
CV_Assert("Widget type is not supported." && actor);
|
||||||
|
|
||||||
double value = 0.0;
|
double value = 0.0;
|
||||||
switch (property)
|
switch (property)
|
||||||
{
|
{
|
||||||
@ -313,7 +313,7 @@ struct cv::viz::Widget3D::MatrixConverter
|
|||||||
m(i, k) = vtk_matrix->GetElement(i, k);
|
m(i, k) = vtk_matrix->GetElement(i, k);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix(const Matx44f& m)
|
static vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix(const Matx44f& m)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||||
@ -328,7 +328,7 @@ void cv::viz::Widget3D::setPose(const Affine3f &pose)
|
|||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget is not 3D." && actor);
|
CV_Assert("Widget is not 3D." && actor);
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
||||||
actor->SetUserMatrix(matrix);
|
actor->SetUserMatrix(matrix);
|
||||||
actor->Modified();
|
actor->Modified();
|
||||||
@ -338,7 +338,7 @@ void cv::viz::Widget3D::updatePose(const Affine3f &pose)
|
|||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget is not 3D." && actor);
|
CV_Assert("Widget is not 3D." && actor);
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||||
if (!matrix)
|
if (!matrix)
|
||||||
{
|
{
|
||||||
@ -358,7 +358,7 @@ cv::Affine3f cv::viz::Widget3D::getPose() const
|
|||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget is not 3D." && actor);
|
CV_Assert("Widget is not 3D." && actor);
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||||
Matx44f matrix_cv = MatrixConverter::convertToMatx(matrix);
|
Matx44f matrix_cv = MatrixConverter::convertToMatx(matrix);
|
||||||
return Affine3f(matrix_cv);
|
return Affine3f(matrix_cv);
|
||||||
@ -369,7 +369,7 @@ void cv::viz::Widget3D::setColor(const Color &color)
|
|||||||
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert("Widget type is not supported." && actor);
|
CV_Assert("Widget type is not supported." && actor);
|
||||||
|
|
||||||
Color c = vtkcolor(color);
|
Color c = vtkcolor(color);
|
||||||
actor->GetMapper()->ScalarVisibilityOff();
|
actor->GetMapper()->ScalarVisibilityOff();
|
||||||
actor->GetProperty()->SetColor(c.val);
|
actor->GetProperty()->SetColor(c.val);
|
||||||
|
@ -110,23 +110,23 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
for (int i = 0, j = 0; i <= 360; ++i, j+=5)
|
for (int i = 0, j = 0; i <= 360; ++i, j+=5)
|
||||||
{
|
{
|
||||||
cam_path.push_back(viz::makeCameraPose(Point3f(0.5*cos(double(i)*CV_PI/180.0), 0.5*sin(double(j)*CV_PI/180.0), 0.5*sin(double(i)*CV_PI/180.0)),
|
cam_path.push_back(viz::makeCameraPose(Point3f(0.5*cos(double(i)*CV_PI/180.0), 0.5*sin(double(j)*CV_PI/180.0), 0.5*sin(double(i)*CV_PI/180.0)),
|
||||||
Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0)));
|
Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int path_counter = 0;
|
int path_counter = 0;
|
||||||
int cam_path_size = cam_path.size();
|
int cam_path_size = cam_path.size();
|
||||||
|
|
||||||
// OTHER WIDGETS
|
// OTHER WIDGETS
|
||||||
cv::Mat img = imread("opencv.png");
|
cv::Mat img = imread("opencv.png");
|
||||||
|
|
||||||
int downSample = 4;
|
int downSample = 4;
|
||||||
|
|
||||||
int row_max = img.rows/downSample;
|
int row_max = img.rows/downSample;
|
||||||
int col_max = img.cols/downSample;
|
int col_max = img.cols/downSample;
|
||||||
|
|
||||||
cv::Mat *clouds = new cv::Mat[img.cols/downSample];
|
cv::Mat *clouds = new cv::Mat[img.cols/downSample];
|
||||||
cv::Mat *colors = new cv::Mat[img.cols/downSample];
|
cv::Mat *colors = new cv::Mat[img.cols/downSample];
|
||||||
|
|
||||||
for (int col = 0; col < col_max; ++col)
|
for (int col = 0; col < col_max; ++col)
|
||||||
{
|
{
|
||||||
clouds[col] = Mat::zeros(img.rows/downSample, 1, CV_32FC3);
|
clouds[col] = Mat::zeros(img.rows/downSample, 1, CV_32FC3);
|
||||||
@ -137,7 +137,7 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
colors[col].at<Vec3b>(row) = img.at<Vec3b>(row*downSample,col*downSample);
|
colors[col].at<Vec3b>(row) = img.at<Vec3b>(row*downSample,col*downSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int col = 0; col < col_max; ++col)
|
for (int col = 0; col < col_max; ++col)
|
||||||
{
|
{
|
||||||
std::stringstream strstrm;
|
std::stringstream strstrm;
|
||||||
@ -146,16 +146,16 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
viz.getWidget(strstrm.str()).setRenderingProperty(viz::POINT_SIZE, 3.0);
|
viz.getWidget(strstrm.str()).setRenderingProperty(viz::POINT_SIZE, 3.0);
|
||||||
viz.getWidget(strstrm.str()).setRenderingProperty(viz::OPACITY, 0.45);
|
viz.getWidget(strstrm.str()).setRenderingProperty(viz::OPACITY, 0.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
viz.showWidget("trajectory", viz::WTrajectory(cam_path, viz::WTrajectory::DISPLAY_PATH, viz::Color::yellow()));
|
viz.showWidget("trajectory", viz::WTrajectory(cam_path, viz::WTrajectory::DISPLAY_PATH, viz::Color::yellow()));
|
||||||
viz.showWidget("cam_text", viz::WText("Global View", Point2i(5,5), 28));
|
viz.showWidget("cam_text", viz::WText("Global View", Point2i(5,5), 28));
|
||||||
viz.registerKeyboardCallback(keyboard_callback, (void *) &viz);
|
viz.registerKeyboardCallback(keyboard_callback, (void *) &viz);
|
||||||
|
|
||||||
int angle = 0;
|
int angle = 0;
|
||||||
|
|
||||||
while(!viz.wasStopped())
|
while(!viz.wasStopped())
|
||||||
{
|
{
|
||||||
if (path_counter == cam_path_size)
|
if (path_counter == cam_path_size)
|
||||||
{
|
{
|
||||||
path_counter = 0;
|
path_counter = 0;
|
||||||
}
|
}
|
||||||
@ -164,12 +164,12 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
{
|
{
|
||||||
viz.setViewerPose(cam_path[path_counter]);
|
viz.setViewerPose(cam_path[path_counter]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angle == 360) angle = 0;
|
if (angle == 360) angle = 0;
|
||||||
|
|
||||||
cam_1.cast<viz::WCameraPosition>().setPose(cam_path[path_counter]);
|
cam_1.cast<viz::WCameraPosition>().setPose(cam_path[path_counter]);
|
||||||
cam_coordinates.cast<viz::WCameraPosition>().setPose(cam_path[path_counter++]);
|
cam_coordinates.cast<viz::WCameraPosition>().setPose(cam_path[path_counter++]);
|
||||||
|
|
||||||
for (int i = 0; i < col_max; ++i)
|
for (int i = 0; i < col_max; ++i)
|
||||||
{
|
{
|
||||||
std::stringstream strstrm;
|
std::stringstream strstrm;
|
||||||
|
@ -82,7 +82,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|||||||
if(NOT HAVE_opencv_gpuarithm OR NOT HAVE_opencv_gpufilters)
|
if(NOT HAVE_opencv_gpuarithm OR NOT HAVE_opencv_gpufilters)
|
||||||
ocv_list_filterout(cpp_samples "/gpu/")
|
ocv_list_filterout(cpp_samples "/gpu/")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
ocv_list_filterout(cpp_samples "viz")
|
ocv_list_filterout(cpp_samples "viz")
|
||||||
|
|
||||||
foreach(sample_filename ${cpp_samples})
|
foreach(sample_filename ${cpp_samples})
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <opencv2/viz.hpp>
|
#include <opencv2/viz.hpp>
|
||||||
#include <opencv2/viz/widget_accessor.hpp>
|
#include <opencv2/viz/widget_accessor.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <vtkPoints.h>
|
#include <vtkPoints.h>
|
||||||
@ -42,7 +42,7 @@ void help()
|
|||||||
class WTriangle : public viz::Widget3D
|
class WTriangle : public viz::Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,22 +56,22 @@ WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3,
|
|||||||
points->InsertNextPoint(pt1.x, pt1.y, pt1.z);
|
points->InsertNextPoint(pt1.x, pt1.y, pt1.z);
|
||||||
points->InsertNextPoint(pt2.x, pt2.y, pt2.z);
|
points->InsertNextPoint(pt2.x, pt2.y, pt2.z);
|
||||||
points->InsertNextPoint(pt3.x, pt3.y, pt3.z);
|
points->InsertNextPoint(pt3.x, pt3.y, pt3.z);
|
||||||
|
|
||||||
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
|
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
|
||||||
triangle->GetPointIds()->SetId(0,0);
|
triangle->GetPointIds()->SetId(0,0);
|
||||||
triangle->GetPointIds()->SetId(1,1);
|
triangle->GetPointIds()->SetId(1,1);
|
||||||
triangle->GetPointIds()->SetId(2,2);
|
triangle->GetPointIds()->SetId(2,2);
|
||||||
|
|
||||||
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
|
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
|
||||||
cells->InsertNextCell(triangle);
|
cells->InsertNextCell(triangle);
|
||||||
|
|
||||||
// Create a polydata object
|
// Create a polydata object
|
||||||
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
// Add the geometry and topology to the polydata
|
// Add the geometry and topology to the polydata
|
||||||
polyData->SetPoints(points);
|
polyData->SetPoints(points);
|
||||||
polyData->SetPolys(cells);
|
polyData->SetPolys(cells);
|
||||||
|
|
||||||
// Create mapper and actor
|
// Create mapper and actor
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
#if VTK_MAJOR_VERSION <= 5
|
#if VTK_MAJOR_VERSION <= 5
|
||||||
@ -79,13 +79,13 @@ WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3,
|
|||||||
#else
|
#else
|
||||||
mapper->SetInputData(polyData);
|
mapper->SetInputData(polyData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
// Store this actor in the widget in order that visualizer can access it
|
// Store this actor in the widget in order that visualizer can access it
|
||||||
viz::WidgetAccessor::setProp(*this, actor);
|
viz::WidgetAccessor::setProp(*this, actor);
|
||||||
|
|
||||||
// Set the color of the widget. This has to be called after WidgetAccessor.
|
// Set the color of the widget. This has to be called after WidgetAccessor.
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
@ -96,18 +96,18 @@ WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3,
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
help();
|
help();
|
||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Creating Widgets");
|
viz::Viz3d myWindow("Creating Widgets");
|
||||||
|
|
||||||
/// Create a triangle widget
|
/// Create a triangle widget
|
||||||
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
||||||
|
|
||||||
/// Show widget in the visualizer window
|
/// Show widget in the visualizer window
|
||||||
myWindow.showWidget("TRIANGLE", tw);
|
myWindow.showWidget("TRIANGLE", tw);
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,33 +33,33 @@ int main()
|
|||||||
help();
|
help();
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Viz Demo");
|
viz::Viz3d myWindow("Viz Demo");
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
cout << "First event loop is over" << endl;
|
cout << "First event loop is over" << endl;
|
||||||
|
|
||||||
/// Access window via its name
|
/// Access window via its name
|
||||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
||||||
|
|
||||||
/// Start event loop
|
/// Start event loop
|
||||||
sameWindow.spin();
|
sameWindow.spin();
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
cout << "Second event loop is over" << endl;
|
cout << "Second event loop is over" << endl;
|
||||||
|
|
||||||
/// Event loop is over when pressed q, Q, e, E
|
/// Event loop is over when pressed q, Q, e, E
|
||||||
/// Start event loop once for 1 millisecond
|
/// Start event loop once for 1 millisecond
|
||||||
sameWindow.spinOnce(1, true);
|
sameWindow.spinOnce(1, true);
|
||||||
while(!sameWindow.wasStopped())
|
while(!sameWindow.wasStopped())
|
||||||
{
|
{
|
||||||
/// Interact with window
|
/// Interact with window
|
||||||
|
|
||||||
/// Event loop for 1 millisecond
|
/// Event loop for 1 millisecond
|
||||||
sameWindow.spinOnce(1, true);
|
sameWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Once more event loop is stopped
|
/// Once more event loop is stopped
|
||||||
cout << "Last event loop is over" << endl;
|
cout << "Last event loop is over" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,7 +44,7 @@ Mat cvcloud_load()
|
|||||||
float dummy1, dummy2;
|
float dummy1, dummy2;
|
||||||
for(size_t i = 0; i < 1889; ++i)
|
for(size_t i = 0; i < 1889; ++i)
|
||||||
ifs >> data[i].x >> data[i].y >> data[i].z >> dummy1 >> dummy2;
|
ifs >> data[i].x >> data[i].y >> data[i].z >> dummy1 >> dummy2;
|
||||||
|
|
||||||
cloud *= 5.0f;
|
cloud *= 5.0f;
|
||||||
return cloud;
|
return cloud;
|
||||||
}
|
}
|
||||||
@ -55,40 +55,40 @@ Mat cvcloud_load()
|
|||||||
int main(int argn, char **argv)
|
int main(int argn, char **argv)
|
||||||
{
|
{
|
||||||
help();
|
help();
|
||||||
|
|
||||||
if (argn < 2)
|
if (argn < 2)
|
||||||
{
|
{
|
||||||
cout << "Missing arguments." << endl;
|
cout << "Missing arguments." << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool camera_pov = (argv[1][0] == 'C');
|
bool camera_pov = (argv[1][0] == 'C');
|
||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Coordinate Frame");
|
viz::Viz3d myWindow("Coordinate Frame");
|
||||||
|
|
||||||
/// Add coordinate axes
|
/// Add coordinate axes
|
||||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||||
|
|
||||||
/// Let's assume camera has the following properties
|
/// Let's assume camera has the following properties
|
||||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||||
|
|
||||||
/// We can get the pose of the cam using makeCameraPose
|
/// We can get the pose of the cam using makeCameraPose
|
||||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||||
|
|
||||||
/// We can get the transformation matrix from camera coordinate system to global using
|
/// We can get the transformation matrix from camera coordinate system to global using
|
||||||
/// - makeTransformToGlobal. We need the axes of the camera
|
/// - makeTransformToGlobal. We need the axes of the camera
|
||||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||||
|
|
||||||
/// Create a cloud widget.
|
/// Create a cloud widget.
|
||||||
Mat bunny_cloud = cvcloud_load();
|
Mat bunny_cloud = cvcloud_load();
|
||||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||||
|
|
||||||
/// Pose of the widget in camera frame
|
/// Pose of the widget in camera frame
|
||||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||||
/// Pose of the widget in global frame
|
/// Pose of the widget in global frame
|
||||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||||
|
|
||||||
/// Visualize camera frame
|
/// Visualize camera frame
|
||||||
if (!camera_pov)
|
if (!camera_pov)
|
||||||
{
|
{
|
||||||
@ -97,16 +97,16 @@ int main(int argn, char **argv)
|
|||||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visualize widget
|
/// Visualize widget
|
||||||
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
||||||
|
|
||||||
/// Set the viewer pose to that of camera
|
/// Set the viewer pose to that of camera
|
||||||
if (camera_pov)
|
if (camera_pov)
|
||||||
myWindow.setViewerPose(cam_pose);
|
myWindow.setViewerPose(cam_pose);
|
||||||
|
|
||||||
/// Start event loop.
|
/// Start event loop.
|
||||||
myWindow.spin();
|
myWindow.spin();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -32,23 +32,23 @@ void help()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
help();
|
help();
|
||||||
|
|
||||||
/// Create a window
|
/// Create a window
|
||||||
viz::Viz3d myWindow("Coordinate Frame");
|
viz::Viz3d myWindow("Coordinate Frame");
|
||||||
|
|
||||||
/// Add coordinate axes
|
/// Add coordinate axes
|
||||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||||
|
|
||||||
/// Add line to represent (1,1,1) axis
|
/// Add line to represent (1,1,1) axis
|
||||||
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
||||||
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
myWindow.showWidget("Line Widget", axis);
|
myWindow.showWidget("Line Widget", axis);
|
||||||
|
|
||||||
/// Construct a cube widget
|
/// Construct a cube widget
|
||||||
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
||||||
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||||
myWindow.showWidget("Cube Widget", cube_widget);
|
myWindow.showWidget("Cube Widget", cube_widget);
|
||||||
|
|
||||||
/// Rodrigues vector
|
/// Rodrigues vector
|
||||||
Mat rot_vec = Mat::zeros(1,3,CV_32F);
|
Mat rot_vec = Mat::zeros(1,3,CV_32F);
|
||||||
float translation_phase = 0.0, translation = 0.0;
|
float translation_phase = 0.0, translation = 0.0;
|
||||||
@ -59,21 +59,21 @@ int main()
|
|||||||
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
||||||
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
||||||
|
|
||||||
/// Shift on (1,1,1)
|
/// Shift on (1,1,1)
|
||||||
translation_phase += CV_PI * 0.01f;
|
translation_phase += CV_PI * 0.01f;
|
||||||
translation = sin(translation_phase);
|
translation = sin(translation_phase);
|
||||||
|
|
||||||
Mat rot_mat;
|
Mat rot_mat;
|
||||||
Rodrigues(rot_vec, rot_mat);
|
Rodrigues(rot_vec, rot_mat);
|
||||||
|
|
||||||
/// Construct pose
|
/// Construct pose
|
||||||
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
||||||
|
|
||||||
myWindow.setWidgetPose("Cube Widget", pose);
|
myWindow.setWidgetPose("Cube Widget", pose);
|
||||||
|
|
||||||
myWindow.spinOnce(1, true);
|
myWindow.spinOnce(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user