Skip to content

Commit

Permalink
Upgrade dependencies to support Ubuntu 22.04
Browse files Browse the repository at this point in the history
Upgrades:
- pyyaml 6.0.1
- pybind11 2.11.1
- ceres solver 2.1.0
- gtest/gmock to the one shipped in latest ceres solver
  • Loading branch information
none authored and jpilet committed Mar 6, 2024
1 parent 7ad7339 commit 914cba2
Show file tree
Hide file tree
Showing 20 changed files with 20,475 additions and 30,481 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.ceres2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -27,12 +27,12 @@ RUN apt-get update \
# Install Ceres 2
RUN \
mkdir -p /source && cd /source && \
curl -L http://ceres-solver.org/ceres-solver-2.0.0.tar.gz | tar xz && \
cd /source/ceres-solver-2.0.0 && \
curl -L http://ceres-solver.org/ceres-solver-2.1.0.tar.gz | tar xz && \
cd /source/ceres-solver-2.1.0 && \
mkdir -p build && cd build && \
cmake .. -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF && \
make -j4 install && \
cd / && rm -rf /source/ceres-solver-2.0.0
cd / && rm -rf /source/ceres-solver-2.1.0


COPY . /source/OpenSfM
Expand Down
5 changes: 3 additions & 2 deletions opensfm/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable all warnings
if (NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()

# For compiling VLFeat
Expand Down Expand Up @@ -85,6 +85,7 @@ add_subdirectory(third_party/akaze)
add_subdirectory(third_party/vlfeat)

include_directories(third_party/vlfeat)
include_directories(third_party/pybind11/include)

####### Debugging #######
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
Expand Down
5 changes: 3 additions & 2 deletions opensfm/src/bundle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ set(BUNDLE_FILES
)
add_library(bundle ${BUNDLE_FILES})
target_link_libraries(bundle
PRIVATE
PUBLIC
${CERES_LIBRARIES}
PRIVATE
${LAPACK_LIBRARIES}
${SUITESPARSE_LIBRARIES}
foundation
Expand Down Expand Up @@ -55,7 +56,7 @@ target_link_libraries(pybundle PRIVATE
bundle
geometry
foundation
pybind11)
pybind11::headers)
set_target_properties(pybundle PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
)
2 changes: 1 addition & 1 deletion opensfm/src/dense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endif()

pybind11_add_module(pydense python/pybind.cc)
target_include_directories(pydense PRIVATE ${GLOG_INCLUDE_DIR})
target_link_libraries(pydense PRIVATE dense foundation pybind11)
target_link_libraries(pydense PRIVATE dense foundation pybind11::headers)
set_target_properties(pydense PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
)
2 changes: 1 addition & 1 deletion opensfm/src/features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_link_libraries(pyfeatures
PRIVATE
features
foundation
pybind11
pybind11::headers
akaze
)
set_target_properties(pyfeatures PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion opensfm/src/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(FOUNDATION_FILES
add_library(foundation ${FOUNDATION_FILES})
target_link_libraries(foundation
PUBLIC
pybind11
pybind11::headers
${OpenCV_LIBS}
${OpenMP_libomp_LIBRARY}
Eigen3::Eigen
Expand Down
2 changes: 1 addition & 1 deletion opensfm/src/geo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ target_link_libraries(pygeo
PRIVATE
geo
foundation
pybind11
pybind11::headers
)
set_target_properties(pygeo PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
Expand Down
5 changes: 3 additions & 2 deletions opensfm/src/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ set(GEOMETRY_FILES
)
add_library(geometry ${GEOMETRY_FILES})
target_link_libraries(geometry
PUBLIC
${CERES_LIBRARIES}
PRIVATE
foundation
${CERES_LIBRARIES}
)
target_include_directories(geometry PUBLIC ${CMAKE_SOURCE_DIR})

Expand All @@ -48,7 +49,7 @@ target_link_libraries(pygeometry
PRIVATE
geometry
foundation
pybind11
pybind11::headers
)
set_target_properties(pygeometry PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
Expand Down
5 changes: 3 additions & 2 deletions opensfm/src/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ set(MAP_FILES
add_library(map ${MAP_FILES})
target_link_libraries(map
PUBLIC
pybind11
pybind11::headers
Eigen3::Eigen
Ceres::ceres
PRIVATE
geo
geometry
Expand All @@ -41,7 +42,7 @@ target_link_libraries(pymap
geometry
foundation
bundle
pybind11
pybind11::headers
)

if (OPENSFM_BUILD_TESTS)
Expand Down
90 changes: 0 additions & 90 deletions opensfm/src/map/pybind_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,6 @@ struct sfm_iterator_state {
};
PYBIND11_NAMESPACE_END_(detail)

/// Makes an python iterator over the keys (`.first`) of a iterator over pairs
/// from a first and past-the-end InputIterator.
template <return_value_policy Policy = return_value_policy::reference_internal,
typename Iterator, typename Sentinel,
typename KeyType = decltype((*std::declval<Iterator>()).second),
typename... Extra>
iterator make_value_iterator(Iterator first, Sentinel last, Extra &&... extra) {
typedef detail::sfm_iterator_state<Iterator, Sentinel, detail::RefIterator,
Policy>
state;

if (!detail::get_type_info(typeid(state), false)) {
class_<state>(handle(), "iterator", pybind11::module_local())
.def("__iter__", [](state &s) -> state & { return s; })
.def("__next__",
[](state &s) -> KeyType {
if (!s.first_or_done) {
++s.it;
} else {
s.first_or_done = false;
}
if (s.it == s.end) {
s.first_or_done = true;
throw stop_iteration();
}
return (*s.it).second;
},
std::forward<Extra>(extra)..., Policy);
}

return cast(state{first, last, true});
}

template <return_value_policy Policy = return_value_policy::reference_internal,
typename Iterator, typename Sentinel,
typename KeyType = decltype(&((*std::declval<Iterator>()).second)),
Expand Down Expand Up @@ -150,61 +117,4 @@ iterator make_ref_iterator(Iterator first, Sentinel last, Extra &&... extra) {
return cast(state{first, last, true});
}

/// Makes a python iterator from a first and past-the-end C++ InputIterator.
template <return_value_policy Policy = return_value_policy::reference_internal,
typename Iterator, typename Sentinel,
typename ValueType = decltype(std::declval<Iterator>()),
typename... Extra>
iterator make_ptr_iterator(Iterator first, Sentinel last, Extra &&... extra) {
typedef detail::iterator_state<Iterator, Sentinel, false, Policy> state;

if (!detail::get_type_info(typeid(state), false)) {
class_<state>(handle(), "iterator", pybind11::module_local())
.def("__iter__", [](state &s) -> state & { return s; })
.def("__next__",
[](state &s) -> ValueType {
if (!s.first_or_done) {
++s.it;
} else {
s.first_or_done = false;
}
if (s.it == s.end) {
s.first_or_done = true;
throw stop_iteration();
}
return s.it;
},
std::forward<Extra>(extra)..., Policy);
}

return cast(state{first, last, true});
}

/// Makes an iterator over the keys (`.first`) of a stl map-like container
/// supporting `std::begin()`/`std::end()`
template <return_value_policy Policy = return_value_policy::reference_internal,
typename Type, typename... Extra>
iterator make_value_iterator(Type &value, Extra &&... extra) {
return make_value_iterator<Policy>(std::begin(value), std::end(value),
extra...);
}
template <return_value_policy Policy = return_value_policy::reference_internal,
typename Type, typename... Extra>
iterator make_unique_ptr_value_iterator(Type &value, Extra &&... extra) {
return make_unique_ptr_value_iterator<Policy>(std::begin(value),
std::end(value), extra...);
}
template <return_value_policy Policy = return_value_policy::reference_internal,
typename Type, typename... Extra>
iterator make_unique_ptr_iterator(Type &value, Extra &&... extra) {
return make_unique_ptr_iterator<Policy>(std::begin(value), std::end(value),
extra...);
}

template <return_value_policy Policy = return_value_policy::reference_internal,
typename Type, typename... Extra>
iterator make_ref_value_iterator(Type &value, Extra &&... extra) {
return make_ref_value_iterator<Policy>(std::begin(value), std::end(value),
extra...);
}
PYBIND11_NAMESPACE_END_(PYBIND11_NAMESPACE)
4 changes: 3 additions & 1 deletion opensfm/src/robust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ set(ROBUST_FILES
)
add_library(robust ${ROBUST_FILES})
target_link_libraries(robust
PUBLIC
${CERES_LIBRARIES}
PRIVATE
foundation
geometry
Expand All @@ -29,7 +31,7 @@ target_link_libraries(pyrobust
PRIVATE
robust
foundation
pybind11
pybind11::headers
)
set_target_properties(pyrobust PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
Expand Down
3 changes: 2 additions & 1 deletion opensfm/src/sfm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_library(sfm ${SFM_FILES})
target_link_libraries(sfm
PUBLIC
Eigen3::Eigen
${CERES_LIBRARIES}
PRIVATE
foundation
map
Expand All @@ -35,7 +36,7 @@ target_include_directories(pysfm PRIVATE ${GLOG_INCLUDE_DIR})
target_link_libraries(pysfm
PRIVATE
foundation
pybind11
pybind11::headers
sfm
)
set_target_properties(pysfm PROPERTIES
Expand Down
Loading

0 comments on commit 914cba2

Please sign in to comment.