Point Cloud Library (PCL)  1.10.0
image_viewer.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #pragma once
40 
41 #include <pcl/pcl_macros.h>
42 #include <pcl/point_types.h>
43 #include <pcl/console/print.h>
44 #include <pcl/visualization/interactor_style.h>
45 #include <pcl/visualization/vtk/pcl_image_canvas_source_2d.h>
46 #include <pcl/visualization/vtk/pcl_context_item.h>
47 #include <pcl/geometry/planar_polygon.h>
48 #include <pcl/correspondence.h>
49 
50 #include <boost/shared_array.hpp>
51 
52 #include <vtkVersion.h>
53 #include <vtkInteractorStyleImage.h>
54 #include <vtkRenderWindowInteractor.h>
55 
56 class vtkImageSlice;
57 class vtkContextActor;
58 class vtkImageViewer;
59 class vtkImageFlip;
60 
61 namespace pcl
62 {
63  namespace visualization
64  {
65  using Vector3ub = Eigen::Array<unsigned char, 3, 1>;
66  static const Vector3ub green_color (0, 255, 0);
67  static const Vector3ub red_color (255, 0, 0);
68  static const Vector3ub blue_color (0, 0, 255);
69 
70  /** \brief An image viewer interactor style, tailored for ImageViewer.
71  * \author Radu B. Rusu
72  * \ingroup visualization
73  */
74  class PCL_EXPORTS ImageViewerInteractorStyle : public vtkInteractorStyleImage
75  {
76  public:
77  static ImageViewerInteractorStyle *New ();
79 
80  void OnMouseWheelForward () override {}
81  void OnMouseWheelBackward () override {}
82  void OnMiddleButtonDown () override {}
83  void OnRightButtonDown () override {}
84  void OnLeftButtonDown () override;
85 
86  void
87  OnChar () override;
88 
89  void
90  adjustCamera (vtkImageData *image, vtkRenderer *ren);
91 
92  void
93  adjustCamera (vtkRenderer *ren);
94  };
95 
96  /** \brief ImageViewer is a class for 2D image visualization.
97  *
98  * Features include:
99  * - add and remove different layers with different opacity (transparency) values
100  * - add 2D geometric shapes (circles, boxes, etc) in separate layers
101  * - display RGB, monochrome, float, angle images
102  *
103  * Simple usage example:
104  * \code
105  * pcl::visualization::ImageViewer iv;
106  * iv.addCircle (10, 10, 5, 1.0, 0.0, 0.0, "circles", 1.0); // add a red, fully opaque circle with radius 5 pixels at (10,10) in layer "circles"
107  * iv.addFilledRectangle (10, 20, 10, 20, 0.0, 1.0, 0.0, "boxes", 0.5); // add a green, 50% transparent box at (10,10->20,20) in layer "boxes"
108  * iv.addRGBImage<pcl::PointXYZRGBA> (cloud); // add a RGB image from a point cloud dataset in an "rgb_image" default layer
109  * iv.spin (); // press 'q' to exit
110  * iv.removeLayer ("circles"); // remove layer "circles"
111  * iv.spin (); // press 'q' to exit
112  * \endcode
113  *
114  * \author Radu B. Rusu, Suat Gedikli
115  * \ingroup visualization
116  */
118  {
119  public:
122 
123  /** \brief Constructor.
124  * \param[in] window_title the title of the window
125  */
126  ImageViewer (const std::string& window_title = "");
127 
128  /** \brief Destructor. */
129  virtual ~ImageViewer ();
130 
131  /** \brief Set up the interactor style. By default the interactor style is set to
132  * vtkInteractorStyleImage you can use this to set it to another type.
133  * \param[in] style user set interactor style.
134  */
135  void
136  setInteractorStyle (vtkInteractorObserver *style)
137  {
138  interactor_->SetInteractorStyle (style);
139  }
140 
141  /** \brief Show a monochrome 2D image on screen.
142  * \param[in] data the input data representing the image
143  * \param[in] width the width of the image
144  * \param[in] height the height of the image
145  * \param[in] layer_id the name of the layer (default: "image")
146  * \param[in] opacity the opacity of the layer (default: 1.0)
147  */
148  void
149  showMonoImage (const unsigned char* data, unsigned width, unsigned height,
150  const std::string &layer_id = "mono_image", double opacity = 1.0);
151 
152  /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
153  * \param[in] data the input data representing the image
154  * \param[in] width the width of the image
155  * \param[in] height the height of the image
156  * \param[in] layer_id the name of the layer (default: "image")
157  * \param[in] opacity the opacity of the layer (default: 1.0)
158  */
159  void
160  addMonoImage (const unsigned char* data, unsigned width, unsigned height,
161  const std::string &layer_id = "mono_image", double opacity = 1.0);
162 
163  /** \brief Show a monochrome 2D image on screen.
164  * \param[in] cloud the input data representing the grayscale point cloud
165  * \param[in] layer_id the name of the layer (default: "image")
166  * \param[in] opacity the opacity of the layer (default: 1.0)
167  */
168  inline void
170  const std::string &layer_id = "mono_image", double opacity = 1.0)
171  {
172  return (showMonoImage (*cloud, layer_id, opacity));
173  }
174 
175  /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
176  * \param[in] cloud the input data representing the grayscale point cloud
177  * \param[in] layer_id the name of the layer (default: "image")
178  * \param[in] opacity the opacity of the layer (default: 1.0)
179  */
180  inline void
182  const std::string &layer_id = "mono_image", double opacity = 1.0)
183  {
184  return (addMonoImage (*cloud, layer_id, opacity));
185  }
186 
187  /** \brief Show a monochrome 2D image on screen.
188  * \param[in] cloud the input data representing the grayscale point cloud
189  * \param[in] layer_id the name of the layer (default: "image")
190  * \param[in] opacity the opacity of the layer (default: 1.0)
191  */
192  void
193  showMonoImage (const pcl::PointCloud<pcl::Intensity> &cloud,
194  const std::string &layer_id = "mono_image", double opacity = 1.0);
195 
196  /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
197  * \param[in] cloud the input data representing the RGB point cloud
198  * \param[in] layer_id the name of the layer (default: "image")
199  * \param[in] opacity the opacity of the layer (default: 1.0)
200  */
201  void
202  addMonoImage (const pcl::PointCloud<pcl::Intensity> &cloud,
203  const std::string &layer_id = "mono_image", double opacity = 1.0);
204 
205  /** \brief Show a monochrome 2D image on screen.
206  * \param[in] cloud the input data representing the grayscale point cloud
207  * \param[in] layer_id the name of the layer (default: "image")
208  * \param[in] opacity the opacity of the layer (default: 1.0)
209  */
210  inline void
212  const std::string &layer_id = "mono_image", double opacity = 1.0)
213  {
214  return (showMonoImage (*cloud, layer_id, opacity));
215  }
216 
217  /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
218  * \param[in] cloud the input data representing the grayscale point cloud
219  * \param[in] layer_id the name of the layer (default: "image")
220  * \param[in] opacity the opacity of the layer (default: 1.0)
221  */
222  inline void
224  const std::string &layer_id = "mono_image", double opacity = 1.0)
225  {
226  return (addMonoImage (*cloud, layer_id, opacity));
227  }
228 
229  /** \brief Show a monochrome 2D image on screen.
230  * \param[in] cloud the input data representing the grayscale point cloud
231  * \param[in] layer_id the name of the layer (default: "image")
232  * \param[in] opacity the opacity of the layer (default: 1.0)
233  */
234  void
235  showMonoImage (const pcl::PointCloud<pcl::Intensity8u> &cloud,
236  const std::string &layer_id = "mono_image", double opacity = 1.0);
237 
238  /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
239  * \param[in] cloud the input data representing the RGB point cloud
240  * \param[in] layer_id the name of the layer (default: "image")
241  * \param[in] opacity the opacity of the layer (default: 1.0)
242  */
243  void
244  addMonoImage (const pcl::PointCloud<pcl::Intensity8u> &cloud,
245  const std::string &layer_id = "mono_image", double opacity = 1.0);
246 
247  /** \brief Show a 2D RGB image on screen.
248  * \param[in] data the input data representing the image
249  * \param[in] width the width of the image
250  * \param[in] height the height of the image
251  * \param[in] layer_id the name of the layer (default: "image")
252  * \param[in] opacity the opacity of the layer (default: 1.0)
253  */
254  void
255  showRGBImage (const unsigned char* data, unsigned width, unsigned height,
256  const std::string &layer_id = "rgb_image", double opacity = 1.0);
257 
258  /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update).
259  * \param[in] data the input data representing the image
260  * \param[in] width the width of the image
261  * \param[in] height the height of the image
262  * \param[in] layer_id the name of the layer (default: "image")
263  * \param[in] opacity the opacity of the layer (default: 1.0)
264  * \param[in] autoresize flag to enable window to adapt to image size (default true)
265  */
266  void
267  addRGBImage (const unsigned char* data, unsigned width, unsigned height,
268  const std::string &layer_id = "rgb_image", double opacity = 1.0,
269  bool autoresize = true);
270 
271  /** \brief Show a 2D image on screen, obtained from the RGB channel of a point cloud.
272  * \param[in] cloud the input data representing the RGB point cloud
273  * \param[in] layer_id the name of the layer (default: "image")
274  * \param[in] opacity the opacity of the layer (default: 1.0)
275  */
276  template <typename T> inline void
278  const std::string &layer_id = "rgb_image", double opacity = 1.0)
279  {
280  return (showRGBImage<T> (*cloud, layer_id, opacity));
281  }
282 
283  /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update).
284  * \param[in] cloud the input data representing the RGB point cloud
285  * \param[in] layer_id the name of the layer (default: "image")
286  * \param[in] opacity the opacity of the layer (default: 1.0)
287  */
288  template <typename T> inline void
290  const std::string &layer_id = "rgb_image", double opacity = 1.0)
291  {
292  return (addRGBImage<T> (*cloud, layer_id, opacity));
293  }
294 
295  /** \brief Show a 2D image on screen, obtained from the RGB channel of a point cloud.
296  * \param[in] cloud the input data representing the RGB point cloud
297  * \param[in] layer_id the name of the layer (default: "image")
298  * \param[in] opacity the opacity of the layer (default: 1.0)
299  */
300  template <typename T> void
301  showRGBImage (const pcl::PointCloud<T> &cloud,
302  const std::string &layer_id = "rgb_image", double opacity = 1.0);
303 
304  /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update).
305  * \param[in] cloud the input data representing the RGB point cloud
306  * \param[in] layer_id the name of the layer (default: "image")
307  * \param[in] opacity the opacity of the layer (default: 1.0)
308  */
309  template <typename T> void
310  addRGBImage (const pcl::PointCloud<T> &cloud,
311  const std::string &layer_id = "rgb_image", double opacity = 1.0);
312 
313  /** \brief Show a 2D image (float) on screen.
314  * \param[in] data the input data representing the image in float format
315  * \param[in] width the width of the image
316  * \param[in] height the height of the image
317  * \param[in] min_value filter all values in the image to be larger than this minimum value
318  * \param[in] max_value filter all values in the image to be smaller than this maximum value
319  * \param[in] grayscale show data as grayscale (true) or not (false). Default: false
320  * \param[in] layer_id the name of the layer (default: "image")
321  * \param[in] opacity the opacity of the layer (default: 1.0)
322  */
323  void
324  showFloatImage (const float* data, unsigned int width, unsigned int height,
325  float min_value = std::numeric_limits<float>::min (),
326  float max_value = std::numeric_limits<float>::max (), bool grayscale = false,
327  const std::string &layer_id = "float_image", double opacity = 1.0);
328 
329  /** \brief Add a float 2D image layer, but do not render it (use spin/spinOnce to update).
330  * \param[in] data the input data representing the image in float format
331  * \param[in] width the width of the image
332  * \param[in] height the height of the image
333  * \param[in] min_value filter all values in the image to be larger than this minimum value
334  * \param[in] max_value filter all values in the image to be smaller than this maximum value
335  * \param[in] grayscale show data as grayscale (true) or not (false). Default: false
336  * \param[in] layer_id the name of the layer (default: "image")
337  * \param[in] opacity the opacity of the layer (default: 1.0)
338  */
339  void
340  addFloatImage (const float* data, unsigned int width, unsigned int height,
341  float min_value = std::numeric_limits<float>::min (),
342  float max_value = std::numeric_limits<float>::max (), bool grayscale = false,
343  const std::string &layer_id = "float_image", double opacity = 1.0);
344 
345  /** \brief Show a 2D image (unsigned short) on screen.
346  * \param[in] short_image the input data representing the image in unsigned short format
347  * \param[in] width the width of the image
348  * \param[in] height the height of the image
349  * \param[in] min_value filter all values in the image to be larger than this minimum value
350  * \param[in] max_value filter all values in the image to be smaller than this maximum value
351  * \param[in] grayscale show data as grayscale (true) or not (false). Default: false
352  * \param[in] layer_id the name of the layer (default: "image")
353  * \param[in] opacity the opacity of the layer (default: 1.0)
354  */
355  void
356  showShortImage (const unsigned short* short_image, unsigned int width, unsigned int height,
357  unsigned short min_value = std::numeric_limits<unsigned short>::min (),
358  unsigned short max_value = std::numeric_limits<unsigned short>::max (), bool grayscale = false,
359  const std::string &layer_id = "short_image", double opacity = 1.0);
360 
361  /** \brief Add a short 2D image layer, but do not render it (use spin/spinOnce to update).
362  * \param[in] short_image the input data representing the image in unsigned short format
363  * \param[in] width the width of the image
364  * \param[in] height the height of the image
365  * \param[in] min_value filter all values in the image to be larger than this minimum value
366  * \param[in] max_value filter all values in the image to be smaller than this maximum value
367  * \param[in] grayscale show data as grayscale (true) or not (false). Default: false
368  * \param[in] layer_id the name of the layer (default: "image")
369  * \param[in] opacity the opacity of the layer (default: 1.0)
370  */
371  void
372  addShortImage (const unsigned short* short_image, unsigned int width, unsigned int height,
373  unsigned short min_value = std::numeric_limits<unsigned short>::min (),
374  unsigned short max_value = std::numeric_limits<unsigned short>::max (), bool grayscale = false,
375  const std::string &layer_id = "short_image", double opacity = 1.0);
376 
377  /** \brief Show a 2D image on screen representing angle data.
378  * \param[in] data the input data representing the image
379  * \param[in] width the width of the image
380  * \param[in] height the height of the image
381  * \param[in] layer_id the name of the layer (default: "image")
382  * \param[in] opacity the opacity of the layer (default: 1.0)
383  */
384  void
385  showAngleImage (const float* data, unsigned width, unsigned height,
386  const std::string &layer_id = "angle_image", double opacity = 1.0);
387 
388  /** \brief Add an angle 2D image layer, but do not render it (use spin/spinOnce to update).
389  * \param[in] data the input data representing the image
390  * \param[in] width the width of the image
391  * \param[in] height the height of the image
392  * \param[in] layer_id the name of the layer (default: "image")
393  * \param[in] opacity the opacity of the layer (default: 1.0)
394  */
395  void
396  addAngleImage (const float* data, unsigned width, unsigned height,
397  const std::string &layer_id = "angle_image", double opacity = 1.0);
398 
399  /** \brief Show a 2D image on screen representing half angle data.
400  * \param[in] data the input data representing the image
401  * \param[in] width the width of the image
402  * \param[in] height the height of the image
403  * \param[in] layer_id the name of the layer (default: "image")
404  * \param[in] opacity the opacity of the layer (default: 1.0)
405  */
406  void
407  showHalfAngleImage (const float* data, unsigned width, unsigned height,
408  const std::string &layer_id = "half_angle_image", double opacity = 1.0);
409 
410  /** \brief Add a half angle 2D image layer, but do not render it (use spin/spinOnce to update).
411  * \param[in] data the input data representing the image
412  * \param[in] width the width of the image
413  * \param[in] height the height of the image
414  * \param[in] layer_id the name of the layer (default: "image")
415  * \param[in] opacity the opacity of the layer (default: 1.0)
416  */
417  void
418  addHalfAngleImage (const float* data, unsigned width, unsigned height,
419  const std::string &layer_id = "half_angle_image", double opacity = 1.0);
420 
421  /** \brief Sets the pixel at coordinates(u,v) to color while setting the neighborhood to another
422  * \param[in] u the u/x coordinate of the pixel
423  * \param[in] v the v/y coordinate of the pixel
424  * \param[in] fg_color the pixel color
425  * \param[in] bg_color the neighborhood color
426  * \param[in] radius the circle radius around the pixel
427  * \param[in] layer_id the name of the layer (default: "points")
428  * \param[in] opacity the opacity of the layer (default: 1.0)
429  */
430  void
431  markPoint (std::size_t u, std::size_t v, Vector3ub fg_color, Vector3ub bg_color = red_color, double radius = 3.0,
432  const std::string &layer_id = "points", double opacity = 1.0);
433 
434  /** \brief Sets the pixel at coordinates(u,v) to color while setting the neighborhood to another
435  * \param[in] uv the u/x, v/y coordinate of the pixels to be marked
436  * \param[in] fg_color the pixel color
437  * \param[in] bg_color the neighborhood color
438  * \param[in] size edge of the square surrounding each pixel
439  * \param[in] layer_id the name of the layer (default: "markers")
440  * \param[in] opacity the opacity of the layer (default: 1.0)
441  */
442  void
443  markPoints (const std::vector<int>& uv, Vector3ub fg_color, Vector3ub bg_color = red_color, double size = 3.0,
444  const std::string &layer_id = "markers", double opacity = 1.0);
445 
446  /** \brief Sets the pixel at coordinates(u,v) to color while setting the neighborhood to another (float coordinates version).
447  * \param[in] uv the u/x, v/y coordinate of the pixels to be marked
448  * \param[in] fg_color the pixel color
449  * \param[in] bg_color the neighborhood color
450  * \param[in] size edge of the square surrounding each pixel
451  * \param[in] layer_id the name of the layer (default: "markers")
452  * \param[in] opacity the opacity of the layer (default: 1.0)
453  */
454  void
455  markPoints (const std::vector<float>& uv, Vector3ub fg_color, Vector3ub bg_color = red_color, double size = 3.0,
456  const std::string &layer_id = "markers", double opacity = 1.0);
457 
458  /** \brief Set the window title name
459  * \param[in] name the window title
460  */
461  void
462  setWindowTitle (const std::string& name);
463 
464  /** \brief Spin method. Calls the interactor and runs an internal loop. */
465  void
466  spin ();
467 
468  /** \brief Spin once method. Calls the interactor and updates the screen once.
469  * \param[in] time - How long (in ms) should the visualization loop be allowed to run.
470  * \param[in] force_redraw - if false it might return without doing anything if the
471  * interactor's framerate does not require a redraw yet.
472  */
473  void
474  spinOnce (int time = 1, bool force_redraw = true);
475 
476  /** \brief Register a callback function for keyboard events
477  * \param[in] callback the function that will be registered as a callback for a keyboard event
478  * \param[in] cookie user data that is passed to the callback
479  * \return a connection object that allows to disconnect the callback function.
480  */
481  boost::signals2::connection
483  void* cookie = nullptr)
484  {
485  return (registerKeyboardCallback ([=] (const pcl::visualization::KeyboardEvent& e) { (*callback) (e, cookie); }));
486  }
487 
488  /** \brief Register a callback function for keyboard events
489  * \param[in] callback the member function that will be registered as a callback for a keyboard event
490  * \param[in] instance instance to the class that implements the callback function
491  * \param[in] cookie user data that is passed to the callback
492  * \return a connection object that allows to disconnect the callback function.
493  */
494  template<typename T> boost::signals2::connection
495  registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*),
496  T& instance, void* cookie = nullptr)
497  {
498  return (registerKeyboardCallback ([=, &instance] (const pcl::visualization::KeyboardEvent& e) { (instance.*callback) (e, cookie); }));
499  }
500 
501  /** \brief Register a callback std::function for keyboard events
502  * \param[in] cb the boost function that will be registered as a callback for a keyboard event
503  * \return a connection object that allows to disconnect the callback function.
504  */
505  boost::signals2::connection
506  registerKeyboardCallback (std::function<void (const pcl::visualization::KeyboardEvent&)> cb);
507 
508  /** \brief Register a callback std::function for mouse events
509  * \param[in] callback the function that will be registered as a callback for a mouse event
510  * \param[in] cookie user data that is passed to the callback
511  * \return a connection object that allows to disconnect the callback function.
512  */
513  boost::signals2::connection
514  registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*),
515  void* cookie = nullptr)
516  {
517  return (registerMouseCallback ([=] (const pcl::visualization::MouseEvent& e) { (*callback) (e, cookie); }));
518  }
519 
520  /** \brief Register a callback function for mouse events
521  * \param[in] callback the member function that will be registered as a callback for a mouse event
522  * \param[in] instance instance to the class that implements the callback function
523  * \param[in] cookie user data that is passed to the callback
524  * \return a connection object that allows to disconnect the callback function.
525  */
526  template<typename T> boost::signals2::connection
527  registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*),
528  T& instance, void* cookie = nullptr)
529  {
530  return (registerMouseCallback ([=, &instance] (const pcl::visualization::MouseEvent& e) { (instance.*callback) (e, cookie); }));
531  }
532 
533  /** \brief Register a callback function for mouse events
534  * \param[in] cb the boost function that will be registered as a callback for a mouse event
535  * \return a connection object that allows to disconnect the callback function.
536  */
537  boost::signals2::connection
538  registerMouseCallback (std::function<void (const pcl::visualization::MouseEvent&)> cb);
539 
540  /** \brief Set the position in screen coordinates.
541  * \param[in] x where to move the window to (X)
542  * \param[in] y where to move the window to (Y)
543  */
544  void
545  setPosition (int x, int y);
546 
547  /** \brief Set the window size in screen coordinates.
548  * \param[in] xw window size in horizontal (pixels)
549  * \param[in] yw window size in vertical (pixels)
550  */
551  void
552  setSize (int xw, int yw);
553 
554  /** \brief Return the window size in pixels. */
555  int*
556  getSize ();
557 
558  /** \brief Returns true when the user tried to close the window */
559  bool
560  wasStopped () const { return (stopped_); }
561 
562  /** \brief Stop the interaction and close the visualizaton window. */
563  void
564  close ()
565  {
566  stopped_ = true;
567  // This tends to close the window...
568  interactor_->TerminateApp ();
569  }
570 
571  /** \brief Add a circle shape from a point and a radius
572  * \param[in] x the x coordinate of the circle center
573  * \param[in] y the y coordinate of the circle center
574  * \param[in] radius the radius of the circle
575  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
576  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
577  */
578  bool
579  addCircle (unsigned int x, unsigned int y, double radius,
580  const std::string &layer_id = "circles", double opacity = 1.0);
581 
582  /** \brief Add a circle shape from a point and a radius
583  * \param[in] x the x coordinate of the circle center
584  * \param[in] y the y coordinate of the circle center
585  * \param[in] radius the radius of the circle
586  * \param[in] r the red channel of the color that the sphere should be rendered with (0.0 -> 1.0)
587  * \param[in] g the green channel of the color that the sphere should be rendered with (0.0 -> 1.0)
588  * \param[in] b the blue channel of the color that the sphere should be rendered with (0.0 -> 1.0)
589  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
590  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
591  */
592  bool
593  addCircle (unsigned int x, unsigned int y, double radius,
594  double r, double g, double b,
595  const std::string &layer_id = "circles", double opacity = 1.0);
596 
597  /** \brief Add a 2D box and color its edges with a given color
598  * \param[in] min_pt the X,Y min coordinate
599  * \param[in] max_pt the X,Y max coordinate
600  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
601  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
602  */
603  bool
604  addRectangle (const pcl::PointXY &min_pt, const pcl::PointXY &max_pt,
605  const std::string &layer_id = "rectangles", double opacity = 1.0);
606 
607  /** \brief Add a 2D box and color its edges with a given color
608  * \param[in] min_pt the X,Y min coordinate
609  * \param[in] max_pt the X,Y max coordinate
610  * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0)
611  * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0)
612  * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0)
613  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
614  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
615  */
616  bool
617  addRectangle (const pcl::PointXY &min_pt, const pcl::PointXY &max_pt,
618  double r, double g, double b,
619  const std::string &layer_id = "rectangles", double opacity = 1.0);
620 
621  /** \brief Add a 2D box and color its edges with a given color
622  * \param[in] x_min the X min coordinate
623  * \param[in] x_max the X max coordinate
624  * \param[in] y_min the Y min coordinate
625  * \param[in] y_max the Y max coordinate
626  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
627  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
628  */
629  bool
630  addRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max,
631  const std::string &layer_id = "rectangles", double opacity = 1.0);
632 
633  /** \brief Add a 2D box and color its edges with a given color
634  * \param[in] x_min the X min coordinate
635  * \param[in] x_max the X max coordinate
636  * \param[in] y_min the Y min coordinate
637  * \param[in] y_max the Y max coordinate
638  * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0)
639  * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0)
640  * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0)
641  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
642  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
643  */
644  bool
645  addRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max,
646  double r, double g, double b,
647  const std::string &layer_id = "rectangles", double opacity = 1.0);
648 
649  /** \brief Add a 2D box and color its edges with a given color
650  * \param[in] image the organized point cloud dataset containing the image data
651  * \param[in] min_pt the X,Y min coordinate
652  * \param[in] max_pt the X,Y max coordinate
653  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
654  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
655  */
656  template <typename T> bool
657  addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image,
658  const T &min_pt, const T &max_pt,
659  const std::string &layer_id = "rectangles", double opacity = 1.0);
660 
661  /** \brief Add a 2D box and color its edges with a given color
662  * \param[in] image the organized point cloud dataset containing the image data
663  * \param[in] min_pt the X,Y min coordinate
664  * \param[in] max_pt the X,Y max coordinate
665  * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0)
666  * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0)
667  * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0)
668  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
669  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
670  */
671  template <typename T> bool
672  addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image,
673  const T &min_pt, const T &max_pt,
674  double r, double g, double b,
675  const std::string &layer_id = "rectangles", double opacity = 1.0);
676 
677  /** \brief Add a 2D box that contains a given image mask and color its edges
678  * \param[in] image the organized point cloud dataset containing the image data
679  * \param[in] mask the point data representing the mask that we want to draw
680  * \param[in] r the red channel of the color that the mask should be rendered with
681  * \param[in] g the green channel of the color that the mask should be rendered with
682  * \param[in] b the blue channel of the color that the mask should be rendered with
683  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
684  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
685  */
686  template <typename T> bool
687  addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask,
688  double r, double g, double b,
689  const std::string &layer_id = "rectangles", double opacity = 1.0);
690 
691  /** \brief Add a 2D box that contains a given image mask and color its edges in red
692  * \param[in] image the organized point cloud dataset containing the image data
693  * \param[in] mask the point data representing the mask that we want to draw
694  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
695  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
696  */
697  template <typename T> bool
698  addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask,
699  const std::string &layer_id = "image_mask", double opacity = 1.0);
700 
701  /** \brief Add a 2D box and fill it in with a given color
702  * \param[in] x_min the X min coordinate
703  * \param[in] x_max the X max coordinate
704  * \param[in] y_min the Y min coordinate
705  * \param[in] y_max the Y max coordinate
706  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
707  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
708  */
709  bool
710  addFilledRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max,
711  const std::string &layer_id = "boxes", double opacity = 0.5);
712 
713  /** \brief Add a 2D box and fill it in with a given color
714  * \param[in] x_min the X min coordinate
715  * \param[in] x_max the X max coordinate
716  * \param[in] y_min the Y min coordinate
717  * \param[in] y_max the Y max coordinate
718  * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0)
719  * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0)
720  * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0)
721  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
722  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
723  */
724  bool
725  addFilledRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max,
726  double r, double g, double b,
727  const std::string &layer_id = "boxes", double opacity = 0.5);
728 
729  /** \brief Add a 2D line with a given color
730  * \param[in] x_min the X min coordinate
731  * \param[in] y_min the Y min coordinate
732  * \param[in] x_max the X max coordinate
733  * \param[in] y_max the Y max coordinate
734  * \param[in] r the red channel of the color that the line should be rendered with (0.0 -> 1.0)
735  * \param[in] g the green channel of the color that the line should be rendered with (0.0 -> 1.0)
736  * \param[in] b the blue channel of the color that the line should be rendered with (0.0 -> 1.0)
737  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
738  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
739  */
740  bool
741  addLine (unsigned int x_min, unsigned int y_min, unsigned int x_max, unsigned int y_max,
742  double r, double g, double b,
743  const std::string &layer_id = "line", double opacity = 1.0);
744 
745  /** \brief Add a 2D line with a given color
746  * \param[in] x_min the X min coordinate
747  * \param[in] y_min the Y min coordinate
748  * \param[in] x_max the X max coordinate
749  * \param[in] y_max the Y max coordinate
750  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
751  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
752  */
753  bool
754  addLine (unsigned int x_min, unsigned int y_min, unsigned int x_max, unsigned int y_max,
755  const std::string &layer_id = "line", double opacity = 1.0);
756 
757  /** \brief Add a 2D text with a given color
758  * \param[in] x the X coordinate
759  * \param[in] y the Y coordinate
760  * \param[in] text the text string to be displayed
761  * \param[in] r the red channel of the color that the line should be rendered with (0.0 -> 1.0)
762  * \param[in] g the green channel of the color that the line should be rendered with (0.0 -> 1.0)
763  * \param[in] b the blue channel of the color that the line should be rendered with (0.0 -> 1.0)
764  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
765  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
766  */
767  bool
768  addText (unsigned int x, unsigned int y, const std::string& text,
769  double r, double g, double b,
770  const std::string &layer_id = "line", double opacity = 1.0);
771 
772  /** \brief Add a 2D text with a given color
773  * \param[in] x the X coordinate
774  * \param[in] y the Y coordinate
775  * \param[in] text the text string to be displayed
776  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
777  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
778  */
779  bool
780  addText (unsigned int x, unsigned int y, const std::string& text,
781  const std::string &layer_id = "line", double opacity = 1.0);
782 
783  /** \brief Add a generic 2D mask to an image
784  * \param[in] image the organized point cloud dataset containing the image data
785  * \param[in] mask the point data representing the mask that we want to draw
786  * \param[in] r the red channel of the color that the mask should be rendered with
787  * \param[in] g the green channel of the color that the mask should be rendered with
788  * \param[in] b the blue channel of the color that the mask should be rendered with
789  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
790  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
791  */
792  template <typename T> bool
793  addMask (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask,
794  double r, double g, double b,
795  const std::string &layer_id = "image_mask", double opacity = 0.5);
796 
797  /** \brief Add a generic 2D mask to an image (colored in red)
798  * \param[in] image the organized point cloud dataset containing the image data
799  * \param[in] mask the point data representing the mask that we want to draw
800  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
801  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
802  */
803  template <typename T> bool
804  addMask (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask,
805  const std::string &layer_id = "image_mask", double opacity = 0.5);
806 
807  /** \brief Add a generic 2D planar polygon to an image
808  * \param[in] image the organized point cloud dataset containing the image data
809  * \param[in] polygon the point data representing the polygon that we want to draw.
810  * A line will be drawn from each point to the next in the dataset.
811  * \param[in] r the red channel of the color that the polygon should be rendered with
812  * \param[in] g the green channel of the color that the polygon should be rendered with
813  * \param[in] b the blue channel of the color that the polygon should be rendered with
814  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
815  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
816  */
817  template <typename T> bool
818  addPlanarPolygon (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PlanarPolygon<T> &polygon,
819  double r, double g, double b,
820  const std::string &layer_id = "planar_polygon", double opacity = 1.0);
821 
822  /** \brief Add a generic 2D planar polygon to an image
823  * \param[in] image the organized point cloud dataset containing the image data
824  * \param[in] polygon the point data representing the polygon that we want to draw.
825  * A line will be drawn from each point to the next in the dataset.
826  * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn.
827  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0)
828  */
829  template <typename T> bool
830  addPlanarPolygon (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PlanarPolygon<T> &polygon,
831  const std::string &layer_id = "planar_polygon", double opacity = 1.0);
832 
833  /** \brief Add a new 2D rendering layer to the viewer.
834  * \param[in] layer_id the name of the layer
835  * \param[in] width the width of the layer
836  * \param[in] height the height of the layer
837  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
838  */
839  bool
840  addLayer (const std::string &layer_id, int width, int height, double opacity = 0.5);
841 
842  /** \brief Remove a 2D layer given by its ID.
843  * \param[in] layer_id the name of the layer
844  */
845  void
846  removeLayer (const std::string &layer_id);
847 
848  /** \brief Add the specified correspondences to the display.
849  * \param[in] source_img The source RGB image
850  * \param[in] target_img The target RGB image
851  * \param[in] correspondences The list of correspondences to display.
852  * \param[in] nth display only the Nth correspondence (e.g., skip the rest)
853  * \param[in] layer_id the layer id (default: "correspondences")
854  */
855  template <typename PointT> bool
856  showCorrespondences (const pcl::PointCloud<PointT> &source_img,
857  const pcl::PointCloud<PointT> &target_img,
858  const pcl::Correspondences &correspondences,
859  int nth = 1,
860  const std::string &layer_id = "correspondences");
861 
862  protected:
863  /** \brief Trigger a render call. */
864  void
865  render ();
866 
867  /** \brief Convert the Intensity information in a PointCloud<Intensity> to an unsigned char array
868  * \param[in] cloud the input cloud containing the grayscale intensity information
869  * \param[out] data a boost shared array of unsigned char type
870  * \note The method assumes that the data array has already been allocated and
871  * contains enough space to copy all the data from cloud!
872  */
873  void
874  convertIntensityCloudToUChar (const pcl::PointCloud<pcl::Intensity> &cloud,
875  boost::shared_array<unsigned char> data);
876 
877  /** \brief Convert the Intensity8u information in a PointCloud<Intensity8u> to an unsigned char array
878  * \param[in] cloud the input cloud containing the grayscale intensity information
879  * \param[out] data a boost shared array of unsigned char type
880  * \note The method assumes that the data array has already been allocated and
881  * contains enough space to copy all the data from cloud!
882  */
883  void
884  convertIntensityCloud8uToUChar (const pcl::PointCloud<pcl::Intensity8u> &cloud,
885  boost::shared_array<unsigned char> data);
886 
887  /** \brief Convert the RGB information in a PointCloud<T> to an unsigned char array
888  * \param[in] cloud the input cloud containing the RGB information
889  * \param[out] data a boost shared array of unsigned char type
890  * \note The method assumes that the data array has already been allocated and
891  * contains enough space to copy all the data from cloud!
892  */
893  template <typename T> void
894  convertRGBCloudToUChar (const pcl::PointCloud<T> &cloud,
895  boost::shared_array<unsigned char> &data);
896 
897  /** \brief Set the stopped flag back to false */
898  void
899  resetStoppedFlag () { stopped_ = false; }
900 
901  /** \brief Fire up a mouse event with a specified event ID
902  * \param[in] event_id the id of the event
903  */
904  void
905  emitMouseEvent (unsigned long event_id);
906 
907  /** \brief Fire up a keyboard event with a specified event ID
908  * \param[in] event_id the id of the event
909  */
910  void
911  emitKeyboardEvent (unsigned long event_id);
912 
913  // Callbacks used to register for vtk command
914  static void
915  MouseCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata);
916  static void
917  KeyboardCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata);
918 
919  protected: // types
920  struct ExitMainLoopTimerCallback : public vtkCommand
921  {
922  ExitMainLoopTimerCallback () : right_timer_id (), window () {}
923 
925  {
926  return (new ExitMainLoopTimerCallback);
927  }
928  void
929  Execute (vtkObject* vtkNotUsed (caller), unsigned long event_id, void* call_data) override
930  {
931  if (event_id != vtkCommand::TimerEvent)
932  return;
933  int timer_id = *static_cast<int*> (call_data);
934  if (timer_id != right_timer_id)
935  return;
936  window->interactor_->TerminateApp ();
937  }
940  };
941  struct ExitCallback : public vtkCommand
942  {
943  ExitCallback () : window () {}
944 
945  static ExitCallback* New ()
946  {
947  return (new ExitCallback);
948  }
949  void
950  Execute (vtkObject*, unsigned long event_id, void*) override
951  {
952  if (event_id != vtkCommand::ExitEvent)
953  return;
954  window->stopped_ = true;
955  window->interactor_->TerminateApp ();
956  }
958  };
959 
960  private:
961  /** \brief Internal structure describing a layer. */
962  struct Layer
963  {
964  Layer () {}
966  std::string layer_name;
967  };
968 
969  using LayerMap = std::vector<Layer>;
970 
971  /** \brief Add a new 2D rendering layer to the viewer.
972  * \param[in] layer_id the name of the layer
973  * \param[in] width the width of the layer
974  * \param[in] height the height of the layer
975  * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5)
976  * \param[in] fill_box set to true to fill in the image with one black box before starting
977  */
978  LayerMap::iterator
979  createLayer (const std::string &layer_id, int width, int height, double opacity = 0.5, bool fill_box = true);
980 
981  boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_;
982  boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_;
983 
986  vtkSmartPointer<vtkCallbackCommand> keyboard_command_;
987 
988  /** \brief Callback object enabling us to leave the main loop, when a timer fires. */
989  vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_;
990  vtkSmartPointer<ExitCallback> exit_callback_;
991 
992  /** \brief The ImageViewer widget. */
993  vtkSmartPointer<vtkImageViewer> image_viewer_;
994 
995  /** \brief The render window. */
997 
998  /** \brief The renderer. */
1000 
1001  /** \brief Global prop. This is the actual "actor". */
1003 
1004  /** \brief The interactor style. */
1006 
1007  /** \brief The data array representing the image. Used internally. */
1008  boost::shared_array<unsigned char> data_;
1009 
1010  /** \brief The data array (representing the image) size. Used internally. */
1011  std::size_t data_size_;
1012 
1013  /** \brief Set to false if the interaction loop is running. */
1014  bool stopped_;
1015 
1016  /** \brief Global timer ID. Used in destructor only. */
1017  int timer_id_;
1018 
1019  // /** \brief Internal blender used to overlay 2D geometry over the image. */
1020  // vtkSmartPointer<vtkImageBlend> blend_;
1021 
1022  /** \brief Internal list with different 2D layers shapes. */
1023  LayerMap layer_map_;
1024 
1025  /** \brief Image reslice, used for flipping the image. */
1027 
1028  /** \brief Internal data array. Used everytime add***Image is called.
1029  * Cleared, everytime the render loop is executed.
1030  */
1031  std::vector<unsigned char*> image_data_;
1032 
1033  struct LayerComparator
1034  {
1035  LayerComparator (const std::string &str) : str_ (str) {}
1036  const std::string &str_;
1037 
1038  bool
1039  operator () (const Layer &layer)
1040  {
1041  return (layer.layer_name == str_);
1042  }
1043  };
1044 
1045  public:
1047  };
1048  }
1049 }
1050 
1051 #include <pcl/visualization/impl/image_viewer.hpp>
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback::Execute
void Execute(vtkObject *vtkNotUsed(caller), unsigned long event_id, void *call_data) override
Definition: image_viewer.h:929
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
point_types.h
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback::ExitMainLoopTimerCallback
ExitMainLoopTimerCallback()
Definition: image_viewer.h:922
pcl::visualization::ImageViewer::ExitCallback::New
static ExitCallback * New()
Definition: image_viewer.h:945
pcl::visualization::ImageViewerInteractorStyle::OnMouseWheelForward
void OnMouseWheelForward() override
Definition: image_viewer.h:80
pcl::visualization::ImageViewer::setInteractorStyle
void setInteractorStyle(vtkInteractorObserver *style)
Set up the interactor style.
Definition: image_viewer.h:136
pcl::visualization::ImageViewer::showRGBImage
void showRGBImage(const typename pcl::PointCloud< T >::ConstPtr &cloud, const std::string &layer_id="rgb_image", double opacity=1.0)
Show a 2D image on screen, obtained from the RGB channel of a point cloud.
Definition: image_viewer.h:277
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback
Definition: image_viewer.h:920
pcl::visualization::ImageViewer::close
void close()
Stop the interaction and close the visualizaton window.
Definition: image_viewer.h:564
pcl::visualization::ImageViewerInteractorStyle::OnRightButtonDown
void OnRightButtonDown() override
Definition: image_viewer.h:83
pcl::visualization::ImageViewerInteractorStyle::OnMouseWheelBackward
void OnMouseWheelBackward() override
Definition: image_viewer.h:81
pcl::visualization::Vector3ub
Eigen::Array< unsigned char, 3, 1 > Vector3ub
Definition: image_viewer.h:65
pcl::visualization::ImageViewer::ConstPtr
shared_ptr< const ImageViewer > ConstPtr
Definition: image_viewer.h:121
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:52
pcl::visualization::blue_color
static const Vector3ub blue_color(0, 0, 255)
pcl::visualization::ImageViewerInteractorStyle
An image viewer interactor style, tailored for ImageViewer.
Definition: image_viewer.h:74
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback::window
ImageViewer * window
Definition: image_viewer.h:939
pcl::visualization::ImageViewer::Ptr
shared_ptr< ImageViewer > Ptr
Definition: image_viewer.h:120
pcl::visualization::ImageViewer::ExitCallback::ExitCallback
ExitCallback()
Definition: image_viewer.h:943
pcl::visualization::ImageViewer
ImageViewer is a class for 2D image visualization.
Definition: image_viewer.h:117
pcl::visualization::ImageViewer::wasStopped
bool wasStopped() const
Returns true when the user tried to close the window.
Definition: image_viewer.h:560
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: pcl_macros.h:371
pcl::visualization::ImageViewer::registerMouseCallback
boost::signals2::connection registerMouseCallback(void(*callback)(const pcl::visualization::MouseEvent &, void *), void *cookie=nullptr)
Register a callback std::function for mouse events.
Definition: image_viewer.h:514
pcl::visualization::ImageViewer::ExitCallback::window
ImageViewer * window
Definition: image_viewer.h:957
pcl::visualization::red_color
static const Vector3ub red_color(255, 0, 0)
pcl::PointXY
A 2D point structure representing Euclidean xy coordinates.
Definition: point_types.hpp:736
pcl::visualization::ImageViewer::resetStoppedFlag
void resetStoppedFlag()
Set the stopped flag back to false.
Definition: image_viewer.h:899
pcl::visualization::ImageViewer::ExitCallback::Execute
void Execute(vtkObject *, unsigned long event_id, void *) override
Definition: image_viewer.h:950
pcl::visualization::ImageViewer::showMonoImage
void showMonoImage(const pcl::PointCloud< pcl::Intensity >::ConstPtr &cloud, const std::string &layer_id="mono_image", double opacity=1.0)
Show a monochrome 2D image on screen.
Definition: image_viewer.h:169
pcl::visualization::ImageViewer::addRGBImage
void addRGBImage(const typename pcl::PointCloud< T >::ConstPtr &cloud, const std::string &layer_id="rgb_image", double opacity=1.0)
Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update).
Definition: image_viewer.h:289
pcl::visualization::ImageViewerInteractorStyle::OnMiddleButtonDown
void OnMiddleButtonDown() override
Definition: image_viewer.h:82
pcl::visualization::ImageViewer::addMonoImage
void addMonoImage(const pcl::PointCloud< pcl::Intensity8u >::ConstPtr &cloud, const std::string &layer_id="mono_image", double opacity=1.0)
Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
Definition: image_viewer.h:223
pcl::visualization::MouseEvent
Definition: mouse_event.h:47
pcl::visualization::ImageViewer::addMonoImage
void addMonoImage(const pcl::PointCloud< pcl::Intensity >::ConstPtr &cloud, const std::string &layer_id="mono_image", double opacity=1.0)
Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update).
Definition: image_viewer.h:181
pcl::visualization::green_color
static const Vector3ub green_color(0, 255, 0)
pcl::visualization::ImageViewer::ExitCallback
Definition: image_viewer.h:941
pcl::visualization::ImageViewer::showMonoImage
void showMonoImage(const pcl::PointCloud< pcl::Intensity8u >::ConstPtr &cloud, const std::string &layer_id="mono_image", double opacity=1.0)
Show a monochrome 2D image on screen.
Definition: image_viewer.h:211
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:416
pcl::PlanarPolygon
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
Definition: planar_polygon.h:53
pcl::Correspondences
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Definition: correspondence.h:88
pcl::visualization::ImageViewer::registerKeyboardCallback
boost::signals2::connection registerKeyboardCallback(void(T::*callback)(const pcl::visualization::KeyboardEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for keyboard events.
Definition: image_viewer.h:495
pcl::visualization::ImageViewer::registerKeyboardCallback
boost::signals2::connection registerKeyboardCallback(void(*callback)(const pcl::visualization::KeyboardEvent &, void *), void *cookie=nullptr)
Register a callback function for keyboard events.
Definition: image_viewer.h:482
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback::New
static ExitMainLoopTimerCallback * New()
Definition: image_viewer.h:924
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:253
vtkSmartPointer< vtkContextActor >
pcl::visualization::KeyboardEvent
/brief Class representing key hit/release events
Definition: keyboard_event.h:48
pcl::shared_ptr
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
pcl::visualization::ImageViewer::ExitMainLoopTimerCallback::right_timer_id
int right_timer_id
Definition: image_viewer.h:938
pcl::visualization::ImageViewer::registerMouseCallback
boost::signals2::connection registerMouseCallback(void(T::*callback)(const pcl::visualization::MouseEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for mouse events.
Definition: image_viewer.h:527