| 1 |
#include "colmap/sensor/rig.h" |
| 2 |
|
| 3 |
#include "pycolmap/helpers.h" |
| 4 |
#include "pycolmap/pybind11_extension.h" |
| 5 |
#include "pycolmap/scene/types.h" |
| 6 |
|
| 7 |
#include <memory> |
| 8 |
|
| 9 |
#include <pybind11/pybind11.h> |
| 10 |
#include <pybind11/stl.h> |
| 11 |
#include <pybind11/stl_bind.h> |
| 12 |
|
| 13 |
using namespace colmap; |
| 14 |
using namespace pybind11::literals; |
| 15 |
namespace py = pybind11; |
| 16 |
|
| 17 |
void BindSensorRig(py::module& m) { |
| 18 |
py::classh<Rig> PyRig(m, "Rig"); |
| 19 |
PyRig.def(py::init<>()) |
| 20 |
.def_property("rig_id", |
| 21 |
&Rig::RigId, |
| 22 |
&Rig::SetRigId, |
| 23 |
"Unique identifier of the rig.") |
| 24 |
.def("add_ref_sensor", |
| 25 |
&Rig::AddRefSensor, |
| 26 |
"sensor_id" |
| 27 |
"Add reference sensor.") |
| 28 |
.def("add_sensor", |
| 29 |
&Rig::AddSensor, |
| 30 |
"sensor_id" |
| 31 |
"Add non-reference sensor.") |
| 32 |
.def("has_sensor", |
| 33 |
&Rig::HasSensor, |
| 34 |
"Whether the rig has a specific sensor.") |
| 35 |
.def("is_ref_sensor", |
| 36 |
&Rig::IsRefSensor, |
| 37 |
"Check whether the given sensor is the reference sensor.") |
| 38 |
.def("has_sensor_from_rig", |
| 39 |
&Rig::HasSensorFromRig, |
| 40 |
"sensor_id"_a, |
| 41 |
"Check if sensor has calibrated transformation from rig.") |
| 42 |
.def("num_sensors", &Rig::NumSensors, "The number of sensors in the rig.") |
| 43 |
.def_property_readonly("ref_sensor_id", |
| 44 |
&Rig::RefSensorId, |
| 45 |
"The reference sensor's identifier.") |
| 46 |
.def("sensor_ids", |
| 47 |
&Rig::SensorIds, |
| 48 |
"Get all sensor ids (including the reference sensor) in the rig.") |
| 49 |
.def("sensor_from_rig", |
| 50 |
py::overload_cast<sensor_t>(&Rig::MaybeSensorFromRig), |
| 51 |
"sensor_id"_a, |
| 52 |
"The transformation from rig to the sensor.") |
| 53 |
.def("set_sensor_from_rig", |
| 54 |
py::overload_cast<sensor_t, const std::optional<Rigid3d>&>( |
| 55 |
&Rig::SetSensorFromRig), |
| 56 |
"sensor_id"_a, |
| 57 |
"sensor_from_rig"_a, |
| 58 |
"Set the sensor_from_rig transformation.") |
| 59 |
.def("reset_sensor_from_rig", |
| 60 |
&Rig::ResetSensorFromRig, |
| 61 |
"sensor_id"_a, |
| 62 |
"Reset the sensor's calibration.") |
| 63 |
.def_property_readonly( |
| 64 |
"non_ref_sensors", |
| 65 |
py::overload_cast<>(&Rig::NonRefSensors), |
| 66 |
py::return_value_policy::reference_internal, |
| 67 |
"Access all sensors in the rig except for reference sensor"); |
| 68 |
MakeDataclass(PyRig); |
| 69 |
|
| 70 |
py::bind_map<RigMap>(m, "RigMap"); |
| 71 |
} |