【计算机视觉】从运动中恢复结构SfM 三维重建-输入重建

来源OpenCV  3.2.0-dev

http://docs.opencv.org/master/de/dfd/tutorial_sfm_import_reconstruction.html

输入重建

目标

在本教程中,您将学习如何从一个给定的文件导入重建获得与打包机[1]:

  • 加载一个文件包含一组摄像机和3 d点。
  • 使用即显示结果。

结果

下图显示了一个从洛杉矶重建 圣家堂 (BCN)使用数据集[2]。

【计算机视觉】从运动中恢复结构SfM 三维重建-输入重建_第1张图片

 

代码

Code

#include

#include

#include

using namespace std;

using namespace cv;

using namespace cv::sfm;

static void help() {

cout

<< "\n---------------------------------------------------------------------------\n"

<< " This program shows how to import a reconstructed scene in the \n"

<< " OpenCV Structure From Motion (SFM) module.\n"

<< " Usage:\n"

<< " example_sfm_import_reconstruction \n"

<< " where: file_path is the absolute path file into your system which contains\n"

<< " the reconstructed scene. \n"

<< "---------------------------------------------------------------------------\n\n"

<< endl;

}

int main(int argc,char* argv[])

{

if ( argc != 2 ) {

help();

exit(0);

}

vector Rs, Ts, Ks, points3d;

importReconstruction(argv[1], Rs, Ts, Ks, points3d,SFM_IO_BUNDLER);

viz::Viz3d window("Coordinate Frame");

window.setWindowSize(Size(500,500));

window.setWindowPosition(Point(150,150));

window.setBackgroundColor(); // black by default

vector point_cloud;

for (int i = 0; i < points3d.size(); ++i){

point_cloud.push_back(Vec3f(points3d[i]));

}

vector path;

for (size_t i = 0; i < Rs.size(); ++i)

path.push_back(Affine3d(Rs[i], Ts[i]));

viz::WCloud cloud_widget(point_cloud, viz::Color::green());

viz::WTrajectory trajectory(path, viz::WTrajectory::FRAMES, 0.5);

viz::WTrajectoryFrustums frustums(path,Vec2f(0.889484, 0.523599), 0.5,

viz::Color::yellow());

window.showWidget("point_cloud", cloud_widget);

window.showWidget("cameras", trajectory);

window.showWidget("frustums", frustums);

cout << endl << "Press 'q' to close each windows ... " << endl;

window.spin();

return 0;

}

Results

The following picture shows a reconstruction from la Sagrada Familia (BCN) using dataset [2].

【计算机视觉】从运动中恢复结构SfM 三维重建-输入重建_第2张图片

[1] http://www.cs.cornell.edu/~snavely/bundler

[2] Penate Sanchez, A. and Moreno-Noguer, F. and Andrade Cetto, J. and Fleuret, F. (2014). LETHA: Learning from High Quality Inputs for 3D Pose Estimation in Low Quality Images. Proceedings of the International Conference on 3D vision (3DV). URL

 

 

 

你可能感兴趣的:(计算机视觉,图像处理,位姿测量,运动估计,三维重建)