From e65267c8e113f2f7d0d2da90c3585e4c8852e72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Fri, 29 Mar 2019 11:43:18 +0000 Subject: [PATCH 1/7] Find GLog using "Config" mode --- CMakeLists.txt | 5 ++--- cmake_modules/FindGLog.cmake | 15 --------------- src/CMakeLists.txt | 6 +----- 3 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 cmake_modules/FindGLog.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5693cc8..334fda0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ SET(SOURCES ## Find required dependencies find_package( Eigen3 REQUIRED ) find_package( Sophus REQUIRED ) -find_package( GLog REQUIRED ) +find_package( GLog CONFIG REQUIRED ) find_package(TinyXML2 REQUIRED) list(APPEND CALIBU_INC ${TinyXML2_INCLUDE_DIRS} ) @@ -192,7 +192,7 @@ endif() # build calibu library add_library( calibu ${SOURCES} ) -target_link_libraries( calibu ${LINK_LIBS} ) +target_link_libraries( calibu ${LINK_LIBS} glog::glog) # install everything install_package( @@ -219,4 +219,3 @@ endif() add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) ########################### - diff --git a/cmake_modules/FindGLog.cmake b/cmake_modules/FindGLog.cmake deleted file mode 100644 index 06f34dd..0000000 --- a/cmake_modules/FindGLog.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# - Try to find glog (or miniglog for Android) -# Once done, this will define -# -# GLog_FOUND - system has glog -# GLog_INCLUDE_DIRS - the glog include directories -# GLog_LIBRARIES - link these to use glog - -# Find header and lib -find_path(GLog_INCLUDE_DIR NAMES glog/logging.h) -find_library(GLog_LIBRARIES NAMES glog) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLog DEFAULT_MSG GLog_INCLUDE_DIR GLog_LIBRARIES) -set(GLOG_INCLUDE_DIRS ${GLog_INCLUDE_DIRS}) -set(GLOG_LIBRARIES ${GLog_LIBRARIES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19b240f..410bd9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,11 +61,7 @@ SET(SOURCES ## Find required dependencies find_package( Eigen3 REQUIRED ) - -find_package( GLog REQUIRED ) -set(HAVE_GLOG 1) -list( APPEND LINK_LIBS ${GLog_LIBRARIES} ) -list( APPEND CALIBU_INC ${Glog_INCLUDE_DIRS} ) +find_package( GLog CONFIG REQUIRED ) # https://github.com/gwu-robotics/Sophus.git find_package( Sophus REQUIRED ) From 6a3446192e91b8912e3ceebed637e7c631cad7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Fri, 29 Mar 2019 12:34:56 +0000 Subject: [PATCH 2/7] Updating Sophus version (renaming Sophus::SxxGroup to Sophus::Sxx) --- include/calibu/calib/ReprojectionCost.h | 4 ++-- include/calibu/calib/ReprojectionCostFunctor.h | 4 ++-- include/calibu/cam/camera_crtp.h | 2 +- include/calibu/cam/camera_rig.h | 14 +++++++------- src/target/TargetGridDot.cpp | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/calibu/calib/ReprojectionCost.h b/include/calibu/calib/ReprojectionCost.h index e833c5f..c377ee0 100644 --- a/include/calibu/calib/ReprojectionCost.h +++ b/include/calibu/calib/ReprojectionCost.h @@ -46,8 +46,8 @@ struct ReprojectionCost bool Evaluate(T const* const* parameters, T* residuals) const { Eigen::Map > r(residuals); - const Eigen::Map > T_kw(parameters[0]); - const Eigen::Map > T_ck(parameters[1]); + const Eigen::Map > T_kw(parameters[0]); + const Eigen::Map > T_ck(parameters[1]); T const* camparam = parameters[2]; const Eigen::Matrix Pc = T_ck * (T_kw * m_Pw.cast()); diff --git a/include/calibu/calib/ReprojectionCostFunctor.h b/include/calibu/calib/ReprojectionCostFunctor.h index d796f98..a217585 100644 --- a/include/calibu/calib/ReprojectionCostFunctor.h +++ b/include/calibu/calib/ReprojectionCostFunctor.h @@ -48,8 +48,8 @@ struct ReprojectionCostFunctor ) const { Eigen::Map > r(residuals); - const Eigen::Map > T_kw(pT_kw); - const Eigen::Map > T_ck(pT_ck); + const Eigen::Map > T_kw(pT_kw); + const Eigen::Map > T_ck(pT_ck); const Eigen::Matrix Pc = T_ck * (T_kw * m_Pw.cast()); Eigen::Matrix pc; diff --git a/include/calibu/cam/camera_crtp.h b/include/calibu/cam/camera_crtp.h index b8b3e24..696751f 100644 --- a/include/calibu/cam/camera_crtp.h +++ b/include/calibu/cam/camera_crtp.h @@ -40,7 +40,7 @@ class CameraInterface { typedef Eigen::Matrix Vec2t; typedef Eigen::Matrix Vec3t; typedef Eigen::Matrix VecXt; - typedef Sophus::SE3Group SE3t; + typedef Sophus::SE3 SE3t; public: CameraInterface() {} diff --git a/include/calibu/cam/camera_rig.h b/include/calibu/cam/camera_rig.h index 0f6ad6c..04eaa95 100644 --- a/include/calibu/cam/camera_rig.h +++ b/include/calibu/cam/camera_rig.h @@ -41,12 +41,12 @@ static const Sophus::SO3d RdfRobotics = // T_2b_1b = T_ba * T_2a_1a * T_ab template -inline Sophus::SE3Group ToCoordinateConvention( - const Sophus::SE3Group& T_2a_1a, - const Sophus::SO3Group& R_ba +inline Sophus::SE3 ToCoordinateConvention( + const Sophus::SE3& T_2a_1a, + const Sophus::SO3& R_ba ) { - Sophus::SE3Group T_2b_1b; + Sophus::SE3 T_2b_1b; T_2b_1b.so3() = R_ba * T_2a_1a.so3() * R_ba.inverse(); T_2b_1b.translation() = R_ba * T_2a_1a.translation(); return T_2b_1b; @@ -55,14 +55,14 @@ inline Sophus::SE3Group ToCoordinateConvention( template inline std::shared_ptr> ToCoordinateConvention( const std::shared_ptr>& rig, - const Sophus::SO3Group& rdf + const Sophus::SO3& rdf ) { std::shared_ptr> ret(new calibu::Rig()); *ret = *rig; for(size_t c=0; cNumCams(); ++c) { - const Sophus::SO3Group M = - rdf * Sophus::SO3Group(rig->cameras_[c]->RDF()).inverse(); + const Sophus::SO3 M = + rdf * Sophus::SO3(rig->cameras_[c]->RDF()).inverse(); ret->cameras_[c]->SetPose(ToCoordinateConvention(rig->cameras_[c]->Pose(), M)); ret->cameras_[c]->SetRDF(rdf.matrix()); } diff --git a/src/target/TargetGridDot.cpp b/src/target/TargetGridDot.cpp index 1bb7005..4a199ba 100644 --- a/src/target/TargetGridDot.cpp +++ b/src/target/TargetGridDot.cpp @@ -359,16 +359,16 @@ bool TargetGridDot::Match(std::map T_0x[4] = { - Sophus::SE2Group(Sophus::SO2Group(1,0), Eigen::Vector2i(0,0) ), - Sophus::SE2Group(Sophus::SO2Group(0,1), Eigen::Vector2i(grid_size_[0]-1,0) ), - Sophus::SE2Group(Sophus::SO2Group(-1,0), Eigen::Vector2i(grid_size_[0]-1,grid_size_[1]-1) ), - Sophus::SE2Group(Sophus::SO2Group(0,-1), Eigen::Vector2i(0,grid_size_[1]-1) ) + Sophus::SE2 T_0x[4] = { + Sophus::SE2(Sophus::SO2(1,0), Eigen::Vector2i(0,0) ), + Sophus::SE2(Sophus::SO2(0,1), Eigen::Vector2i(grid_size_[0]-1,0) ), + Sophus::SE2(Sophus::SO2(-1,0), Eigen::Vector2i(grid_size_[0]-1,grid_size_[1]-1) ), + Sophus::SE2(Sophus::SO2(0,-1), Eigen::Vector2i(0,grid_size_[1]-1) ) }; - Sophus::SE2Group T_xm(Sophus::SO2Group(), Eigen::Vector2i(bc,br)); + Sophus::SE2 T_xm(Sophus::SO2(), Eigen::Vector2i(bc,br)); - Sophus::SE2Group T_0m = T_0x[bg] * T_xm; + Sophus::SE2 T_0m = T_0x[bg] * T_xm; for(auto i = obs.begin(); i != obs.end(); ++i) { i->second->pg = T_0m * i->second->pg; From c985602ce017a1d817a3a5362327fdf071976651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Fri, 29 Mar 2019 18:21:38 +0000 Subject: [PATCH 3/7] Add missing const --- include/calibu/cam/camera_crtp_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/calibu/cam/camera_crtp_impl.h b/include/calibu/cam/camera_crtp_impl.h index 2859fa1..3a2fb54 100644 --- a/include/calibu/cam/camera_crtp_impl.h +++ b/include/calibu/cam/camera_crtp_impl.h @@ -48,7 +48,7 @@ class CameraImpl : public CameraInterface { CameraImpl() {} virtual ~CameraImpl() {} - CameraImpl(const Eigen::VectorXd& params, Eigen::Vector2i& image_size) : + CameraImpl(const Eigen::VectorXd& params, const Eigen::Vector2i& image_size) : CameraInterface(params, image_size) { } From 510784168d3be40f033e7c599c544ed8210882c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Fri, 29 Mar 2019 18:53:34 +0000 Subject: [PATCH 4/7] Keep base (CameraImpl) implementation of 'Scale' visible. --- include/calibu/cam/camera_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/calibu/cam/camera_utils.h b/include/calibu/cam/camera_utils.h index 44f3833..e7a82c7 100644 --- a/include/calibu/cam/camera_utils.h +++ b/include/calibu/cam/camera_utils.h @@ -148,6 +148,7 @@ class LinearCamera : public CameraImpl > { typedef CameraImpl > Base; public: using Base::Base; + using Base::Scale; static constexpr int NumParams = 4; @@ -211,4 +212,3 @@ class LinearCamera : public CameraImpl > { }; }//end namespace calibu - From 2c401e28fbab9c5cc1592bf47c2f3340d797fdbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Thu, 4 Apr 2019 15:14:36 +0100 Subject: [PATCH 5/7] Keep base implementations of interface visible. --- include/calibu/cam/camera_models_kb4.h | 1 + include/calibu/cam/camera_models_poly.h | 1 + include/calibu/cam/camera_models_rational.h | 1 + include/calibu/cam/camera_utils.h | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/calibu/cam/camera_models_kb4.h b/include/calibu/cam/camera_models_kb4.h index 04da84e..2c72a52 100644 --- a/include/calibu/cam/camera_models_kb4.h +++ b/include/calibu/cam/camera_models_kb4.h @@ -41,6 +41,7 @@ class KannalaBrandtCamera : public CameraImpl > Base; public: using Base::Base; + using Base::Scale, Base::K, Base::Unproject, Base::Project, Base::dProject_dparams, Base::dUnproject_dparams, Base::dProject_dray; static constexpr int NumParams = 8; diff --git a/include/calibu/cam/camera_models_poly.h b/include/calibu/cam/camera_models_poly.h index 3c6da80..a7d4d8d 100644 --- a/include/calibu/cam/camera_models_poly.h +++ b/include/calibu/cam/camera_models_poly.h @@ -38,6 +38,7 @@ class FovCamera : public CameraImpl > { typedef CameraImpl > Base; public: using Base::Base; + using Base::Scale, Base::K, Base::Unproject, Base::Project, Base::dProject_dparams, Base::dUnproject_dparams, Base::dProject_dray; static constexpr int NumParams = 5; diff --git a/include/calibu/cam/camera_models_rational.h b/include/calibu/cam/camera_models_rational.h index cd2a825..2e6060f 100644 --- a/include/calibu/cam/camera_models_rational.h +++ b/include/calibu/cam/camera_models_rational.h @@ -41,6 +41,7 @@ class Rational6Camera : public CameraImpl > typedef CameraImpl > Base; public: using Base::Base; + using Base::Scale, Base::K, Base::Unproject, Base::Project, Base::dProject_dparams, Base::dUnproject_dparams, Base::dProject_dray; static constexpr int NumParams = 10; diff --git a/include/calibu/cam/camera_utils.h b/include/calibu/cam/camera_utils.h index e7a82c7..b9807e5 100644 --- a/include/calibu/cam/camera_utils.h +++ b/include/calibu/cam/camera_utils.h @@ -148,7 +148,7 @@ class LinearCamera : public CameraImpl > { typedef CameraImpl > Base; public: using Base::Base; - using Base::Scale; + using Base::Scale, Base::K, Base::Unproject, Base::Project, Base::dProject_dparams, Base::dUnproject_dparams, Base::dProject_dray; static constexpr int NumParams = 4; From e6dc02e255247aeaf4bbc154c9bd2edf090ae192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Sat, 6 Apr 2019 22:51:43 +0100 Subject: [PATCH 6/7] Add `Clone` function to `CameraInterface` --- include/calibu/cam/camera_crtp.h | 3 +++ include/calibu/cam/camera_crtp_impl.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/calibu/cam/camera_crtp.h b/include/calibu/cam/camera_crtp.h index 696751f..eda1be7 100644 --- a/include/calibu/cam/camera_crtp.h +++ b/include/calibu/cam/camera_crtp.h @@ -50,6 +50,9 @@ class CameraInterface { virtual ~CameraInterface() {} + /** Clone a camera model, useful when camera type is not known at compile time */ + virtual std::shared_ptr> Clone() = 0; + /** Change camera model image size. */ virtual void Scale( const Scalar& s ) = 0; diff --git a/include/calibu/cam/camera_crtp_impl.h b/include/calibu/cam/camera_crtp_impl.h index 3a2fb54..4d86b18 100644 --- a/include/calibu/cam/camera_crtp_impl.h +++ b/include/calibu/cam/camera_crtp_impl.h @@ -52,6 +52,12 @@ class CameraImpl : public CameraInterface { CameraInterface(params, image_size) { } + /** Clone a camera model, useful when camera type is not known at compile time */ + virtual std::shared_ptr> + Clone() { + return std::make_shared(static_cast(*this)); + }; + void Scale(const Scalar& s) override { Derived::Scale( s, this->params_.data() ); From af28ac15b90692352dc45d76cf6ea78e332cd5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCnz?= Date: Thu, 11 Apr 2019 22:34:58 +0100 Subject: [PATCH 7/7] Add missing include --- include/calibu/cam/camera_utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/calibu/cam/camera_utils.h b/include/calibu/cam/camera_utils.h index b9807e5..5ad650f 100644 --- a/include/calibu/cam/camera_utils.h +++ b/include/calibu/cam/camera_utils.h @@ -25,6 +25,9 @@ */ #pragma once + +#include + namespace calibu { struct CameraUtils { /** Euclidean distance from (0, 0) to given pixel */