From 4f6e4cbb936c0118e623a2b3c10b81caa894bb59 Mon Sep 17 00:00:00 2001 From: Erick Fuentes Date: Fri, 15 Nov 2024 15:47:10 -0500 Subject: [PATCH] add opengv (#336) --- WORKSPACE | 9 + third_party/BUILD.eigen | 14 ++ third_party/BUILD.opengv | 45 +++++ ...efix-unsupported-eigen-include-paths.patch | 165 ++++++++++++++++++ 4 files changed, 233 insertions(+) create mode 100644 third_party/BUILD.opengv create mode 100644 third_party/opengv_0001-prefix-unsupported-eigen-include-paths.patch diff --git a/WORKSPACE b/WORKSPACE index 8e25c86d..35d9cb27 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -449,3 +449,12 @@ http_archive( patches = ["//third_party:dbow2_0001-prefix-include-paths.patch"] ) +http_archive( + name = "opengv", + urls = ["https://github.com/laurentkneip/opengv/archive/91f4b19c73450833a40e463ad3648aae80b3a7f3.zip"], + strip_prefix="opengv-91f4b19c73450833a40e463ad3648aae80b3a7f3", + build_file="//third_party:BUILD.opengv", + patch_args = ["-p1"], + patches = ["//third_party:opengv_0001-prefix-unsupported-eigen-include-paths.patch"], + integrity = "sha256-gIK3IvE6rGDpxvN3BA+EPFKPvZ7Zi7Ix33IIcm2RULA=" +) diff --git a/third_party/BUILD.eigen b/third_party/BUILD.eigen index d5b666c0..10232d4a 100644 --- a/third_party/BUILD.eigen +++ b/third_party/BUILD.eigen @@ -35,6 +35,8 @@ cc_library( "Eigen/UmfPackSupport", "unsupported/Eigen/AutoDiff", "unsupported/Eigen/Polynomials", + "unsupported/Eigen/NonLinearOptimization", + "unsupported/Eigen/NumericalDiff", ], srcs = glob(["Eigen/src/**/*"]) + [ @@ -43,6 +45,18 @@ cc_library( "unsupported/Eigen/src/Polynomials/Companion.h", "unsupported/Eigen/src/Polynomials/PolynomialUtils.h", "unsupported/Eigen/src/Polynomials/PolynomialSolver.h", + "unsupported/Eigen/src/NonLinearOptimization/chkder.h", + "unsupported/Eigen/src/NonLinearOptimization/covar.h", + "unsupported/Eigen/src/NonLinearOptimization/dogleg.h", + "unsupported/Eigen/src/NonLinearOptimization/fdjac1.h", + "unsupported/Eigen/src/NonLinearOptimization/lmpar.h", + "unsupported/Eigen/src/NonLinearOptimization/qrsolv.h", + "unsupported/Eigen/src/NonLinearOptimization/rwupdt.h", + "unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h", + "unsupported/Eigen/src/NonLinearOptimization/r1updt.h", + "unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h", + "unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h", + "unsupported/Eigen/src/NumericalDiff/NumericalDiff.h", ], # Other third party dependencies often pull in Eigen using angle brackets # This makes it so that Eigen is available at both "Eigen/Core" and diff --git a/third_party/BUILD.opengv b/third_party/BUILD.opengv new file mode 100644 index 00000000..0183156d --- /dev/null +++ b/third_party/BUILD.opengv @@ -0,0 +1,45 @@ + +cc_library( + name = "opengv", + hdrs = glob(["include/**/*.hpp", "include/*.hpp"]), + srcs = glob(["src/**/*.cpp"]), + strip_include_prefix="include", + deps = ["@eigen"], + visibility=["//visibility:public"], +) + +cc_library( + name = "random_generators", + hdrs = [ + "test/random_generators.hpp", + "test/experiment_helpers.hpp", + "test/time_measurement.hpp", + ], + srcs = [ + "test/random_generators.cpp", + "test/experiment_helpers.cpp", + "test/time_measurement.cpp", + ], + strip_include_prefix="test", + deps = [":opengv"], +) + +cc_test( + name = "test_absolute_pose", + srcs = ["test/test_absolute_pose.cpp"], + deps = [ + ":opengv", + ":random_generators", + ], +) + +cc_test( + name = "test_absolute_pose_sac", + srcs = ["test/test_absolute_pose_sac.cpp"], + deps = [ + ":opengv", + ":random_generators", + ], +) + +# TODO: additional tests and python bindings diff --git a/third_party/opengv_0001-prefix-unsupported-eigen-include-paths.patch b/third_party/opengv_0001-prefix-unsupported-eigen-include-paths.patch new file mode 100644 index 00000000..1824159f --- /dev/null +++ b/third_party/opengv_0001-prefix-unsupported-eigen-include-paths.patch @@ -0,0 +1,165 @@ +diff --git a/src/absolute_pose/methods.cpp b/src/absolute_pose/methods.cpp +index b1f0889..84c3ef4 100644 +--- a/src/absolute_pose/methods.cpp ++++ b/src/absolute_pose/methods.cpp +@@ -32,8 +32,8 @@ + #include + #include + +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/absolute_pose/modules/main.cpp b/src/absolute_pose/modules/main.cpp +index ed0c271..a179aaf 100644 +--- a/src/absolute_pose/modules/main.cpp ++++ b/src/absolute_pose/modules/main.cpp +@@ -29,8 +29,8 @@ + ******************************************************************************/ + + +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/point_cloud/methods.cpp b/src/point_cloud/methods.cpp +index 5409eeb..ed69488 100644 +--- a/src/point_cloud/methods.cpp ++++ b/src/point_cloud/methods.cpp +@@ -32,8 +32,8 @@ + #include + #include + +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/relative_pose/methods.cpp b/src/relative_pose/methods.cpp +index 0027dae..939ad6e 100644 +--- a/src/relative_pose/methods.cpp ++++ b/src/relative_pose/methods.cpp +@@ -32,8 +32,8 @@ + #include + #include + +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/relative_pose/modules/fivept_nister/modules.cpp b/src/relative_pose/modules/fivept_nister/modules.cpp +index 4b134c5..b4f8d7d 100644 +--- a/src/relative_pose/modules/fivept_nister/modules.cpp ++++ b/src/relative_pose/modules/fivept_nister/modules.cpp +@@ -30,8 +30,8 @@ + + + #include +-#include +-#include ++#include ++#include + + #include + +diff --git a/src/relative_pose/modules/main.cpp b/src/relative_pose/modules/main.cpp +index 674c36b..a8c6ed4 100644 +--- a/src/relative_pose/modules/main.cpp ++++ b/src/relative_pose/modules/main.cpp +@@ -31,8 +31,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/sac_problems/relative_pose/CentralRelativePoseSacProblem.cpp b/src/sac_problems/relative_pose/CentralRelativePoseSacProblem.cpp +index cc48dfb..2c231eb 100644 +--- a/src/sac_problems/relative_pose/CentralRelativePoseSacProblem.cpp ++++ b/src/sac_problems/relative_pose/CentralRelativePoseSacProblem.cpp +@@ -32,8 +32,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + bool + opengv::sac_problems:: +diff --git a/src/sac_problems/relative_pose/MultiCentralRelativePoseSacProblem.cpp b/src/sac_problems/relative_pose/MultiCentralRelativePoseSacProblem.cpp +index 25f446a..7a44d30 100644 +--- a/src/sac_problems/relative_pose/MultiCentralRelativePoseSacProblem.cpp ++++ b/src/sac_problems/relative_pose/MultiCentralRelativePoseSacProblem.cpp +@@ -33,8 +33,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + bool + opengv::sac_problems:: +diff --git a/src/sac_problems/relative_pose/MultiNoncentralRelativePoseSacProblem.cpp b/src/sac_problems/relative_pose/MultiNoncentralRelativePoseSacProblem.cpp +index cd9596e..0c35cc9 100644 +--- a/src/sac_problems/relative_pose/MultiNoncentralRelativePoseSacProblem.cpp ++++ b/src/sac_problems/relative_pose/MultiNoncentralRelativePoseSacProblem.cpp +@@ -33,8 +33,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + +diff --git a/src/sac_problems/relative_pose/NoncentralRelativePoseSacProblem.cpp b/src/sac_problems/relative_pose/NoncentralRelativePoseSacProblem.cpp +index df58181..6ad47af 100644 +--- a/src/sac_problems/relative_pose/NoncentralRelativePoseSacProblem.cpp ++++ b/src/sac_problems/relative_pose/NoncentralRelativePoseSacProblem.cpp +@@ -32,8 +32,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + +diff --git a/src/sac_problems/relative_pose/RotationOnlySacProblem.cpp b/src/sac_problems/relative_pose/RotationOnlySacProblem.cpp +index af04c3c..c11cf10 100644 +--- a/src/sac_problems/relative_pose/RotationOnlySacProblem.cpp ++++ b/src/sac_problems/relative_pose/RotationOnlySacProblem.cpp +@@ -32,8 +32,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + bool + opengv::sac_problems::