In this tutorial you will learn how to import a reconstruction from a given file obtained with Bundler [1]:
#include <iostream>
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 <path_to_file>\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<Mat> Rs, Ts, Ks, points3d;
viz::Viz3d window("Coordinate Frame");
window.setWindowSize(
Size(500,500));
window.setWindowPosition(
Point(150,150));
window.setBackgroundColor();
vector<Vec3d> point_cloud;
for (int i = 0; i < points3d.size(); ++i){
point_cloud.push_back(
Vec3f(points3d[i]));
}
vector<Affine3d> path;
for (size_t i = 0; i < Rs.size(); ++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;
}
Point2i Point
Definition: modules/core/include/opencv2/core/types.hpp:209
Size2i Size
Definition: modules/core/include/opencv2/core/types.hpp:370
Vec< float, 2 > Vec2f
Definition: matx.hpp:458
Vec< float, 3 > Vec3f
Definition: matx.hpp:459
Affine3< double > Affine3d
Definition: affine.hpp:291
void importReconstruction(const cv::String &file, OutputArrayOfArrays Rs, OutputArrayOfArrays Ts, OutputArrayOfArrays Ks, OutputArrayOfArrays points3d, int file_format=SFM_IO_BUNDLER)
Import a reconstruction file.
@ SFM_IO_BUNDLER
Definition: io.hpp:58
int main(int argc, char *argv[])
Definition: highgui_qt.cpp:3
Definition: conditioning.hpp:44
Definition: core/include/opencv2/core.hpp:107
[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