From 6ac3f1beabee6393e26c00860131f89d3ef4f9af Mon Sep 17 00:00:00 2001 From: Lior Ramati Date: Wed, 4 Sep 2019 19:05:48 +0300 Subject: [PATCH 1/3] Fix python docstring display glitch --- wrappers/python/pyrs_context.cpp | 2 +- wrappers/python/pyrs_processing.cpp | 2 +- wrappers/python/pyrs_record_playback.cpp | 4 ++-- wrappers/python/pyrsutil.cpp | 11 +++++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/wrappers/python/pyrs_context.cpp b/wrappers/python/pyrs_context.cpp index 03d81000c8..5de84cab76 100644 --- a/wrappers/python/pyrs_context.cpp +++ b/wrappers/python/pyrs_context.cpp @@ -31,7 +31,7 @@ void init_context(py::module &m) { self.set_devices_changed_callback(callback); }, "Register devices changed callback.", "callback"_a) .def("load_device", &rs2::context::load_device, "Creates a devices from a RealSense file.\n" - "On successful load, the device will be appended to the context and a devices_changed event triggered." + "On successful load, the device will be appended to the context and a devices_changed event triggered.", "filename"_a) .def("unload_device", &rs2::context::unload_device, "filename"_a) // No docstring in C++ .def("unload_tracking_module", &rs2::context::unload_tracking_module); // No docstring in C++ diff --git a/wrappers/python/pyrs_processing.cpp b/wrappers/python/pyrs_processing.cpp index ab38fe3763..7b39c8e7a0 100644 --- a/wrappers/python/pyrs_processing.cpp +++ b/wrappers/python/pyrs_processing.cpp @@ -9,7 +9,7 @@ void init_processing(py::module &m) { py::class_ frame_source(m, "frame_source", "The source used to generate frames, which is usually done by the low level driver for each sensor. " "frame_source is one of the parameters of processing_block's callback function, which can be used to re-generate the " "frame and via frame_ready invoke another callback function to notify application frame is ready."); - frame_source.def("allocate_video_frame", &rs2::frame_source::allocate_video_frame, "Allocate a new video frame with given params" + frame_source.def("allocate_video_frame", &rs2::frame_source::allocate_video_frame, "Allocate a new video frame with given params", "profile"_a, "original"_a, "new_bpp"_a = 0, "new_width"_a = 0, "new_height"_a = 0, "new_stride"_a = 0, "frame_type"_a = RS2_EXTENSION_VIDEO_FRAME) .def("allocate_points", &rs2::frame_source::allocate_points, "profile"_a, diff --git a/wrappers/python/pyrs_record_playback.cpp b/wrappers/python/pyrs_record_playback.cpp index 8db2e8cde3..f01f732a5f 100644 --- a/wrappers/python/pyrs_record_playback.cpp +++ b/wrappers/python/pyrs_record_playback.cpp @@ -16,12 +16,12 @@ void init_record_playback(py::module &m) { .def("file_name", &rs2::playback::file_name, "The name of the playback file.") .def("get_position", &rs2::playback::get_position, "Retrieves the current position of the playback in the file in terms of time. Units are expressed in nanoseconds.") .def("get_duration", &rs2::playback::get_duration, "Retrieves the total duration of the file.") - .def("seek", &rs2::playback::seek, "Sets the playback to a specified time point of the played data." "time"_a) + .def("seek", &rs2::playback::seek, "Sets the playback to a specified time point of the played data.", "time"_a) .def("is_real_time", &rs2::playback::is_real_time, "Indicates if playback is in real time mode or non real time.") .def("set_real_time", &rs2::playback::set_real_time, "Set the playback to work in real time or non real time. In real time mode, playback will " "play the same way the file was recorded. If the application takes too long to handle the callback, frames may be dropped. In non real time " "mode, playback will wait for each callback to finish handling the data before reading the next frame. In this mode no frames will be dropped, " - "and the application controls the framerate of playback via callback duration." "real_time"_a) + "and the application controls the framerate of playback via callback duration.", "real_time"_a) // set_playback_speed? .def("set_status_changed_callback", [](rs2::playback& self, std::function callback) { self.set_status_changed_callback(callback); diff --git a/wrappers/python/pyrsutil.cpp b/wrappers/python/pyrsutil.cpp index 8f52c40243..6256e7c4ba 100644 --- a/wrappers/python/pyrsutil.cpp +++ b/wrappers/python/pyrsutil.cpp @@ -11,27 +11,30 @@ void init_util(py::module &m) { std::array pixel{}; rs2_project_point_to_pixel(pixel.data(), &intrin, point.data()); return pixel; - }, "Given a point in 3D space, compute the corresponding pixel coordinates in an image with no distortion or forward distortion coefficients produced by the same camera"); + }, "Given a point in 3D space, compute the corresponding pixel coordinates in an image with no distortion or forward distortion coefficients produced by the same camera", + "intrin"_a, "point"_a); m.def("rs2_deproject_pixel_to_point", [](const rs2_intrinsics& intrin, const std::array& pixel, float depth)->std::array { std::array point{}; rs2_deproject_pixel_to_point(point.data(), &intrin, pixel.data(), depth); return point; - }, "Given pixel coordinates and depth in an image with no distortion or inverse distortion coefficients, compute the corresponding point in 3D space relative to the same camera"); + }, "Given pixel coordinates and depth in an image with no distortion or inverse distortion coefficients, compute the corresponding point in 3D space relative to the same camera", + "intrin"_a, "pixel"_a, "depth"_a); m.def("rs2_transform_point_to_point", [](const rs2_extrinsics& extrin, const std::array& from_point)->std::array { std::array to_point{}; rs2_transform_point_to_point(to_point.data(), &extrin, from_point.data()); return to_point; - }, "Transform 3D coordinates relative to one sensor to 3D coordinates relative to another viewpoint"); + }, "Transform 3D coordinates relative to one sensor to 3D coordinates relative to another viewpoint", + "extrin"_a, "from_point"_a); m.def("rs2_fov", [](const rs2_intrinsics& intrin)->std::array { std::array to_fow{}; rs2_fov(&intrin, to_fow.data()); return to_fow; - }, "Calculate horizontal and vertical field of view, based on video intrinsics"); + }, "Calculate horizontal and vertical field of view, based on video intrinsics", "intrin"_a); /** end rsutil.h **/ } From b128f0b430a589e299d8b2110dfb4f30c579dc15 Mon Sep 17 00:00:00 2001 From: Lior Ramati Date: Thu, 5 Sep 2019 14:42:44 +0300 Subject: [PATCH 2/3] Add STAFactor to python wrapper to fix advanced_mode.get/set_amp_factor --- wrappers/python/pyrs_advanced_mode.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wrappers/python/pyrs_advanced_mode.cpp b/wrappers/python/pyrs_advanced_mode.cpp index 3586d17839..c9cf51d132 100644 --- a/wrappers/python/pyrs_advanced_mode.cpp +++ b/wrappers/python/pyrs_advanced_mode.cpp @@ -211,6 +211,15 @@ void init_advanced_mode(py::module &m) { return ss.str(); }); + py::class_ _STAFactor(m, "STAFactor"); + _STAFactor.def(py::init<>()) + .def_readwrite("amplitude", &STAFactor::amplitude) + .def("__repr__", [](const STAFactor &e) { + std::stringstream ss; + ss << "amplitude: " << e.amplitude; + return ss.str(); + }); + py::class_ rs400_advanced_mode(m, "rs400_advanced_mode"); rs400_advanced_mode.def(py::init(), "device"_a) .def("toggle_advanced_mode", &rs400::advanced_mode::toggle_advanced_mode, "enable"_a) From 9f28362ca2ddce6cbb7dc381d937ce4a1f0c3da0 Mon Sep 17 00:00:00 2001 From: Lior Ramati Date: Thu, 5 Sep 2019 15:40:21 +0300 Subject: [PATCH 3/3] Rename STAFactor.amplitude --- wrappers/python/pyrs_advanced_mode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/python/pyrs_advanced_mode.cpp b/wrappers/python/pyrs_advanced_mode.cpp index c9cf51d132..72085a96fb 100644 --- a/wrappers/python/pyrs_advanced_mode.cpp +++ b/wrappers/python/pyrs_advanced_mode.cpp @@ -213,10 +213,10 @@ void init_advanced_mode(py::module &m) { py::class_ _STAFactor(m, "STAFactor"); _STAFactor.def(py::init<>()) - .def_readwrite("amplitude", &STAFactor::amplitude) + .def_readwrite("a_factor", &STAFactor::amplitude) .def("__repr__", [](const STAFactor &e) { std::stringstream ss; - ss << "amplitude: " << e.amplitude; + ss << "a_factor: " << e.amplitude; return ss.str(); });