#include <iostream>
#include <fstream>
static void help()
{
cout
<< "--------------------------------------------------------------------------" << endl
<< "该程序展示了如何使用 makeTransformToGlobal() 计算所需的姿势,"
<< "如何使用 makeCameraPose 和 Viz3d::setViewerPose。你可以观察场景 "
<< "来自相机视点 (C) 或全局视点 (G)" << endl
<< "用法:" << 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 << "输入参数缺失" << 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);
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
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);
Mat bunny_cloud = cvcloud_load();
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
Affine3f cloud_pose_global = transform * cloud_pose;
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) 等价于 Affine(E, t) * a,其中 E 是单位矩阵
3D 点模板类,它具有 x、y、z 坐标。
定义 types.hpp:255
此 Viz3d 类代表一个 3D 可视化窗口。这个类是共享的。
定义 viz3d.hpp:68
这个 3D 构件可以通过它的轴或视锥来表示它的场景中的相机位置....
定义 widgets.hpp:544
#define CV_32FC3
定义 interface.h:120
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
与磁盘上的文件关联的文件存储的“黑匣子”表示。
定义 core.hpp:102