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

Function loadJSON

src/aliceVision/sfmDataIO/jsonIO.cpp:816–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814}
815
816bool loadJSON(sfmData::SfMData& sfmData,
817 const std::string& filename,
818 ESfMData partFlag,
819 bool incompleteViews,
820 EViewIdMethod viewIdMethod,
821 const std::string& viewIdRegex)
822{
823 Version version;
824
825 // load flags
826 const bool loadViews = (partFlag & VIEWS) == VIEWS;
827 const bool loadAncestors = (partFlag & ANCESTORS) == ANCESTORS;
828 const bool loadIntrinsics = (partFlag & INTRINSICS) == INTRINSICS;
829 const bool loadExtrinsics = (partFlag & EXTRINSICS) == EXTRINSICS;
830 const bool loadStructure = (partFlag & STRUCTURE) == STRUCTURE;
831 const bool loadSurveys = (partFlag & SURVEYS) == SURVEYS;
832 const bool loadFeatures = (partFlag & OBSERVATIONS_WITH_FEATURES) == OBSERVATIONS_WITH_FEATURES;
833 const bool loadObservations = loadFeatures || ((partFlag & OBSERVATIONS) == OBSERVATIONS);
834
835 // main tree
836 bpt::ptree fileTree;
837
838 // read the json file and initialize the tree
839 bpt::read_json(filename, fileTree);
840
841 // version
842 {
843 Vec3i v;
844 loadMatrix("version", v, fileTree);
845 version = v;
846
847 const Vec3i currentVersion = {ALICEVISION_SFMDATAIO_VERSION_MAJOR, ALICEVISION_SFMDATAIO_VERSION_MINOR, ALICEVISION_SFMDATAIO_VERSION_REVISION};
848 if (Version(currentVersion) < version)
849 {
850 ALICEVISION_LOG_ERROR("File has a version more recent than this library");
851 return false;
852 }
853 }
854
855 // folders
856 if (fileTree.count("featuresFolders"))
857 for (bpt::ptree::value_type& featureFolderNode : fileTree.get_child("featuresFolders"))
858 sfmData.addFeaturesFolder(featureFolderNode.second.get_value<std::string>());
859
860 if (fileTree.count("matchesFolders"))
861 for (bpt::ptree::value_type& matchingFolderNode : fileTree.get_child("matchesFolders"))
862 sfmData.addMatchesFolder(matchingFolderNode.second.get_value<std::string>());
863
864 // intrinsics
865 if (loadIntrinsics && fileTree.count("intrinsics"))
866 {
867 sfmData::Intrinsics& intrinsics = sfmData.getIntrinsics();
868
869 for (bpt::ptree::value_type& intrinsicNode : fileTree.get_child("intrinsics"))
870 {
871 IndexT intrinsicId;
872 std::shared_ptr<camera::IntrinsicBase> intrinsic;
873

Callers 2

loadFunction · 0.85
aliceVision_mainFunction · 0.85

Calls 15

loadMatrixFunction · 0.85
VersionClass · 0.85
loadIntrinsicFunction · 0.85
loadAncestorFunction · 0.85
loadViewFunction · 0.85
bootstrapViewFunction · 0.85
loadImageGroupFunction · 0.85
loadCameraPoseFunction · 0.85
loadRigFunction · 0.85
loadLandmarkFunction · 0.85
addFeaturesFolderMethod · 0.80
addMatchesFolderMethod · 0.80

Tested by

no test coverage detected