20 namespace visualization {
23 static const std::unordered_map<std::string, std::string>
25 {
"callback_func",
"The call back function."},
27 "Scale depth value when capturing the depth image."},
28 {
"do_render",
"Set to ``True`` to do render."},
29 {
"filename",
"Path to file."},
30 {
"geometry",
"The ``Geometry`` object."},
31 {
"height",
"Height of window."},
32 {
"left",
"Left margin of the window to the screen."},
33 {
"top",
"Top margin of the window to the screen."},
34 {
"visible",
"Whether the window is visible."},
35 {
"width",
"Width of the window."},
36 {
"window_name",
"Window title name."},
37 {
"convert_to_world_coordinate",
38 "Set to ``True`` to convert to world coordinates"},
39 {
"reset_bounding_box",
40 "Set to ``False`` to keep current viewpoint"}};
43 py::class_<Visualizer, PyVisualizer<>, std::shared_ptr<Visualizer>>
44 visualizer(m,
"Visualizer",
"The main Visualizer class.");
45 py::detail::bind_default_constructor<Visualizer>(visualizer);
49 return std::string(
"Visualizer with name ") +
53 "Function to create a window and initialize GLFW",
54 "window_name"_a =
"CloudViewer",
"width"_a = 1920,
55 "height"_a = 1080,
"left"_a = 50,
"top"_a = 50,
58 "Function to destroy a window. This function MUST be called "
59 "from the main thread.")
60 .def(
"register_animation_callback",
62 "Function to register a callback function for animation. The "
63 "callback function returns if UpdateGeometry() needs to be "
67 "Function to activate the window. This function will block "
68 "the current thread until the window is closed.")
70 "Function to notify the window to be closed")
72 "Function to reset view point",
"reset_bounding_box"_a =
false)
74 "Function to update geometry. This function must be called "
75 "when geometry has been changed. Otherwise the behavior of "
76 "Visualizer is undefined.",
79 "Function to inform render needed to be updated")
81 "Function to change between fullscreen and windowed",
84 "Function to toggle between fullscreen and windowed")
86 "Function to query whether in fullscreen mode")
88 "Function to poll events")
90 "Function to add geometry to the scene and create "
91 "corresponding shaders",
92 "geometry"_a,
"reset_bounding_box"_a =
true)
94 "Function to remove geometry",
"geometry"_a,
95 "reset_bounding_box"_a =
true)
97 "Function to clear geometries from the visualizer")
99 "Function to retrieve the associated ``ViewControl``",
100 py::return_value_policy::reference_internal)
102 "Function to retrieve the associated ``RenderOption``",
103 py::return_value_policy::reference_internal)
104 .def(
"capture_screen_float_buffer",
106 "Function to capture screen and store RGB in a float buffer",
107 "do_render"_a =
false)
109 "capture_screen_image",
112 return self.CaptureScreenImage(
filename.string(),
115 "Function to capture and save a screen image",
"filename"_a,
116 "do_render"_a =
false)
117 .def(
"capture_depth_float_buffer",
119 "Function to capture depth in a float buffer",
120 "do_render"_a =
false)
122 "capture_depth_image",
124 bool do_render,
double depth_scale) {
125 self.CaptureDepthImage(
filename.string(), do_render,
128 "Function to capture and save a depth image",
"filename"_a,
129 "do_render"_a =
false,
"depth_scale"_a = 1000.0)
131 "capture_depth_point_cloud",
133 bool do_render,
bool convert_to_world_coordinate) {
134 self.CaptureDepthPointCloud(
136 convert_to_world_coordinate);
138 "Function to capture and save local point cloud",
139 "filename"_a,
"do_render"_a =
false,
140 "convert_to_world_coordinate"_a =
false)
145 std::shared_ptr<VisualizerWithKeyCallback>>
146 visualizer_key(m,
"VisualizerWithKeyCallback", visualizer,
147 "Visualizer with custom key callack capabilities.");
148 py::detail::bind_default_constructor<VisualizerWithKeyCallback>(
154 "VisualizerWithKeyCallback with name ") +
157 .def(
"register_key_callback",
159 "Function to register a callback function for a key press "
161 "key"_a,
"callback_func"_a)
163 .def(
"register_key_action_callback",
165 "Function to register a callback function for a key action "
166 "event. The callback function takes `Visualizer`, `action` "
167 "and `mods` as input and returns a boolean indicating if "
168 "`UpdateGeometry()` needs to be run. The `action` can be one "
169 "of `GLFW_RELEASE` (0), `GLFW_PRESS` (1) or `GLFW_REPEAT` "
170 "(2), see `GLFW input interface "
171 "<https://www.glfw.org/docs/latest/group__input.html>`__. The "
172 "`mods` specifies the modifier key, see `GLFW modifier key "
173 "<https://www.glfw.org/docs/latest/group__mods.html>`__",
174 "key"_a,
"callback_func"_a)
176 .def(
"register_mouse_move_callback",
178 "Function to register a callback function for a mouse move "
179 "event. The callback function takes Visualizer, x and y mouse "
180 "position inside the window as input and returns a boolean "
181 "indicating if UpdateGeometry() needs to be run. `GLFW mouse "
182 "position <https://www.glfw.org/docs/latest/"
183 "input_guide.html#input_mouse>`__ for more details.",
186 .def(
"register_mouse_scroll_callback",
188 "Function to register a callback function for a mouse scroll "
189 "event. The callback function takes Visualizer, x and y mouse "
190 "scroll offset as input and returns a boolean "
191 "indicating if UpdateGeometry() needs to be run. `GLFW mouse "
192 "scrolling <https://www.glfw.org/docs/latest/"
193 "input_guide.html#scrolling>`__ for more details.",
196 .def(
"register_mouse_button_callback",
198 "Function to register a callback function for a mouse button "
199 "event. The callback function takes `Visualizer`, `button`, "
200 "`action` and `mods` as input and returns a boolean "
201 "indicating `UpdateGeometry()` needs to be run. The `action` "
202 "can be one of GLFW_RELEASE (0), GLFW_PRESS (1) or "
203 "GLFW_REPEAT (2), see `GLFW input interface "
204 "<https://www.glfw.org/docs/latest/group__input.html>`__. "
205 "The `mods` specifies the modifier key, see `GLFW modifier "
206 "key <https://www.glfw.org/docs/latest/group__mods.html>`__.",
209 py::class_<VisualizerWithEditing, PyVisualizer<VisualizerWithEditing>,
210 std::shared_ptr<VisualizerWithEditing>>
211 visualizer_edit(m,
"VisualizerWithEditing", visualizer,
212 "Visualizer with editing capabilities.");
213 py::detail::bind_default_constructor<VisualizerWithEditing>(
216 .def(py::init<double, bool, const std::string &>(),
"voxel_size"_a,
217 "use_dialog"_a,
"directory"_a)
220 return std::string(
"VisualizerWithEditing with name ") +
224 "Function to get picked points");
228 std::shared_ptr<VisualizerWithVertexSelection>>
230 m,
"VisualizerWithVertexSelection", visualizer,
231 "Visualizer with vertex selection capabilities.");
232 py::detail::bind_default_constructor<VisualizerWithVertexSelection>(
234 visualizer_vselect.def(py::init<>())
238 "VisualizerWithVertexSelection with "
243 "Function to pick points",
"x"_a,
"y"_a,
"w"_a,
"h"_a)
244 .def(
"get_picked_points",
246 "Function to get picked points")
247 .def(
"clear_picked_points",
249 "Function to clear picked points")
250 .def(
"add_picked_points",
252 "Function to add picked points",
"indices"_a)
253 .def(
"remove_picked_points",
255 "Function to remove picked points",
"indices"_a)
256 .def(
"register_selection_changed_callback",
258 RegisterSelectionChangedCallback,
259 "Registers a function to be called when selection changes",
261 .def(
"register_selection_moving_callback",
263 RegisterSelectionMovingCallback,
264 "Registers a function to be called while selection moves. "
265 "Geometry's vertex values can be changed, but do not change"
266 "the number of vertices.",
268 .def(
"register_selection_moved_callback",
270 "Registers a function to be called after selection moves",
273 py::class_<VisualizerWithVertexSelection::PickedPoint>
274 visualizer_vselect_pickedpoint(m,
"PickedPoint");
275 visualizer_vselect_pickedpoint.def(py::init<>())
276 .def_readwrite(
"index",
278 .def_readwrite(
"coord",
286 "capture_depth_float_buffer",
291 "capture_depth_point_cloud",
294 "capture_screen_float_buffer",
313 "register_animation_callback",
Visualizer with editing capabilities.
std::vector< size_t > & GetPickedPoints()
Visualizer with custom key callack capabilities.
void RegisterMouseScrollCallback(std::function< bool(Visualizer *, double, double)> callback)
void RegisterMouseMoveCallback(std::function< bool(Visualizer *, double, double)> callback)
void RegisterKeyActionCallback(int key, std::function< bool(Visualizer *, int, int)> callback)
void RegisterMouseButtonCallback(std::function< bool(Visualizer *, int, int, int)> callback)
void RegisterKeyCallback(int key, std::function< bool(Visualizer *)> callback)
std::vector< PickedPoint > GetPickedPoints() const
void RemovePickedPoints(const std::vector< int > indices)
void AddPickedPoints(const std::vector< int > indices)
std::vector< int > PickPoints(double x, double y, double w, double h)
void RegisterSelectionMovedCallback(std::function< void()> f)
The main Visualizer class.
virtual bool UpdateGeometry(std::shared_ptr< const ccHObject > geometry_ptr=nullptr)
Function to update geometry.
virtual bool IsFullScreen()
std::shared_ptr< geometry::Image > CaptureDepthFloatBuffer(bool do_render=true)
const std::string & GetWindowName() const
RenderOption & GetRenderOption()
Function to retrieve the associated RenderOption.
virtual bool RemoveGeometry(std::shared_ptr< const ccHObject > geometry_ptr, bool reset_bounding_box=true)
Function to remove geometry from the scene.
virtual void UpdateRender()
Function to inform render needed to be updated.
void ResetViewPoint(bool reset_bounding_box=false)
Function to reset view point.
virtual bool AddGeometry(std::shared_ptr< const ccHObject > geometry_ptr, bool reset_bounding_box=true)
Function to add geometry to the scene and create corresponding shaders.
void DestroyVisualizerWindow()
Function to destroy a window.
void Run()
Function to activate the window.
virtual void SetFullScreen(bool fullscreen)
Functions to change between fullscreen and windowed modes.
void Close()
Function to to notify the window to be closed.
void RegisterAnimationCallback(std::function< bool(Visualizer *)> callback_func)
Function to register a callback function for animation.
bool CreateVisualizerWindow(const std::string &window_name="CloudViewer", const int width=640, const int height=480, const int left=50, const int top=50, const bool visible=true)
Function to create a window and initialize GLFW.
virtual void ToggleFullScreen()
std::shared_ptr< geometry::Image > CaptureScreenFloatBuffer(bool do_render=true)
Function to capture screen and store RGB in a float buffer.
ViewControl & GetViewControl()
Function to retrieve the associated ViewControl.
virtual bool ClearGeometries()
void ClassMethodDocInject(py::module &pybind_module, const std::string &class_name, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
static const std::string path
void pybind_visualizer_method(py::module &m)
void pybind_visualizer(py::module &m)
static const std::unordered_map< std::string, std::string > map_visualizer_docstrings
Generic file read and write utility for python interface.