From 9227baf114ce435a7d62821a20ac74b1aaba0ce7 Mon Sep 17 00:00:00 2001 From: doronhi Date: Tue, 17 Dec 2019 11:12:27 +0200 Subject: [PATCH] Add python bindings. --- wrappers/python/pyrs_device.cpp | 3 +++ wrappers/python/pyrs_sensor.cpp | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wrappers/python/pyrs_device.cpp b/wrappers/python/pyrs_device.cpp index 9b3ee35aa8..219f96b366 100644 --- a/wrappers/python/pyrs_device.cpp +++ b/wrappers/python/pyrs_device.cpp @@ -15,6 +15,9 @@ void init_device(py::module &m) { .def("first_depth_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ .def("first_roi_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ .def("first_pose_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ + .def("first_color_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ + .def("first_motion_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ + .def("first_fisheye_sensor", [](rs2::device& self) { return self.first(); }) // No docstring in C++ .def("supports", &rs2::device::supports, "Check if specific camera info is supported.", "info"_a) .def("get_info", &rs2::device::get_info, "Retrieve camera specific information, " "like versions of various internal components", "info"_a) diff --git a/wrappers/python/pyrs_sensor.cpp b/wrappers/python/pyrs_sensor.cpp index adf98a3356..be17582897 100644 --- a/wrappers/python/pyrs_sensor.cpp +++ b/wrappers/python/pyrs_sensor.cpp @@ -67,6 +67,9 @@ void init_sensor(py::module &m) { .def("__nonzero__", &rs2::sensor::operator bool) // No docstring in C++ .def(BIND_DOWNCAST(sensor, roi_sensor)) .def(BIND_DOWNCAST(sensor, depth_sensor)) + .def(BIND_DOWNCAST(sensor, color_sensor)) + .def(BIND_DOWNCAST(sensor, motion_sensor)) + .def(BIND_DOWNCAST(sensor, fisheye_sensor)) .def(BIND_DOWNCAST(sensor, pose_sensor)) .def(BIND_DOWNCAST(sensor, wheel_odometer)); @@ -85,6 +88,18 @@ void init_sensor(py::module &m) { "Retrieves mapping between the units of the depth image and meters.") .def("__nonzero__", &rs2::depth_sensor::operator bool); // No docstring in C++ + py::class_ color_sensor(m, "color_sensor"); // No docstring in C++ + color_sensor.def(py::init(), "sensor"_a) + .def("__nonzero__", &rs2::color_sensor::operator bool); // No docstring in C++ + + py::class_ motion_sensor(m, "motion_sensor"); // No docstring in C++ + motion_sensor.def(py::init(), "sensor"_a) + .def("__nonzero__", &rs2::motion_sensor::operator bool); // No docstring in C++ + + py::class_ fisheye_sensor(m, "fisheye_sensor"); // No docstring in C++ + fisheye_sensor.def(py::init(), "sensor"_a) + .def("__nonzero__", &rs2::fisheye_sensor::operator bool); // No docstring in C++ + // rs2::depth_stereo_sensor py::class_ depth_stereo_sensor(m, "depth_stereo_sensor"); // No docstring in C++ depth_stereo_sensor.def(py::init()) @@ -96,7 +111,7 @@ void init_sensor(py::module &m) { "Load relocalization map onto device. Only one relocalization map can be imported at a time; " "any previously existing map will be overwritten.\n" "The imported map exists simultaneously with the map created during the most recent tracking " - "session after \start()," + "session after start()," "and they are merged after the imported map is relocalized.\n" "This operation must be done before start().", "lmap_buf"_a) .def("export_localization_map", &rs2::pose_sensor::export_localization_map,