Skip to content

Commit 690d260

Browse files
committed
sfm: support ng-log
1 parent 1e4d4e0 commit 690d260

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

modules/sfm/CMakeLists.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@ find_package(Ceres QUIET)
99
if(NOT Gflags_FOUND) # Ceres find gflags on the own, so separate search isn't necessary
1010
find_package(Gflags QUIET)
1111
endif()
12+
if(NOT (Ng-log_FOUND OR ng-log_FOUND))
13+
find_package(ng-log QUIET)
14+
endif()
1215
if(NOT (Glog_FOUND OR glog_FOUND)) # Ceres find glog on the own, so separate search isn't necessary
1316
find_package(Glog QUIET)
1417
endif()
1518

19+
if(Ng-log_FOUND OR ng-log_FOUND)
20+
if(NOT (Glog_FOUND OR glog_FOUND))
21+
message(STATUS "sfm: ng-log is detected, but Google glog is not. ng-log(ver 0.9.x or later) is used")
22+
set(glog_FOUND ON)
23+
get_property(GLOG_INCLUDE_DIR TARGET ng-log::ng-log PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
24+
else()
25+
message(STATUS "sfm: Both ng-log and Google glog are detected. Google glog or ng-log(ver 0.8.x) is used")
26+
endif()
27+
endif()
28+
1629
if(NOT Gflags_FOUND OR NOT (Glog_FOUND OR glog_FOUND))
1730
# try local search scripts
1831
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
@@ -35,14 +48,21 @@ endif()
3548
if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR)
3649
set(GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR}")
3750
endif()
51+
if(NOT GLOG_LIBRARIES AND TARGET ng-log::ng-log)
52+
set(GLOG_NAME "ng-log")
53+
set(GLOG_LIBRARIES ng-log::ng-log)
54+
add_definitions("-DNGLOG_FOUND=1")
55+
endif()
3856
if(NOT GLOG_LIBRARIES AND TARGET glog::glog)
57+
set(GLOG_NAME "glog")
3958
set(GLOG_LIBRARIES glog::glog)
59+
message(STATUS "Google glog is deprecated, ng-log is recommended.")
4060
endif()
4161

4262
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))
4363
set(__cache_key "${GLOG_INCLUDE_DIRS} ~ ${GFLAGS_INCLUDE_DIRS} ~ ${GLOG_LIBRARIES} ~ ${GFLAGS_LIBRARIES}")
4464
if(NOT DEFINED SFM_GLOG_GFLAGS_TEST_CACHE_KEY OR NOT (SFM_GLOG_GFLAGS_TEST_CACHE_KEY STREQUAL __cache_key))
45-
set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_glog_gflags.cpp")
65+
set(__fname "${CMAKE_CURRENT_LIST_DIR}/cmake/checks/check_${GLOG_NAME}_gflags.cpp")
4666
try_compile(
4767
SFM_GLOG_GFLAGS_TEST "${CMAKE_BINARY_DIR}" "${__fname}"
4868
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
5777
endif()
5878
set(SFM_GLOG_GFLAGS_TEST "${SFM_GLOG_GFLAGS_TEST}" CACHE INTERNAL "")
5979
set(SFM_GLOG_GFLAGS_TEST_CACHE_KEY "${__cache_key}" CACHE INTERNAL "")
60-
message(STATUS "Checking SFM glog/gflags deps... ${SFM_GLOG_GFLAGS_TEST}")
80+
message(STATUS "Checking SFM ${GLOG_NAME}/gflags deps... ${SFM_GLOG_GFLAGS_TEST}")
6181
endif()
6282
unset(__cache_key)
6383
set(SFM_DEPS_OK "${SFM_GLOG_GFLAGS_TEST}")

modules/sfm/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ Before compiling, take a look at the following details in order to give a proper
1111

1212
In addition, it depends on some open source libraries:
1313

14-
- [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) 3.2.2 or later. **Required**
15-
- [Google Log](http://code.google.com/p/google-glog) 0.3.1 or later. **Required**
16-
- [Google Flags](http://code.google.com/p/gflags). **Required**
14+
- [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page) 3.2.2 or later. **Required**
15+
- [ng-log](https://github.com/ng-log/ng-log) 0.9.0 or later. **Required, use instead of Google glog**
16+
- [Google Logging Library(glog)](https://github.com/google/glog) 0.3.1 or later. **Not recommended**
17+
- [Google Flags](https://github.com/gflags/gflags). **Required**
1718
- [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**
1819

1920
Installation
@@ -30,8 +31,10 @@ Start by installing all the dependencies.
3031

3132
# CMake
3233
sudo apt-get install cmake
33-
# google-glog + gflags
34-
sudo apt-get install libgoogle-glog-dev
34+
# gflags
35+
sudo apt-get install libgflag-dev
36+
# google-glog(not recommended)
37+
# sudo apt-get install libgoogle-glog-dev
3538
# BLAS & LAPACK
3639
sudo apt-get install libatlas-base-dev
3740
# Eigen3
@@ -47,6 +50,15 @@ Start by installing all the dependencies.
4750
sudo apt-get update
4851
sudo apt-get install libsuitesparse-dev
4952

53+
We are now ready to build, test, and install ng-log.
54+
git clone https://github.com/ng-log/ng-log.git
55+
cd ng-log
56+
mkdir build && cd build
57+
cmake ..
58+
make -j4
59+
make test
60+
sudo make install
61+
5062
We are now ready to build, test, and install Ceres.
5163

5264
git clone https://ceres-solver.googlesource.com/ceres-solver
@@ -116,3 +128,4 @@ Future Work
116128
* Decide which functions are kept since most of them are the same in calib3d.
117129
* Finish to implement computeOrientation().
118130
* Find a good features matchig algorithm for reconstruction() in case we provide pure images for autocalibration (look into OpenMVG).
131+
* If Ceres supports ng-log, update CMakeFile.txt to drop supporting Google glog.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <ng-log/logging.h>
2+
#include <gflags/gflags.h>
3+
int main()
4+
{
5+
(void)(0);
6+
return 0;
7+
}

modules/sfm/src/libmv_light/libmv/logging/logging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
#ifndef LIBMV_LOGGING_LOGGING_H
2222
#define LIBMV_LOGGING_LOGGING_H
2323

24+
#if NGLOG_FOUND
25+
#include <ng-log/logging.h>
26+
#else
2427
#include <glog/logging.h>
28+
#endif
2529

2630

2731
#if defined _MSC_VER && _MSC_VER < 1900

0 commit comments

Comments
 (0)