MCPcopy Create free account
hub / github.com/alicevision/AliceVision / exportToPMVSFormat

Function exportToPMVSFormat

src/software/export/main_exportPMVS.cpp:42–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40namespace fs = std::filesystem;
41
42bool exportToPMVSFormat(const SfMData& sfm_data,
43 const std::string& sOutDirectory, // Output PMVS files folder
44 const int downsampling_factor,
45 const int CPU_core_count,
46 const bool b_VisData = true)
47{
48 bool bOk = true;
49 if (!utils::exists(sOutDirectory))
50 {
51 fs::create_directory(sOutDirectory);
52 bOk = fs::is_directory(sOutDirectory);
53 }
54
55 // Create basis folder structure
56 fs::create_directory(fs::path(sOutDirectory) / std::string("models"));
57 fs::create_directory(fs::path(sOutDirectory) / std::string("txt"));
58 fs::create_directory(fs::path(sOutDirectory) / std::string("visualize"));
59
60 if (bOk && fs::is_directory(fs::path(sOutDirectory) / std::string("models")) && fs::is_directory(fs::path(sOutDirectory) / std::string("txt")) &&
61 fs::is_directory(fs::path(sOutDirectory) / std::string("visualize")))
62 {
63 bOk = true;
64 }
65 else
66 {
67 std::cerr << "Cannot access to one of the desired output folder" << std::endl;
68 }
69
70 if (bOk)
71 {
72 auto progressDisplay = system::createConsoleProgressDisplay(sfm_data.getViews().size() * 2, std::cout);
73
74 // Since PMVS requires contiguous camera index, and that some views can have some missing poses,
75 // we reindex the poses to ensure a contiguous pose list.
76 std::map<IndexT, IndexT> map_viewIdToContiguous;
77
78 // Export valid views as Projective Cameras:
79 for (Views::const_iterator iter = sfm_data.getViews().begin(); iter != sfm_data.getViews().end(); ++iter, ++progressDisplay)
80 {
81 const View* view = iter->second.get();
82 if (!sfm_data.isPoseAndIntrinsicDefined(view))
83 continue;
84
85 const Pose3 pose = sfm_data.getPose(*view).getTransform();
86 Intrinsics::const_iterator iterIntrinsic = sfm_data.getIntrinsics().find(view->getIntrinsicId());
87
88 // View Id re-indexing
89 map_viewIdToContiguous.insert(std::make_pair(view->getViewId(), map_viewIdToContiguous.size()));
90
91 std::shared_ptr<camera::IntrinsicBase> cam = iterIntrinsic->second;
92 std::shared_ptr<camera::Pinhole> camPinHole = std::dynamic_pointer_cast<camera::Pinhole>(cam);
93 if (!camPinHole)
94 {
95 ALICEVISION_LOG_ERROR("Camera is not pinhole in filter");
96 continue;
97 }
98
99 // We have a valid view with a corresponding camera & pose

Callers 1

aliceVision_mainFunction · 0.85

Calls 15

existsFunction · 0.85
pathClass · 0.85
readImageFunction · 0.85
UndistortImageFunction · 0.85
writeImageFunction · 0.85
ImageWriteOptionsClass · 0.85
getPoseMethod · 0.80
getIntrinsicIdMethod · 0.80
rowMethod · 0.80

Tested by

no test coverage detected