Skip to content

sfm: support ng-log #3960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions modules/sfm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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}"
Expand All @@ -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}")
Expand All @@ -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)
Expand Down
37 changes: 33 additions & 4 deletions modules/sfm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down Expand Up @@ -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.
7 changes: 7 additions & 0 deletions modules/sfm/cmake/checks/check_ng-log_gflags.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <ng-log/logging.h>
#include <gflags/gflags.h>
int main()
{
(void)(0);
return 0;
}
4 changes: 4 additions & 0 deletions modules/sfm/src/libmv_light/libmv/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#ifndef LIBMV_LOGGING_LOGGING_H
#define LIBMV_LOGGING_LOGGING_H

#if NGLOG_FOUND
#include <ng-log/logging.h>
#else
#include <glog/logging.h>
#endif


#if defined _MSC_VER && _MSC_VER < 1900
Expand Down
40 changes: 35 additions & 5 deletions modules/sfm/tutorials/sfm_installation/sfm_installation.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__
Expand Down Expand Up @@ -59,4 +89,4 @@ We are now ready to build, test, and install Ceres:
make -j4
make test
sudo make install
@endcode
@endcode