From 4b2d4ccfede76af0d778105bc01c74b97ae936c4 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Wed, 18 Aug 2021 10:25:44 +0200 Subject: [PATCH] [sfmDataIO] use integers for versions --- src/aliceVision/localization/LocalizationResult.cpp | 6 +++--- src/aliceVision/numeric/numeric.hpp | 5 ++++- src/aliceVision/sfmDataIO/jsonIO.cpp | 6 +++--- src/aliceVision/version.hpp | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/aliceVision/localization/LocalizationResult.cpp b/src/aliceVision/localization/LocalizationResult.cpp index b0491be695..55b0a65d3d 100644 --- a/src/aliceVision/localization/LocalizationResult.cpp +++ b/src/aliceVision/localization/LocalizationResult.cpp @@ -160,7 +160,7 @@ void LocalizationResult::load(std::vector& localizationResul // empty output vector localizationResults.clear(); - Vec3 version; + Vec3i version; // main tree bpt::ptree fileTree; @@ -204,7 +204,7 @@ void LocalizationResult::load(std::vector& localizationResul { IndexT intrinsicId; std::shared_ptr intrinsicPtr; - sfmDataIO::loadIntrinsic(version, intrinsicId, intrinsicPtr, lrTree.get_child("intrinsic")); + sfmDataIO::loadIntrinsic(Version(version), intrinsicId, intrinsicPtr, lrTree.get_child("intrinsic")); lr._intrinsics = *(dynamic_cast(intrinsicPtr.get())); } @@ -251,7 +251,7 @@ void LocalizationResult::save(const std::vector& localizatio { using namespace aliceVision::sfm; - const Vec3 version = {1, 0, 0}; + const Vec3i version = {1, 0, 0}; // main tree bpt::ptree fileTree; diff --git a/src/aliceVision/numeric/numeric.hpp b/src/aliceVision/numeric/numeric.hpp index 214805ad86..1475c13e95 100644 --- a/src/aliceVision/numeric/numeric.hpp +++ b/src/aliceVision/numeric/numeric.hpp @@ -69,9 +69,12 @@ using Eigen::Map; using EigenDoubleTraits = Eigen::NumTraits; using Vec3 = Eigen::Vector3d; +using Vec3i = Eigen::Vector3i; +using Vec3f = Eigen::Vector3f; + using Vec2i = Eigen::Vector2i; using Vec2f = Eigen::Vector2f; -using Vec3f = Eigen::Vector3f; + using Vec9 = Eigen::Matrix; using Quaternion = Eigen::Quaternion; diff --git a/src/aliceVision/sfmDataIO/jsonIO.cpp b/src/aliceVision/sfmDataIO/jsonIO.cpp index adebe20fa6..f6040de057 100644 --- a/src/aliceVision/sfmDataIO/jsonIO.cpp +++ b/src/aliceVision/sfmDataIO/jsonIO.cpp @@ -163,7 +163,7 @@ void loadIntrinsic(const Version & version, IndexT& intrinsicId, std::shared_ptr // Focal length Vec2 pxFocalLength; - if (version < Version(1,2,0)) // version < 1.2 + if (version < Version(1,2,0)) { pxFocalLength(0) = intrinsicTree.get("pxFocalLength", -1); // Only one focal value for X and Y in previous versions @@ -332,7 +332,7 @@ void loadLandmark(IndexT& landmarkId, sfmData::Landmark& landmark, bpt::ptree& l bool saveJSON(const sfmData::SfMData& sfmData, const std::string& filename, ESfMData partFlag) { - const Vec3 version = {ALICEVISION_SFMDATAIO_VERSION_MAJOR, ALICEVISION_SFMDATAIO_VERSION_MINOR, ALICEVISION_SFMDATAIO_VERSION_REVISION}; + const Vec3i version = {ALICEVISION_SFMDATAIO_VERSION_MAJOR, ALICEVISION_SFMDATAIO_VERSION_MINOR, ALICEVISION_SFMDATAIO_VERSION_REVISION}; // save flags const bool saveViews = (partFlag & VIEWS) == VIEWS; @@ -464,7 +464,7 @@ bool saveJSON(const sfmData::SfMData& sfmData, const std::string& filename, ESfM bool loadJSON(sfmData::SfMData& sfmData, const std::string& filename, ESfMData partFlag, bool incompleteViews, EViewIdMethod viewIdMethod, const std::string& viewIdRegex) { - Vec3 version; + Vec3i version; // load flags const bool loadViews = (partFlag & VIEWS) == VIEWS; diff --git a/src/aliceVision/version.hpp b/src/aliceVision/version.hpp index df317bf9d0..271ccc4ebb 100644 --- a/src/aliceVision/version.hpp +++ b/src/aliceVision/version.hpp @@ -26,17 +26,17 @@ namespace aliceVision { class Version { public: - Version(const Vec3 & v) : _v(v) + explicit Version(const Vec3i & v) : _v(v) { } - + Version(int major, int minor, int micro) : _v(major, minor, micro) { } bool operator<(const Version& other) const { - for (Vec3::Index i = 0; i < 3; i++) + for (Vec3i::Index i = 0; i < 3; i++) { if (_v[i] < other._v[i]) { @@ -53,7 +53,7 @@ class Version } private: - Vec3 _v; + Vec3i _v; }; } \ No newline at end of file