| 1 |
#include "colmap/geometry/homography_matrix.h" |
| 2 |
|
| 3 |
#include "colmap/util/logging.h" |
| 4 |
|
| 5 |
#include "pycolmap/helpers.h" |
| 6 |
#include "pycolmap/pybind11_extension.h" |
| 7 |
|
| 8 |
#include <pybind11/eigen.h> |
| 9 |
#include <pybind11/pybind11.h> |
| 10 |
#include <pybind11/stl.h> |
| 11 |
|
| 12 |
using namespace colmap; |
| 13 |
using namespace pybind11::literals; |
| 14 |
namespace py = pybind11; |
| 15 |
|
| 16 |
py::dict PyPoseFromHomographyMatrix( |
| 17 |
const Eigen::Matrix3d& H, |
| 18 |
const Eigen::Matrix3d& K1, |
| 19 |
const Eigen::Matrix3d& K2, |
| 20 |
const std::vector<Eigen::Vector3d>& cam_rays1, |
| 21 |
const std::vector<Eigen::Vector3d>& cam_rays2) { |
| 22 |
py::gil_scoped_release release; |
| 23 |
Rigid3d cam2_from_cam1; |
| 24 |
Eigen::Vector3d normal; |
| 25 |
std::vector<Eigen::Vector3d> points3D; |
| 26 |
PoseFromHomographyMatrix( |
| 27 |
H, K1, K2, cam_rays1, cam_rays2, &cam2_from_cam1, &normal, &points3D); |
| 28 |
py::gil_scoped_acquire acquire; |
| 29 |
return py::dict("cam2_from_cam1"_a = cam2_from_cam1, |
| 30 |
"normal"_a = normal, |
| 31 |
"points3D"_a = points3D); |
| 32 |
} |
| 33 |
|
| 34 |
void BindHomographyMatrixGeometry(py::module& m) { |
| 35 |
m.def("pose_from_homography_matrix", |
| 36 |
&PyPoseFromHomographyMatrix, |
| 37 |
"H"_a, |
| 38 |
"K1"_a, |
| 39 |
"K2"_a, |
| 40 |
"cam_rays1"_a, |
| 41 |
"cam_rays2"_a, |
| 42 |
"Recover the most probable pose from the given homography matrix using " |
| 43 |
"the cheirality check."); |
| 44 |
} |