diff --git a/modules/sfm/CMakeLists.txt b/modules/sfm/CMakeLists.txt index 46da72e309a..2168ff23f92 100644 --- a/modules/sfm/CMakeLists.txt +++ b/modules/sfm/CMakeLists.txt @@ -12,6 +12,9 @@ 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(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)) # try local search scripts @@ -24,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() @@ -32,17 +36,45 @@ if(NOT GFLAGS_LIBRARIES AND TARGET gflags::gflags) elseif(NOT GFLAGS_LIBRARIES AND TARGET gflags) set(GFLAGS_LIBRARIES gflags) endif() + +# 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(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_LIBRARIES glog::glog) +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_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}" @@ -57,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/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}") @@ -71,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 83a860bce1e..7515d83f002 100644 --- a/modules/sfm/README.md +++ b/modules/sfm/README.md @@ -11,18 +11,46 @@ 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** +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 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 ------------ **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 + +**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 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** @@ -116,3 +144,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). +* After Ceres supports ng-log, drop to support 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 diff --git a/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown b/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown index b450f6e1df3..90746bdb697 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 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 @@ -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