forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyrs_sensor.cpp
114 lines (104 loc) · 7.51 KB
/
pyrs_sensor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* License: Apache 2.0. See LICENSE file in root directory.
Copyright(c) 2017 Intel Corporation. All Rights Reserved. */
#include "python.hpp"
#include "../include/librealsense2/hpp/rs_sensor.hpp"
void init_sensor(py::module &m) {
/** rs_sensor.hpp **/
py::class_<rs2::notification> notification(m, "notification"); // No docstring in C++
notification.def(py::init<>())
.def("get_category", &rs2::notification::get_category,
"Retrieve the notification's category.")
.def_property_readonly("category", &rs2::notification::get_category,
"The notification's category. Identical to calling get_category.")
.def("get_description", &rs2::notification::get_description,
"Retrieve the notification's description.")
.def_property_readonly("description", &rs2::notification::get_description,
"The notification's description. Identical to calling get_description.")
.def("get_timestamp", &rs2::notification::get_timestamp,
"Retrieve the notification's arrival timestamp.")
.def_property_readonly("timestamp", &rs2::notification::get_timestamp,
"The notification's arrival timestamp. Identical to calling get_timestamp.")
.def("get_severity", &rs2::notification::get_severity,
"Retrieve the notification's severity.")
.def_property_readonly("severity", &rs2::notification::get_severity,
"The notification's severity. Identical to calling get_severity.")
.def("get_serialized_data", &rs2::notification::get_severity,
"Retrieve the notification's serialized data.")
.def_property_readonly("serialized_data", &rs2::notification::get_serialized_data,
"The notification's serialized data. Identical to calling get_serialized_data.")
.def("__repr__", [](const rs2::notification &n) {
return n.get_description();
});
// not binding notifications_callback, templated
py::class_<rs2::sensor, rs2::options> sensor(m, "sensor"); // No docstring in C++
sensor.def("open", (void (rs2::sensor::*)(const rs2::stream_profile&) const) &rs2::sensor::open,
"Open sensor for exclusive access, by commiting to a configuration", "profile"_a)
.def("supports", (bool (rs2::sensor::*)(rs2_camera_info) const) &rs2::sensor::supports,
"Check if specific camera info is supported.", "info")
.def("supports", (bool (rs2::sensor::*)(rs2_option) const) &rs2::options::supports,
"Check if specific camera info is supported.", "info")
.def("get_info", &rs2::sensor::get_info, "Retrieve camera specific information, "
"like versions of various internal components.", "info"_a)
.def("set_notifications_callback", [](const rs2::sensor& self, std::function<void(rs2::notification)> callback) {
self.set_notifications_callback(callback);
}, "Register Notifications callback", "callback"_a)
.def("open", (void (rs2::sensor::*)(const std::vector<rs2::stream_profile>&) const) &rs2::sensor::open,
"Open sensor for exclusive access, by committing to a composite configuration, specifying one or "
"more stream profiles.", "profiles"_a)
.def("close", &rs2::sensor::close, "Close sensor for exclusive access.", py::call_guard<py::gil_scoped_release>())
.def("start", [](const rs2::sensor& self, std::function<void(rs2::frame)> callback) {
self.start(callback);
}, "Start passing frames into user provided callback.", "callback"_a)
.def("start", [](const rs2::sensor& self, rs2::syncer& syncer) {
self.start(syncer);
}, "Start passing frames into user provided syncer.", "syncer"_a)
.def("start", [](const rs2::sensor& self, rs2::frame_queue& queue) {
self.start(queue);
}, "start passing frames into specified frame_queue", "queue"_a)
.def("stop", &rs2::sensor::stop, "Stop streaming.", py::call_guard<py::gil_scoped_release>())
.def("get_stream_profiles", &rs2::sensor::get_stream_profiles, "Retrieves the list of stream profiles supported by the sensor.")
.def_property_readonly("profiles", &rs2::sensor::get_stream_profiles, "The list of stream profiles supported by the sensor. Identical to calling get_stream_profiles")
.def("get_recommended_filters", &rs2::sensor::get_recommended_filters, "Return the recommended list of filters by the sensor.")
.def(py::init<>())
.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, pose_sensor))
.def(BIND_DOWNCAST(sensor, wheel_odometer));
// rs2::sensor_from_frame [frame.def("get_sensor", ...)?
// rs2::sensor==sensor?
py::class_<rs2::roi_sensor, rs2::sensor> roi_sensor(m, "roi_sensor"); // No docstring in C++
roi_sensor.def(py::init<rs2::sensor>(), "sensor"_a)
.def("set_region_of_interest", &rs2::roi_sensor::set_region_of_interest, "roi"_a) // No docstring in C++
.def("get_region_of_interest", &rs2::roi_sensor::get_region_of_interest) // No docstring in C++
.def("__nonzero__", &rs2::roi_sensor::operator bool); // No docstring in C++
py::class_<rs2::depth_sensor, rs2::sensor> depth_sensor(m, "depth_sensor"); // No docstring in C++
depth_sensor.def(py::init<rs2::sensor>(), "sensor"_a)
.def("get_depth_scale", &rs2::depth_sensor::get_depth_scale,
"Retrieves mapping between the units of the depth image and meters.")
.def("__nonzero__", &rs2::depth_sensor::operator bool); // No docstring in C++
// rs2::depth_stereo_sensor
py::class_<rs2::depth_stereo_sensor, rs2::depth_sensor> depth_stereo_sensor(m, "depth_stereo_sensor"); // No docstring in C++
depth_stereo_sensor.def(py::init<rs2::sensor>())
.def("get_stereo_baseline", &rs2::depth_stereo_sensor::get_stereo_baseline, "Retrieve the stereoscopic baseline value from the sensor.");
py::class_<rs2::pose_sensor, rs2::sensor> pose_sensor(m, "pose_sensor"); // No docstring in C++
pose_sensor.def(py::init<rs2::sensor>(), "sensor"_a)
.def("import_localization_map", &rs2::pose_sensor::import_localization_map,
"Load SLAM localization map from host to device.", "lmap_buf"_a)
.def("export_localization_map", &rs2::pose_sensor::export_localization_map,
"Extract SLAM localization map from device and store on host.")
.def("set_static_node", &rs2::pose_sensor::set_static_node,
"Create a named reference frame anchored to a specific 3D pose.")
.def("get_static_node", &rs2::pose_sensor::get_static_node,
"Retrieve a named reference frame anchored to a specific 3D pose.")
.def("__nonzero__", &rs2::pose_sensor::operator bool); // No docstring in C++
py::class_<rs2::wheel_odometer, rs2::sensor> wheel_odometer(m, "wheel_odometer"); // No docstring in C++
wheel_odometer.def(py::init<rs2::sensor>(), "sensor"_a)
.def("load_wheel_odometery_config", &rs2::wheel_odometer::load_wheel_odometery_config,
"Load Wheel odometer settings from host to device.", "odometry_config_buf"_a)
.def("send_wheel_odometry", &rs2::wheel_odometer::send_wheel_odometry,
"Send wheel odometry data for each individual sensor (wheel)",
"wo_sensor_id"_a, "frame_num"_a, "translational_velocity"_a)
.def("__nonzero__", &rs2::wheel_odometer::operator bool);
/** end rs_sensor.hpp **/
}