#include <iostream>
#include <fstream>
static void help()
{
cout
<< "--------------------------------------------------------------------------" << endl
<< "This program shows how to use makeTransformToGlobal() to compute required pose,"
<< "how to use makeCameraPose and Viz3d::setViewerPose. You can observe the scene "
<< "from camera point of view (C) or global point of view (G)" << endl
<< "Usage:" << endl
<< "./transformations [ G | C ]" << endl
<< endl;
}
static Mat cvcloud_load()
{
ifstream ifs("bunny.ply");
string str;
for(size_t i = 0; i < 12; ++i)
getline(ifs, str);
float dummy1, dummy2;
for(size_t i = 0; i < 1889; ++i)
ifs >> data[i].x >> data[i].y >> data[i].
z >> dummy1 >> dummy2;
cloud *= 5.0f;
return cloud;
}
int main(int argn, char **argv)
{
help();
if (argn < 2)
{
cout << "Missing arguments." << endl;
return 1;
}
bool camera_pov = (argv[1][0] == 'C');
Vec3f 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);
Mat bunny_cloud = cvcloud_load();
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
if (!camera_pov)
{
myWindow.showWidget("CPW", cpw, cam_pose);
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
}
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
if (camera_pov)
myWindow.setViewerPose(cam_pose);
myWindow.spin();
return 0;
}
Affine3 translate(const Vec3 &t) const
a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
n-dimensional dense array class
Definition: mat.hpp:811
The Viz3d class represents a 3D visualizer window. This class is implicitly shared.
Definition: viz3d.hpp:68
This 3D Widget represents camera position in a scene by its axes or viewing frustum....
Definition: widgets.hpp:544
Clouds.
Definition: widgets.hpp:681
Compound widgets.
Definition: widgets.hpp:514
void transform(InputArray src, OutputArray dst, InputArray m)
Performs the matrix transformation of every array element.
Vec< float, 2 > Vec2f
Definition: matx.hpp:435
Vec< float, 3 > Vec3f
Definition: matx.hpp:436
#define CV_32FC3
Definition: interface.h:120
Affine3< float > Affine3f
Definition: affine.hpp:290
@ z
Definition: gr_skig.hpp:67
Affine3d makeTransformToGlobal(const Vec3d &axis_x, const Vec3d &axis_y, const Vec3d &axis_z, const Vec3d &origin=Vec3d::all(0))
Takes coordinate frame data and builds transform to global coordinate frame.
Affine3d makeCameraPose(const Vec3d &position, const Vec3d &focal_point, const Vec3d &y_dir)
Constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more information...
"black box" representation of the file storage associated with a file on disk.
Definition: core.hpp:106