Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Python Fixes #4808

Merged
merged 3 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions wrappers/python/pyrs_advanced_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ void init_advanced_mode(py::module &m) {
return ss.str();
});

py::class_<STAFactor> _STAFactor(m, "STAFactor");
_STAFactor.def(py::init<>())
.def_readwrite("a_factor", &STAFactor::amplitude)
.def("__repr__", [](const STAFactor &e) {
std::stringstream ss;
ss << "a_factor: " << e.amplitude;
return ss.str();
});

py::class_<rs400::advanced_mode> rs400_advanced_mode(m, "rs400_advanced_mode");
rs400_advanced_mode.def(py::init<rs2::device>(), "device"_a)
.def("toggle_advanced_mode", &rs400::advanced_mode::toggle_advanced_mode, "enable"_a)
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/pyrs_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/pyrs_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void init_processing(py::module &m) {
py::class_<rs2::frame_source> 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,
Expand Down
4 changes: 2 additions & 2 deletions wrappers/python/pyrs_record_playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(rs2_playback_status)> callback) {
self.set_status_changed_callback(callback);
Expand Down
11 changes: 7 additions & 4 deletions wrappers/python/pyrsutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,30 @@ void init_util(py::module &m) {
std::array<float, 2> 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<float, 2>& pixel, float depth)->std::array<float, 3>
{
std::array<float, 3> 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<float, 3>& from_point)->std::array<float, 3>
{
std::array<float, 3> 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<float, 2>
{
std::array<float, 2> 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 **/
}