From 690d2609960d9db4aa4e70f6b180d4e43e540cd2 Mon Sep 17 00:00:00 2001 From: Kumataro Date: Thu, 19 Jun 2025 19:48:48 +0900 Subject: [PATCH 1/3] sfm: support ng-log --- modules/sfm/CMakeLists.txt | 24 +++++++++++++++++-- modules/sfm/README.md | 23 ++++++++++++++---- .../sfm/cmake/checks/check_ng-log_gflags.cpp | 7 ++++++ .../src/libmv_light/libmv/logging/logging.h | 4 ++++ 4 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 modules/sfm/cmake/checks/check_ng-log_gflags.cpp diff --git a/modules/sfm/CMakeLists.txt b/modules/sfm/CMakeLists.txt index 46da72e309a..a6eb9cde723 100644 --- a/modules/sfm/CMakeLists.txt +++ b/modules/sfm/CMakeLists.txt @@ -9,10 +9,23 @@ find_package(Ceres QUIET) if(NOT Gflags_FOUND) # Ceres find gflags on the own, so separate search isn't necessary find_package(Gflags QUIET) endif() +if(NOT (Ng-log_FOUND OR ng-log_FOUND)) + find_package(ng-log QUIET) +endif() if(NOT (Glog_FOUND OR glog_FOUND)) # Ceres find glog on the own, so separate search isn't necessary find_package(Glog QUIET) endif() +if(Ng-log_FOUND OR ng-log_FOUND) + if(NOT (Glog_FOUND OR glog_FOUND)) + message(STATUS "sfm: ng-log is detected, but Google glog is not. ng-log(ver 0.9.x or later) is used") + set(glog_FOUND ON) + get_property(GLOG_INCLUDE_DIR TARGET ng-log::ng-log PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + else() + message(STATUS "sfm: Both ng-log and Google glog are detected. Google glog or ng-log(ver 0.8.x) is used") + endif() +endif() + if(NOT Gflags_FOUND OR NOT (Glog_FOUND OR glog_FOUND)) # try local search scripts list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -35,14 +48,21 @@ endif() if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR) set(GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR}") endif() +if(NOT GLOG_LIBRARIES AND TARGET ng-log::ng-log) + set(GLOG_NAME "ng-log") + set(GLOG_LIBRARIES ng-log::ng-log) + add_definitions("-DNGLOG_FOUND=1") +endif() if(NOT GLOG_LIBRARIES AND TARGET glog::glog) + set(GLOG_NAME "glog") set(GLOG_LIBRARIES glog::glog) + message(STATUS "Google glog is deprecated, ng-log is recommended.") endif() if((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS)) set(__cache_key "${GLOG_INCLUDE_DIRS} ~ ${GFLAGS_INCLUDE_DIRS} ~ ${GLOG_LIBRARIES} ~ ${GFLAGS_LIBRARIES}") if(NOT DEFINED SFM_GLOG_GFLAGS_TEST_CACHE_KEY OR NOT (SFM_GLOG_GFLAGS_TEST_CACHE_KEY STREQUAL __cache_key)) - set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_glog_gflags.cpp") + set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_${GLOG_NAME}_gflags.cpp") try_compile( SFM_GLOG_GFLAGS_TEST "${CMAKE_BINARY_DIR}" "${__fname}" CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS};${GFLAGS_INCLUDE_DIRS}" @@ -57,7 +77,7 @@ if((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (gl endif() set(SFM_GLOG_GFLAGS_TEST "${SFM_GLOG_GFLAGS_TEST}" CACHE INTERNAL "") set(SFM_GLOG_GFLAGS_TEST_CACHE_KEY "${__cache_key}" CACHE INTERNAL "") - message(STATUS "Checking SFM glog/gflags deps... ${SFM_GLOG_GFLAGS_TEST}") + message(STATUS "Checking SFM ${GLOG_NAME}/gflags deps... ${SFM_GLOG_GFLAGS_TEST}") endif() unset(__cache_key) set(SFM_DEPS_OK "${SFM_GLOG_GFLAGS_TEST}") diff --git a/modules/sfm/README.md b/modules/sfm/README.md index 83a860bce1e..ede07f85f82 100644 --- a/modules/sfm/README.md +++ b/modules/sfm/README.md @@ -11,9 +11,10 @@ Before compiling, take a look at the following details in order to give a proper In addition, it depends on some open source libraries: -- [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) 3.2.2 or later. **Required** -- [Google Log](http://code.google.com/p/google-glog) 0.3.1 or later. **Required** -- [Google Flags](http://code.google.com/p/gflags). **Required** +- [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page) 3.2.2 or later. **Required** +- [ng-log](https://github.com/ng-log/ng-log) 0.9.0 or later. **Required, use instead of Google glog** +- [Google Logging Library(glog)](https://github.com/google/glog) 0.3.1 or later. **Not recommended** +- [Google Flags](https://github.com/gflags/gflags). **Required** - [Ceres Solver](http://ceres-solver.org). Needed by the reconstruction API in order to solve part of the Bundle Adjustment plus the points Intersect. If Ceres Solver is not installed on your system, the reconstruction funcionality will be disabled. **Recommended** Installation @@ -30,8 +31,10 @@ Start by installing all the dependencies. # CMake sudo apt-get install cmake - # google-glog + gflags - sudo apt-get install libgoogle-glog-dev + # gflags + sudo apt-get install libgflag-dev + # google-glog(not recommended) + # sudo apt-get install libgoogle-glog-dev # BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 @@ -47,6 +50,15 @@ Start by installing all the dependencies. sudo apt-get update sudo apt-get install libsuitesparse-dev +We are now ready to build, test, and install ng-log. + git clone https://github.com/ng-log/ng-log.git + cd ng-log + mkdir build && cd build + cmake .. + make -j4 + make test + sudo make install + We are now ready to build, test, and install Ceres. git clone https://ceres-solver.googlesource.com/ceres-solver @@ -116,3 +128,4 @@ Future Work * Decide which functions are kept since most of them are the same in calib3d. * Finish to implement computeOrientation(). * Find a good features matchig algorithm for reconstruction() in case we provide pure images for autocalibration (look into OpenMVG). +* If Ceres supports ng-log, update CMakeFile.txt to drop supporting Google glog. diff --git a/modules/sfm/cmake/checks/check_ng-log_gflags.cpp b/modules/sfm/cmake/checks/check_ng-log_gflags.cpp new file mode 100644 index 00000000000..a77307129f7 --- /dev/null +++ b/modules/sfm/cmake/checks/check_ng-log_gflags.cpp @@ -0,0 +1,7 @@ +#include +#include +int main() +{ + (void)(0); + return 0; +} diff --git a/modules/sfm/src/libmv_light/libmv/logging/logging.h b/modules/sfm/src/libmv_light/libmv/logging/logging.h index fa091c0acc1..7314a61cfd8 100644 --- a/modules/sfm/src/libmv_light/libmv/logging/logging.h +++ b/modules/sfm/src/libmv_light/libmv/logging/logging.h @@ -21,7 +21,11 @@ #ifndef LIBMV_LOGGING_LOGGING_H #define LIBMV_LOGGING_LOGGING_H +#if NGLOG_FOUND +#include +#else #include +#endif #if defined _MSC_VER && _MSC_VER < 1900 From bb3bed2cda0fcccc9c953975fa2de23665558b1d Mon Sep 17 00:00:00 2001 From: Kumataro Date: Fri, 20 Jun 2025 07:20:01 +0900 Subject: [PATCH 2/3] fix for missing both glog and ng-log --- modules/sfm/CMakeLists.txt | 62 ++++++++++++------- modules/sfm/README.md | 45 +++++++++----- .../sfm_installation.markdown | 40 ++++++++++-- 3 files changed, 104 insertions(+), 43 deletions(-) diff --git a/modules/sfm/CMakeLists.txt b/modules/sfm/CMakeLists.txt index a6eb9cde723..2168ff23f92 100644 --- a/modules/sfm/CMakeLists.txt +++ b/modules/sfm/CMakeLists.txt @@ -9,21 +9,11 @@ find_package(Ceres QUIET) if(NOT Gflags_FOUND) # Ceres find gflags on the own, so separate search isn't necessary find_package(Gflags QUIET) endif() -if(NOT (Ng-log_FOUND OR ng-log_FOUND)) - find_package(ng-log QUIET) -endif() if(NOT (Glog_FOUND OR glog_FOUND)) # Ceres find glog on the own, so separate search isn't necessary find_package(Glog QUIET) endif() - -if(Ng-log_FOUND OR ng-log_FOUND) - if(NOT (Glog_FOUND OR glog_FOUND)) - message(STATUS "sfm: ng-log is detected, but Google glog is not. ng-log(ver 0.9.x or later) is used") - set(glog_FOUND ON) - get_property(GLOG_INCLUDE_DIR TARGET ng-log::ng-log PROPERTY INTERFACE_INCLUDE_DIRECTORIES) - else() - message(STATUS "sfm: Both ng-log and Google glog are detected. Google glog or ng-log(ver 0.8.x) is used") - endif() +if(NOT (Ng-log_FOUND OR ng-log_FOUND)) + find_package(ng-log QUIET) endif() if(NOT Gflags_FOUND OR NOT (Glog_FOUND OR glog_FOUND)) @@ -37,6 +27,7 @@ if(NOT Gflags_FOUND OR NOT (Glog_FOUND OR glog_FOUND)) endif() endif() +# Setup for gflags if(NOT DEFINED GFLAGS_INCLUDE_DIRS AND DEFINED GFLAGS_INCLUDE_DIR) set(GFLAGS_INCLUDE_DIRS "${GFLAGS_INCLUDE_DIR}") endif() @@ -45,24 +36,45 @@ if(NOT GFLAGS_LIBRARIES AND TARGET gflags::gflags) elseif(NOT GFLAGS_LIBRARIES AND TARGET gflags) set(GFLAGS_LIBRARIES gflags) endif() -if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR) - set(GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR}") + +# Setup for ng-log and Google glog +if(Ng-log_FOUND OR ng-log_FOUND) + if(Glog_FOUND OR glog_FOUND) + message(STATUS "sfm: Both ng-log and Google glog are detected. Google glog or ng-log(ver 0.8.x) is used") + set(GLOG_TYPE "glog") + else() + message(STATUS "sfm: ng-log is detected and Google glog is not. ng-log(ver 0.9.x or later) is used") + set(GLOG_TYPE "ng-log") + endif() +else() + if(Glog_FOUND OR glog_FOUND) + message(STATUS "sfm: Deprecated Google glog is detected. ng-log is recommended") + set(GLOG_TYPE "glog") + else() + message(STATUS "sfm: Both ng-log and Google glog are not detected") + unset(GLOG_TYPE) + endif() endif() -if(NOT GLOG_LIBRARIES AND TARGET ng-log::ng-log) - set(GLOG_NAME "ng-log") - set(GLOG_LIBRARIES ng-log::ng-log) + +if(GLOG_TYPE STREQUAL "ng-log") + set(glog_FOUND ON) + get_property(GLOG_INCLUDE_DIR TARGET ng-log::ng-log PROPERTY INTERFACE_INCLUDE_DIRECTORIES) add_definitions("-DNGLOG_FOUND=1") endif() + +if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR) + set(GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR}") +endif() if(NOT GLOG_LIBRARIES AND TARGET glog::glog) - set(GLOG_NAME "glog") set(GLOG_LIBRARIES glog::glog) - message(STATUS "Google glog is deprecated, ng-log is recommended.") +elseif(NOT GLOG_LIBRARIES AND TARGET ng-log::ng-log) + set(GLOG_LIBRARIES ng-log::ng-log) endif() -if((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS)) +if((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND GLOG_TYPE) set(__cache_key "${GLOG_INCLUDE_DIRS} ~ ${GFLAGS_INCLUDE_DIRS} ~ ${GLOG_LIBRARIES} ~ ${GFLAGS_LIBRARIES}") if(NOT DEFINED SFM_GLOG_GFLAGS_TEST_CACHE_KEY OR NOT (SFM_GLOG_GFLAGS_TEST_CACHE_KEY STREQUAL __cache_key)) - set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_${GLOG_NAME}_gflags.cpp") + set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_${GLOG_TYPE}_gflags.cpp") try_compile( SFM_GLOG_GFLAGS_TEST "${CMAKE_BINARY_DIR}" "${__fname}" CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS};${GFLAGS_INCLUDE_DIRS}" @@ -77,7 +89,7 @@ if((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (gl endif() set(SFM_GLOG_GFLAGS_TEST "${SFM_GLOG_GFLAGS_TEST}" CACHE INTERNAL "") set(SFM_GLOG_GFLAGS_TEST_CACHE_KEY "${__cache_key}" CACHE INTERNAL "") - message(STATUS "Checking SFM ${GLOG_NAME}/gflags deps... ${SFM_GLOG_GFLAGS_TEST}") + message(STATUS "Checking SFM ${GLOG_TYPE}/gflags deps... ${SFM_GLOG_GFLAGS_TEST}") endif() unset(__cache_key) set(SFM_DEPS_OK "${SFM_GLOG_GFLAGS_TEST}") @@ -91,7 +103,11 @@ if(NOT HAVE_EIGEN OR NOT SFM_DEPS_OK) set(DISABLE_MSG "${DISABLE_MSG} Eigen") endif() if(NOT SFM_DEPS_OK) - set(DISABLE_MSG "${DISABLE_MSG} Glog/Gflags") + if(GLOG_TYPE) + set(DISABLE_MSG "${DISABLE_MSG} ${GLOG_TYPE}/Gflags") + else() + set(DISABLE_MSG "${DISABLE_MSG} ng-log/Gflags") + endif() endif() message(STATUS ${DISABLE_MSG}) ocv_module_disable(sfm) diff --git a/modules/sfm/README.md b/modules/sfm/README.md index ede07f85f82..1d728402456 100644 --- a/modules/sfm/README.md +++ b/modules/sfm/README.md @@ -17,24 +17,48 @@ In addition, it depends on some open source libraries: - [Google Flags](https://github.com/gflags/gflags). **Required** - [Ceres Solver](http://ceres-solver.org). Needed by the reconstruction API in order to solve part of the Bundle Adjustment plus the points Intersect. If Ceres Solver is not installed on your system, the reconstruction funcionality will be disabled. **Recommended** +Notice + +- Google glog is deprecated. Use ng-log 0.9.0 or later. +- If ng-log 0.8.x or earlier is used, many configuration and build warnings will shown. Update to 0.9.0 or later. - If both ng-log and Google glog are installed, sfm uses Google glog. If you require ng-log, uninstall Google glog. + + Installation ------------ **Required Dependencies** In case you are on [Ubuntu](http://www.ubuntu.com/) you can simply install the required dependencies by typing the following command. - sudo apt-get install libeigen3-dev libgflags-dev libgoogle-glog-dev + sudo apt-get install libeigen3-dev libgflags-dev -**Ceres Solver** +**ng-log** + +See https://ng-log.github.io/ng-log/stable/build/#cmake Start by installing all the dependencies. # CMake sudo apt-get install cmake # gflags - sudo apt-get install libgflag-dev - # google-glog(not recommended) - # sudo apt-get install libgoogle-glog-dev + sudo apt-get install libgflags-dev + +We are now ready to build, test, and install ng-log. + git clone https://github.com/ng-log/ng-log.git + cd ng-log + mkdir build && cd build + cmake .. + make -j4 + make test + sudo make install + +**Ceres Solver** + +Start by installing all the dependencies. + + # CMake + sudo apt-get install cmake + # google-glog + gflags + sudo apt-get install libgoogle-glog-dev # BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 @@ -50,15 +74,6 @@ Start by installing all the dependencies. sudo apt-get update sudo apt-get install libsuitesparse-dev -We are now ready to build, test, and install ng-log. - git clone https://github.com/ng-log/ng-log.git - cd ng-log - mkdir build && cd build - cmake .. - make -j4 - make test - sudo make install - We are now ready to build, test, and install Ceres. git clone https://ceres-solver.googlesource.com/ceres-solver @@ -128,4 +143,4 @@ Future Work * Decide which functions are kept since most of them are the same in calib3d. * Finish to implement computeOrientation(). * Find a good features matchig algorithm for reconstruction() in case we provide pure images for autocalibration (look into OpenMVG). -* If Ceres supports ng-log, update CMakeFile.txt to drop supporting Google glog. +* After Ceres supports ng-log, drop to support Google glog. diff --git a/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown b/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown index b450f6e1df3..4922f10b669 100644 --- a/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown +++ b/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown @@ -6,11 +6,16 @@ Dependencies The Structure from Motion module depends on some open source libraries. - - [Eigen](http://eigen.tuxfamily.org) 3.2.2 or later. \b Required - - [GLog](https://github.com/google/glog) 0.3.1 or later. \b Required - - [GFlags]( https://github.com/gflags). \b Required + - [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page) 3.2.2 or later. \b Required + - [ng-log](https://github.com/ng-log/ng-log) 0.9.0 or later. \b Required, use instead of Google glog + - [Google Logging Library(glog)](https://github.com/google/glog) 0.3.1 or later. \b Not-recommended + - [Google Flags](https://github.com/gflags/gflags). \b Required - [Ceres Solver](http://ceres-solver.org). Needed by the reconstruction API in order to solve part of the Bundle Adjustment plus the points Intersect. If Ceres Solver is not installed on your system, the reconstruction funcionality will be disabled. \b Recommended +@warning +- Google glog is deprecated. Use ng-log 0.9.0 or later. +- If ng-log 0.8.x or earlier is used, many configuration and build warnings will shown. Update to 0.9.0 or later. +- If both ng-log and Google glog are installed, sfm uses Google glog. If you require ng-log, uninstall Google glog. Installation @@ -21,7 +26,32 @@ __Required Dependencies__ In case you are on [Ubuntu](http://www.ubuntu.com) you can simply install the required dependencies by typing the following command: @code{.bash} - sudo apt-get install libeigen3-dev libgflags-dev libgoogle-glog-dev + sudo apt-get install libeigen3-dev libgflags-dev +@endcode + +__ng-log__ + +See https://ng-log.github.io/ng-log/stable/build/#cmake + +Start by installing all the dependencies. + +@code{.bash} + # CMake + sudo apt-get install cmake + # gflags + sudo apt-get install libgflags-dev +@endcode + +We are now ready to build, test, and install ng-log. + +@code{.bash} + git clone https://github.com/ng-log/ng-log.git + cd ng-log + mkdir build && cd build + cmake .. + make -j4 + make test + sudo make install @endcode __Ceres Solver__ @@ -59,4 +89,4 @@ We are now ready to build, test, and install Ceres: make -j4 make test sudo make install -@endcode \ No newline at end of file +@endcode From e5238dc7802e9b2a97aa63ea0c6d62261024e02d Mon Sep 17 00:00:00 2001 From: Kumataro Date: Fri, 20 Jun 2025 08:45:07 +0900 Subject: [PATCH 3/3] fix typo --- modules/sfm/README.md | 3 ++- .../sfm/tutorials/sfm_installation/sfm_installation.markdown | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/sfm/README.md b/modules/sfm/README.md index 1d728402456..7515d83f002 100644 --- a/modules/sfm/README.md +++ b/modules/sfm/README.md @@ -20,7 +20,8 @@ In addition, it depends on some open source libraries: Notice - Google glog is deprecated. Use ng-log 0.9.0 or later. -- If ng-log 0.8.x or earlier is used, many configuration and build warnings will shown. Update to 0.9.0 or later. - If both ng-log and Google glog are installed, sfm uses Google glog. If you require ng-log, uninstall Google glog. +- If ng-log 0.8.x or earlier is used, many configuration and build warnings will be shown. Update ng-log 0.9.0 or later. +- If both ng-log and Google glog are installed, sfm uses Google glog. If you require ng-log, uninstall Google glog. Installation diff --git a/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown b/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown index 4922f10b669..90746bdb697 100644 --- a/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown +++ b/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown @@ -14,7 +14,7 @@ The Structure from Motion module depends on some open source libraries. @warning - Google glog is deprecated. Use ng-log 0.9.0 or later. -- If ng-log 0.8.x or earlier is used, many configuration and build warnings will shown. Update to 0.9.0 or later. +- If ng-log 0.8.x or earlier is used, many configuration and build warnings will be shown. Update ng-log 0.9.0 or later. - If both ng-log and Google glog are installed, sfm uses Google glog. If you require ng-log, uninstall Google glog.