目標
在本教程中,您將學習如何從使用 Bundler [1] 獲取的給定檔案中匯入重建。
- 載入包含一組相機和 3D 點的檔案。
- 使用 Viz 顯示獲得的結果。
程式碼
#include <iostream>
static void help() {
cout
<< "\n---------------------------------------------------------------------------\n"
<< " 此程式演示如何在 OpenCV 運動結構 (SFM) 模組中匯入重建場景。\n"
<< " OpenCV 運動結構 (SFM) 模組。\n"
<< " example_sfm_scene_reconstruction <檔案路徑> <f> <cx> <cy>\n"
<< " example_sfm_import_reconstruction <path_to_file>\n"
<< " 其中:file_path 是系統中包含重建場景的絕對路徑檔案。\n"
<< " 重建的場景。\n"
<< "---------------------------------------------------------------------------\n\n"
<< endl;
}
int main(
int argc,
char* argv[])
{
if ( argc != 2 ) {
help();
exit(0);
}
vector<Mat> Rs, Ts, Ks, points3d;
importReconstruction(argv[1], Rs, Ts, Ks, points3d, SFM_IO_BUNDLER);
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]));
}
for (size_t i = 0; i < Rs_est.size(); ++i)
for (size_t i = 0; i < Rs.size(); ++i)
viz::WCloud cloud_widget(point_cloud, viz::Color::green());
viz::Color::yellow());
window.showWidget("point_cloud", cloud_widget);
window.showWidget("cameras", trajectory);
window.showWidget("frustums", frustums);
cout << endl << "按 'q' 關閉每個視窗 ... " << endl;
cv::Affine3
return 0;
}
定義 affine.hpp:127
cv::Matx< double, 3, 3 >
用於指定影像或矩形大小的模板類。
Definition types.hpp:335
Viz3d 類表示 3D 視覺化視窗。此類是隱式共享的。
定義 viz3d.hpp:68
點雲.
Definition widgets.hpp:681
此 3D 小部件表示軌跡。
定義 widgets.hpp:605
int main(int argc, char *argv[])
定義 highgui_qt.cpp:3
結果
下圖顯示了使用資料集 [2] 從聖家族教堂 (BCN) 的重建。
[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