Skip to content

Commit

Permalink
Bind essential matrix utils (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe authored Jan 23, 2024
1 parent 6f0096d commit 1f166ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pycolmap/estimators/two_view_geometry.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Authors: John Lambert (johnwlambert), Paul-Edouard Sarlin (skydes)

#include "colmap/estimators/two_view_geometry.h"
#include "colmap/estimators/utils.h"
#include "colmap/geometry/pose.h"
#include "colmap/math/random.h"
#include "colmap/optim/loransac.h"
Expand Down Expand Up @@ -161,4 +162,20 @@ void BindTwoViewGeometryEstimator(py::module& m) {
"camera2"_a,
"points2"_a,
"geometry"_a);

m.def(
"squared_sampson_error",
[](const std::vector<Eigen::Vector2d>& points1,
const std::vector<Eigen::Vector2d>& points2,
const Eigen::Matrix3d& E) {
std::vector<double> residuals;
ComputeSquaredSampsonError(points1, points2, E, &residuals);
return residuals;
},
"points2D1"_a,
"points2D2"_a,
"E"_a,
"Calculate the squared Sampson error for a given essential or "
"fundamental matrix.",
py::call_guard<py::gil_scoped_release>());
}
2 changes: 2 additions & 0 deletions pycolmap/geometry/bindings.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "colmap/geometry/essential_matrix.h"
#include "colmap/geometry/pose.h"
#include "colmap/geometry/rigid3.h"
#include "colmap/geometry/sim3.h"
Expand Down Expand Up @@ -51,6 +52,7 @@ void BindGeometry(py::module& m) {
.def_readwrite("rotation", &Rigid3d::rotation)
.def_readwrite("translation", &Rigid3d::translation)
.def("matrix", &Rigid3d::ToMatrix)
.def("essential_matrix", &EssentialMatrixFromPose)
.def(py::self * Eigen::Vector3d())
.def(py::self * Rigid3d())
.def("inverse", static_cast<Rigid3d (*)(const Rigid3d&)>(&Inverse))
Expand Down

0 comments on commit 1f166ff

Please sign in to comment.