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