00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2012, Willow Garage, Inc. 00006 * Copyright (c) 2012-, Open Perception, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * * Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * * Redistributions in binary form must reproduce the above 00017 * copyright notice, this list of conditions and the following 00018 * disclaimer in the documentation and/or other materials provided 00019 * with the distribution. 00020 * * Neither the name of the copyright holder(s) nor the names of its 00021 * contributors may be used to endorse or promote products derived 00022 * from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00027 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00028 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00030 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00034 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 */ 00038 00039 #ifndef PCL_VISUALIZATION_IMAGE_VISUALIZER_H__ 00040 #define PCL_VISUALIZATION_IMAGE_VISUALIZER_H__ 00041 00042 #include <pcl/pcl_macros.h> 00043 #include <pcl/point_types.h> 00044 #include <pcl/console/print.h> 00045 #include <pcl/visualization/interactor.h> 00046 #include <pcl/visualization/interactor_style.h> 00047 #include <pcl/visualization/vtk/pcl_image_canvas_source_2d.h> 00048 #include <pcl/visualization/vtk/pcl_context_item.h> 00049 #include <pcl/geometry/planar_polygon.h> 00050 #include <pcl/correspondence.h> 00051 00052 #include <boost/shared_array.hpp> 00053 00054 #include <vtkInteractorStyleImage.h> 00055 00056 class vtkImageSlice; 00057 class vtkContextActor; 00058 class vtkImageViewer; 00059 class vtkImageFlip; 00060 00061 namespace pcl 00062 { 00063 namespace visualization 00064 { 00065 typedef Eigen::Array<unsigned char, 3, 1> Vector3ub; 00066 static const Vector3ub green_color (0, 255, 0); 00067 static const Vector3ub red_color (255, 0, 0); 00068 static const Vector3ub blue_color (0, 0, 255); 00069 00070 /** \brief An image viewer interactor style, tailored for ImageViewer. 00071 * \author Radu B. Rusu 00072 * \ingroup visualization 00073 */ 00074 class PCL_EXPORTS ImageViewerInteractorStyle : public vtkInteractorStyleImage 00075 { 00076 public: 00077 static ImageViewerInteractorStyle *New (); 00078 ImageViewerInteractorStyle (); 00079 00080 virtual void OnMouseWheelForward () {} 00081 virtual void OnMouseWheelBackward () {} 00082 virtual void OnMiddleButtonDown () {} 00083 virtual void OnRightButtonDown () {} 00084 virtual void OnLeftButtonDown (); 00085 00086 virtual void 00087 OnChar (); 00088 00089 void 00090 adjustCamera (vtkImageData *image, vtkRenderer *ren); 00091 00092 void 00093 adjustCamera (vtkRenderer *ren); 00094 }; 00095 00096 /** \brief ImageViewer is a class for 2D image visualization. 00097 * 00098 * Features include: 00099 * - add and remove different layers with different opacity (transparency) values 00100 * - add 2D geometric shapes (circles, boxes, etc) in separate layers 00101 * - display RGB, monochrome, float, angle images 00102 * 00103 * Simple usage example: 00104 * \code 00105 * pcl::visualization::ImageViewer iv; 00106 * 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" 00107 * 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" 00108 * iv.addRGBImage<pcl::PointXYZRGBA> (cloud); // add a RGB image from a point cloud dataset in an "rgb_image" default layer 00109 * iv.spin (); // press 'q' to exit 00110 * iv.removeLayer ("circles"); // remove layer "circles" 00111 * iv.spin (); // press 'q' to exit 00112 * \endcode 00113 * 00114 * \author Radu B. Rusu, Suat Gedikli 00115 * \ingroup visualization 00116 */ 00117 class PCL_EXPORTS ImageViewer 00118 { 00119 public: 00120 typedef boost::shared_ptr<ImageViewer> Ptr; 00121 00122 /** \brief Constructor. 00123 * \param[in] window_title the title of the window 00124 */ 00125 ImageViewer (const std::string& window_title = ""); 00126 00127 /** \brief Destructor. */ 00128 virtual ~ImageViewer (); 00129 00130 #if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION > 4))) 00131 /** \brief Set up the interactor style. By default the interactor style is set to 00132 * vtkInteractorStyleImage you can use this to set it to another type. 00133 * \param[in] style user set interactor style. 00134 */ 00135 void 00136 setInteractorStyle (vtkInteractorObserver *style) 00137 { 00138 interactor_->SetInteractorStyle (style); 00139 } 00140 #endif 00141 /** \brief Show a monochrome 2D image on screen. 00142 * \param[in] data the input data representing the image 00143 * \param[in] width the width of the image 00144 * \param[in] height the height of the image 00145 * \param[in] layer_id the name of the layer (default: "image") 00146 * \param[in] opacity the opacity of the layer (default: 1.0) 00147 */ 00148 void 00149 showMonoImage (const unsigned char* data, unsigned width, unsigned height, 00150 const std::string &layer_id = "mono_image", double opacity = 1.0); 00151 00152 /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update). 00153 * \param[in] data the input data representing the image 00154 * \param[in] width the width of the image 00155 * \param[in] height the height of the image 00156 * \param[in] layer_id the name of the layer (default: "image") 00157 * \param[in] opacity the opacity of the layer (default: 1.0) 00158 */ 00159 void 00160 addMonoImage (const unsigned char* data, unsigned width, unsigned height, 00161 const std::string &layer_id = "mono_image", double opacity = 1.0); 00162 00163 /** \brief Show a monochrome 2D image on screen. 00164 * \param[in] cloud the input data representing the grayscale point cloud 00165 * \param[in] layer_id the name of the layer (default: "image") 00166 * \param[in] opacity the opacity of the layer (default: 1.0) 00167 */ 00168 inline void 00169 showMonoImage (const pcl::PointCloud<pcl::Intensity>::ConstPtr &cloud, 00170 const std::string &layer_id = "mono_image", double opacity = 1.0) 00171 { 00172 return (showMonoImage (*cloud, layer_id, opacity)); 00173 } 00174 00175 /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update). 00176 * \param[in] cloud the input data representing the grayscale point cloud 00177 * \param[in] layer_id the name of the layer (default: "image") 00178 * \param[in] opacity the opacity of the layer (default: 1.0) 00179 */ 00180 inline void 00181 addMonoImage (const pcl::PointCloud<pcl::Intensity>::ConstPtr &cloud, 00182 const std::string &layer_id = "mono_image", double opacity = 1.0) 00183 { 00184 return (addMonoImage (*cloud, layer_id, opacity)); 00185 } 00186 00187 /** \brief Show a monochrome 2D image on screen. 00188 * \param[in] cloud the input data representing the grayscale point cloud 00189 * \param[in] layer_id the name of the layer (default: "image") 00190 * \param[in] opacity the opacity of the layer (default: 1.0) 00191 */ 00192 void 00193 showMonoImage (const pcl::PointCloud<pcl::Intensity> &cloud, 00194 const std::string &layer_id = "mono_image", double opacity = 1.0); 00195 00196 /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update). 00197 * \param[in] cloud the input data representing the RGB point cloud 00198 * \param[in] layer_id the name of the layer (default: "image") 00199 * \param[in] opacity the opacity of the layer (default: 1.0) 00200 */ 00201 void 00202 addMonoImage (const pcl::PointCloud<pcl::Intensity> &cloud, 00203 const std::string &layer_id = "mono_image", double opacity = 1.0); 00204 00205 /** \brief Show a monochrome 2D image on screen. 00206 * \param[in] cloud the input data representing the grayscale point cloud 00207 * \param[in] layer_id the name of the layer (default: "image") 00208 * \param[in] opacity the opacity of the layer (default: 1.0) 00209 */ 00210 inline void 00211 showMonoImage (const pcl::PointCloud<pcl::Intensity8u>::ConstPtr &cloud, 00212 const std::string &layer_id = "mono_image", double opacity = 1.0) 00213 { 00214 return (showMonoImage (*cloud, layer_id, opacity)); 00215 } 00216 00217 /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update). 00218 * \param[in] cloud the input data representing the grayscale point cloud 00219 * \param[in] layer_id the name of the layer (default: "image") 00220 * \param[in] opacity the opacity of the layer (default: 1.0) 00221 */ 00222 inline void 00223 addMonoImage (const pcl::PointCloud<pcl::Intensity8u>::ConstPtr &cloud, 00224 const std::string &layer_id = "mono_image", double opacity = 1.0) 00225 { 00226 return (addMonoImage (*cloud, layer_id, opacity)); 00227 } 00228 00229 /** \brief Show a monochrome 2D image on screen. 00230 * \param[in] cloud the input data representing the grayscale point cloud 00231 * \param[in] layer_id the name of the layer (default: "image") 00232 * \param[in] opacity the opacity of the layer (default: 1.0) 00233 */ 00234 void 00235 showMonoImage (const pcl::PointCloud<pcl::Intensity8u> &cloud, 00236 const std::string &layer_id = "mono_image", double opacity = 1.0); 00237 00238 /** \brief Add a monochrome 2D image layer, but do not render it (use spin/spinOnce to update). 00239 * \param[in] cloud the input data representing the RGB point cloud 00240 * \param[in] layer_id the name of the layer (default: "image") 00241 * \param[in] opacity the opacity of the layer (default: 1.0) 00242 */ 00243 void 00244 addMonoImage (const pcl::PointCloud<pcl::Intensity8u> &cloud, 00245 const std::string &layer_id = "mono_image", double opacity = 1.0); 00246 00247 /** \brief Show a 2D RGB image on screen. 00248 * \param[in] data the input data representing the image 00249 * \param[in] width the width of the image 00250 * \param[in] height the height of the image 00251 * \param[in] layer_id the name of the layer (default: "image") 00252 * \param[in] opacity the opacity of the layer (default: 1.0) 00253 */ 00254 void 00255 showRGBImage (const unsigned char* data, unsigned width, unsigned height, 00256 const std::string &layer_id = "rgb_image", double opacity = 1.0); 00257 00258 /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update). 00259 * \param[in] data the input data representing the image 00260 * \param[in] width the width of the image 00261 * \param[in] height the height of the image 00262 * \param[in] layer_id the name of the layer (default: "image") 00263 * \param[in] opacity the opacity of the layer (default: 1.0) 00264 */ 00265 void 00266 addRGBImage (const unsigned char* data, unsigned width, unsigned height, 00267 const std::string &layer_id = "rgb_image", double opacity = 1.0); 00268 00269 /** \brief Show a 2D image on screen, obtained from the RGB channel of a point cloud. 00270 * \param[in] cloud the input data representing the RGB point cloud 00271 * \param[in] layer_id the name of the layer (default: "image") 00272 * \param[in] opacity the opacity of the layer (default: 1.0) 00273 */ 00274 template <typename T> inline void 00275 showRGBImage (const typename pcl::PointCloud<T>::ConstPtr &cloud, 00276 const std::string &layer_id = "rgb_image", double opacity = 1.0) 00277 { 00278 return (showRGBImage<T> (*cloud, layer_id, opacity)); 00279 } 00280 00281 /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update). 00282 * \param[in] cloud the input data representing the RGB point cloud 00283 * \param[in] layer_id the name of the layer (default: "image") 00284 * \param[in] opacity the opacity of the layer (default: 1.0) 00285 */ 00286 template <typename T> inline void 00287 addRGBImage (const typename pcl::PointCloud<T>::ConstPtr &cloud, 00288 const std::string &layer_id = "rgb_image", double opacity = 1.0) 00289 { 00290 return (addRGBImage<T> (*cloud, layer_id, opacity)); 00291 } 00292 00293 /** \brief Show a 2D image on screen, obtained from the RGB channel of a point cloud. 00294 * \param[in] cloud the input data representing the RGB point cloud 00295 * \param[in] layer_id the name of the layer (default: "image") 00296 * \param[in] opacity the opacity of the layer (default: 1.0) 00297 */ 00298 template <typename T> void 00299 showRGBImage (const pcl::PointCloud<T> &cloud, 00300 const std::string &layer_id = "rgb_image", double opacity = 1.0); 00301 00302 /** \brief Add an RGB 2D image layer, but do not render it (use spin/spinOnce to update). 00303 * \param[in] cloud the input data representing the RGB point cloud 00304 * \param[in] layer_id the name of the layer (default: "image") 00305 * \param[in] opacity the opacity of the layer (default: 1.0) 00306 */ 00307 template <typename T> void 00308 addRGBImage (const pcl::PointCloud<T> &cloud, 00309 const std::string &layer_id = "rgb_image", double opacity = 1.0); 00310 00311 /** \brief Show a 2D image (float) on screen. 00312 * \param[in] data the input data representing the image in float format 00313 * \param[in] width the width of the image 00314 * \param[in] height the height of the image 00315 * \param[in] min_value filter all values in the image to be larger than this minimum value 00316 * \param[in] max_value filter all values in the image to be smaller than this maximum value 00317 * \param[in] grayscale show data as grayscale (true) or not (false). Default: false 00318 * \param[in] layer_id the name of the layer (default: "image") 00319 * \param[in] opacity the opacity of the layer (default: 1.0) 00320 */ 00321 void 00322 showFloatImage (const float* data, unsigned int width, unsigned int height, 00323 float min_value = std::numeric_limits<float>::min (), 00324 float max_value = std::numeric_limits<float>::max (), bool grayscale = false, 00325 const std::string &layer_id = "float_image", double opacity = 1.0); 00326 00327 /** \brief Add a float 2D image layer, but do not render it (use spin/spinOnce to update). 00328 * \param[in] data the input data representing the image in float format 00329 * \param[in] width the width of the image 00330 * \param[in] height the height of the image 00331 * \param[in] min_value filter all values in the image to be larger than this minimum value 00332 * \param[in] max_value filter all values in the image to be smaller than this maximum value 00333 * \param[in] grayscale show data as grayscale (true) or not (false). Default: false 00334 * \param[in] layer_id the name of the layer (default: "image") 00335 * \param[in] opacity the opacity of the layer (default: 1.0) 00336 */ 00337 void 00338 addFloatImage (const float* data, unsigned int width, unsigned int height, 00339 float min_value = std::numeric_limits<float>::min (), 00340 float max_value = std::numeric_limits<float>::max (), bool grayscale = false, 00341 const std::string &layer_id = "float_image", double opacity = 1.0); 00342 00343 /** \brief Show a 2D image (unsigned short) on screen. 00344 * \param[in] short_image the input data representing the image in unsigned short format 00345 * \param[in] width the width of the image 00346 * \param[in] height the height of the image 00347 * \param[in] min_value filter all values in the image to be larger than this minimum value 00348 * \param[in] max_value filter all values in the image to be smaller than this maximum value 00349 * \param[in] grayscale show data as grayscale (true) or not (false). Default: false 00350 * \param[in] layer_id the name of the layer (default: "image") 00351 * \param[in] opacity the opacity of the layer (default: 1.0) 00352 */ 00353 void 00354 showShortImage (const unsigned short* short_image, unsigned int width, unsigned int height, 00355 unsigned short min_value = std::numeric_limits<unsigned short>::min (), 00356 unsigned short max_value = std::numeric_limits<unsigned short>::max (), bool grayscale = false, 00357 const std::string &layer_id = "short_image", double opacity = 1.0); 00358 00359 /** \brief Add a short 2D image layer, but do not render it (use spin/spinOnce to update). 00360 * \param[in] short_image the input data representing the image in unsigned short format 00361 * \param[in] width the width of the image 00362 * \param[in] height the height of the image 00363 * \param[in] min_value filter all values in the image to be larger than this minimum value 00364 * \param[in] max_value filter all values in the image to be smaller than this maximum value 00365 * \param[in] grayscale show data as grayscale (true) or not (false). Default: false 00366 * \param[in] layer_id the name of the layer (default: "image") 00367 * \param[in] opacity the opacity of the layer (default: 1.0) 00368 */ 00369 void 00370 addShortImage (const unsigned short* short_image, unsigned int width, unsigned int height, 00371 unsigned short min_value = std::numeric_limits<unsigned short>::min (), 00372 unsigned short max_value = std::numeric_limits<unsigned short>::max (), bool grayscale = false, 00373 const std::string &layer_id = "short_image", double opacity = 1.0); 00374 00375 /** \brief Show a 2D image on screen representing angle data. 00376 * \param[in] data the input data representing the image 00377 * \param[in] width the width of the image 00378 * \param[in] height the height of the image 00379 * \param[in] layer_id the name of the layer (default: "image") 00380 * \param[in] opacity the opacity of the layer (default: 1.0) 00381 */ 00382 void 00383 showAngleImage (const float* data, unsigned width, unsigned height, 00384 const std::string &layer_id = "angle_image", double opacity = 1.0); 00385 00386 /** \brief Add an angle 2D image layer, but do not render it (use spin/spinOnce to update). 00387 * \param[in] data the input data representing the image 00388 * \param[in] width the width of the image 00389 * \param[in] height the height of the image 00390 * \param[in] layer_id the name of the layer (default: "image") 00391 * \param[in] opacity the opacity of the layer (default: 1.0) 00392 */ 00393 void 00394 addAngleImage (const float* data, unsigned width, unsigned height, 00395 const std::string &layer_id = "angle_image", double opacity = 1.0); 00396 00397 /** \brief Show a 2D image on screen representing half angle data. 00398 * \param[in] data the input data representing the image 00399 * \param[in] width the width of the image 00400 * \param[in] height the height of the image 00401 * \param[in] layer_id the name of the layer (default: "image") 00402 * \param[in] opacity the opacity of the layer (default: 1.0) 00403 */ 00404 void 00405 showHalfAngleImage (const float* data, unsigned width, unsigned height, 00406 const std::string &layer_id = "half_angle_image", double opacity = 1.0); 00407 00408 /** \brief Add a half angle 2D image layer, but do not render it (use spin/spinOnce to update). 00409 * \param[in] data the input data representing the image 00410 * \param[in] width the width of the image 00411 * \param[in] height the height of the image 00412 * \param[in] layer_id the name of the layer (default: "image") 00413 * \param[in] opacity the opacity of the layer (default: 1.0) 00414 */ 00415 void 00416 addHalfAngleImage (const float* data, unsigned width, unsigned height, 00417 const std::string &layer_id = "half_angle_image", double opacity = 1.0); 00418 00419 /** \brief Sets the pixel at coordinates(u,v) to color while setting the neighborhood to another 00420 * \param[in] u the u/x coordinate of the pixel 00421 * \param[in] v the v/y coordinate of the pixel 00422 * \param[in] fg_color the pixel color 00423 * \param[in] bg_color the neighborhood color 00424 * \param[in] radius the circle radius around the pixel 00425 * \param[in] layer_id the name of the layer (default: "points") 00426 * \param[in] opacity the opacity of the layer (default: 1.0) 00427 */ 00428 void 00429 markPoint (size_t u, size_t v, Vector3ub fg_color, Vector3ub bg_color = red_color, double radius = 3.0, 00430 const std::string &layer_id = "points", double opacity = 1.0); 00431 00432 /** \brief Set the window title name 00433 * \param[in] name the window title 00434 */ 00435 void 00436 setWindowTitle (const std::string& name); 00437 00438 /** \brief Spin method. Calls the interactor and runs an internal loop. */ 00439 void 00440 spin (); 00441 00442 /** \brief Spin once method. Calls the interactor and updates the screen once. 00443 * \param[in] time - How long (in ms) should the visualization loop be allowed to run. 00444 * \param[in] force_redraw - if false it might return without doing anything if the 00445 * interactor's framerate does not require a redraw yet. 00446 */ 00447 void 00448 spinOnce (int time = 1, bool force_redraw = true); 00449 00450 /** \brief Register a callback function for keyboard events 00451 * \param[in] callback the function that will be registered as a callback for a keyboard event 00452 * \param[in] cookie user data that is passed to the callback 00453 * \return a connection object that allows to disconnect the callback function. 00454 */ 00455 boost::signals2::connection 00456 registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), 00457 void* cookie = NULL) 00458 { 00459 return (registerKeyboardCallback (boost::bind (callback, _1, cookie))); 00460 } 00461 00462 /** \brief Register a callback function for keyboard events 00463 * \param[in] callback the member function that will be registered as a callback for a keyboard event 00464 * \param[in] instance instance to the class that implements the callback function 00465 * \param[in] cookie user data that is passed to the callback 00466 * \return a connection object that allows to disconnect the callback function. 00467 */ 00468 template<typename T> boost::signals2::connection 00469 registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), 00470 T& instance, void* cookie = NULL) 00471 { 00472 return (registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie))); 00473 } 00474 00475 /** \brief Register a callback boost::function for keyboard events 00476 * \param[in] cb the boost function that will be registered as a callback for a keyboard event 00477 * \return a connection object that allows to disconnect the callback function. 00478 */ 00479 boost::signals2::connection 00480 registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> cb); 00481 00482 /** \brief Register a callback boost::function for mouse events 00483 * \param[in] callback the function that will be registered as a callback for a mouse event 00484 * \param[in] cookie user data that is passed to the callback 00485 * \return a connection object that allows to disconnect the callback function. 00486 */ 00487 boost::signals2::connection 00488 registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), 00489 void* cookie = NULL) 00490 { 00491 return (registerMouseCallback (boost::bind (callback, _1, cookie))); 00492 } 00493 00494 /** \brief Register a callback function for mouse events 00495 * \param[in] callback the member function that will be registered as a callback for a mouse event 00496 * \param[in] instance instance to the class that implements the callback function 00497 * \param[in] cookie user data that is passed to the callback 00498 * \return a connection object that allows to disconnect the callback function. 00499 */ 00500 template<typename T> boost::signals2::connection 00501 registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), 00502 T& instance, void* cookie = NULL) 00503 { 00504 return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie))); 00505 } 00506 00507 /** \brief Register a callback function for mouse events 00508 * \param[in] cb the boost function that will be registered as a callback for a mouse event 00509 * \return a connection object that allows to disconnect the callback function. 00510 */ 00511 boost::signals2::connection 00512 registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> cb); 00513 00514 /** \brief Set the position in screen coordinates. 00515 * \param[in] x where to move the window to (X) 00516 * \param[in] y where to move the window to (Y) 00517 */ 00518 void 00519 setPosition (int x, int y); 00520 00521 /** \brief Set the window size in screen coordinates. 00522 * \param[in] xw window size in horizontal (pixels) 00523 * \param[in] yw window size in vertical (pixels) 00524 */ 00525 void 00526 setSize (int xw, int yw); 00527 00528 /** \brief Return the window size in pixels. */ 00529 int* 00530 getSize (); 00531 00532 /** \brief Returns true when the user tried to close the window */ 00533 bool 00534 wasStopped () const { return (stopped_); } 00535 00536 /** \brief Stop the interaction and close the visualizaton window. */ 00537 void 00538 close () 00539 { 00540 stopped_ = true; 00541 // This tends to close the window... 00542 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 00543 interactor_->stopLoop (); 00544 #else 00545 interactor_->TerminateApp (); 00546 #endif 00547 } 00548 00549 /** \brief Add a circle shape from a point and a radius 00550 * \param[in] x the x coordinate of the circle center 00551 * \param[in] y the y coordinate of the circle center 00552 * \param[in] radius the radius of the circle 00553 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00554 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00555 */ 00556 bool 00557 addCircle (unsigned int x, unsigned int y, double radius, 00558 const std::string &layer_id = "circles", double opacity = 1.0); 00559 00560 /** \brief Add a circle shape from a point and a radius 00561 * \param[in] x the x coordinate of the circle center 00562 * \param[in] y the y coordinate of the circle center 00563 * \param[in] radius the radius of the circle 00564 * \param[in] r the red channel of the color that the sphere should be rendered with (0.0 -> 1.0) 00565 * \param[in] g the green channel of the color that the sphere should be rendered with (0.0 -> 1.0) 00566 * \param[in] b the blue channel of the color that the sphere should be rendered with (0.0 -> 1.0) 00567 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00568 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00569 */ 00570 bool 00571 addCircle (unsigned int x, unsigned int y, double radius, 00572 double r, double g, double b, 00573 const std::string &layer_id = "circles", double opacity = 1.0); 00574 00575 /** \brief Add a 2D box and color its edges with a given color 00576 * \param[in] min_pt the X,Y min coordinate 00577 * \param[in] max_pt the X,Y max coordinate 00578 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00579 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00580 */ 00581 bool 00582 addRectangle (const pcl::PointXY &min_pt, const pcl::PointXY &max_pt, 00583 const std::string &layer_id = "rectangles", double opacity = 1.0); 00584 00585 /** \brief Add a 2D box and color its edges with a given color 00586 * \param[in] min_pt the X,Y min coordinate 00587 * \param[in] max_pt the X,Y max coordinate 00588 * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0) 00589 * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0) 00590 * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0) 00591 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00592 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00593 */ 00594 bool 00595 addRectangle (const pcl::PointXY &min_pt, const pcl::PointXY &max_pt, 00596 double r, double g, double b, 00597 const std::string &layer_id = "rectangles", double opacity = 1.0); 00598 00599 /** \brief Add a 2D box and color its edges with a given color 00600 * \param[in] x_min the X min coordinate 00601 * \param[in] x_max the X max coordinate 00602 * \param[in] y_min the Y min coordinate 00603 * \param[in] y_max the Y max coordinate 00604 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00605 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00606 */ 00607 bool 00608 addRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max, 00609 const std::string &layer_id = "rectangles", double opacity = 1.0); 00610 00611 /** \brief Add a 2D box and color its edges with a given color 00612 * \param[in] x_min the X min coordinate 00613 * \param[in] x_max the X max coordinate 00614 * \param[in] y_min the Y min coordinate 00615 * \param[in] y_max the Y max coordinate 00616 * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0) 00617 * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0) 00618 * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0) 00619 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00620 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00621 */ 00622 bool 00623 addRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max, 00624 double r, double g, double b, 00625 const std::string &layer_id = "rectangles", double opacity = 1.0); 00626 00627 /** \brief Add a 2D box and color its edges with a given color 00628 * \param[in] image the organized point cloud dataset containing the image data 00629 * \param[in] min_pt the X,Y min coordinate 00630 * \param[in] max_pt the X,Y max coordinate 00631 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00632 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00633 */ 00634 template <typename T> bool 00635 addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, 00636 const T &min_pt, const T &max_pt, 00637 const std::string &layer_id = "rectangles", double opacity = 1.0); 00638 00639 /** \brief Add a 2D box and color its edges with a given color 00640 * \param[in] image the organized point cloud dataset containing the image data 00641 * \param[in] min_pt the X,Y min coordinate 00642 * \param[in] max_pt the X,Y max coordinate 00643 * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0) 00644 * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0) 00645 * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0) 00646 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00647 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00648 */ 00649 template <typename T> bool 00650 addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, 00651 const T &min_pt, const T &max_pt, 00652 double r, double g, double b, 00653 const std::string &layer_id = "rectangles", double opacity = 1.0); 00654 00655 /** \brief Add a 2D box that contains a given image mask and color its edges 00656 * \param[in] image the organized point cloud dataset containing the image data 00657 * \param[in] mask the point data representing the mask that we want to draw 00658 * \param[in] r the red channel of the color that the mask should be rendered with 00659 * \param[in] g the green channel of the color that the mask should be rendered with 00660 * \param[in] b the blue channel of the color that the mask should be rendered with 00661 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00662 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00663 */ 00664 template <typename T> bool 00665 addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask, 00666 double r, double g, double b, 00667 const std::string &layer_id = "rectangles", double opacity = 1.0); 00668 00669 /** \brief Add a 2D box that contains a given image mask and color its edges in red 00670 * \param[in] image the organized point cloud dataset containing the image data 00671 * \param[in] mask the point data representing the mask that we want to draw 00672 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00673 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00674 */ 00675 template <typename T> bool 00676 addRectangle (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask, 00677 const std::string &layer_id = "image_mask", double opacity = 1.0); 00678 00679 /** \brief Add a 2D box and fill it in with a given color 00680 * \param[in] x_min the X min coordinate 00681 * \param[in] x_max the X max coordinate 00682 * \param[in] y_min the Y min coordinate 00683 * \param[in] y_max the Y max coordinate 00684 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00685 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00686 */ 00687 bool 00688 addFilledRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max, 00689 const std::string &layer_id = "boxes", double opacity = 0.5); 00690 00691 /** \brief Add a 2D box and fill it in with a given color 00692 * \param[in] x_min the X min coordinate 00693 * \param[in] x_max the X max coordinate 00694 * \param[in] y_min the Y min coordinate 00695 * \param[in] y_max the Y max coordinate 00696 * \param[in] r the red channel of the color that the box should be rendered with (0.0 -> 1.0) 00697 * \param[in] g the green channel of the color that the box should be rendered with (0.0 -> 1.0) 00698 * \param[in] b the blue channel of the color that the box should be rendered with (0.0 -> 1.0) 00699 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00700 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00701 */ 00702 bool 00703 addFilledRectangle (unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max, 00704 double r, double g, double b, 00705 const std::string &layer_id = "boxes", double opacity = 0.5); 00706 00707 /** \brief Add a 2D line with a given color 00708 * \param[in] x_min the X min coordinate 00709 * \param[in] y_min the Y min coordinate 00710 * \param[in] x_max the X max coordinate 00711 * \param[in] y_max the Y max coordinate 00712 * \param[in] r the red channel of the color that the line should be rendered with (0.0 -> 1.0) 00713 * \param[in] g the green channel of the color that the line should be rendered with (0.0 -> 1.0) 00714 * \param[in] b the blue channel of the color that the line should be rendered with (0.0 -> 1.0) 00715 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00716 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00717 */ 00718 bool 00719 addLine (unsigned int x_min, unsigned int y_min, unsigned int x_max, unsigned int y_max, 00720 double r, double g, double b, 00721 const std::string &layer_id = "line", double opacity = 1.0); 00722 00723 /** \brief Add a 2D line with a given color 00724 * \param[in] x_min the X min coordinate 00725 * \param[in] y_min the Y min coordinate 00726 * \param[in] x_max the X max coordinate 00727 * \param[in] y_max the Y max coordinate 00728 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00729 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00730 */ 00731 bool 00732 addLine (unsigned int x_min, unsigned int y_min, unsigned int x_max, unsigned int y_max, 00733 const std::string &layer_id = "line", double opacity = 1.0); 00734 00735 /** \brief Add a 2D text with a given color 00736 * \param[in] x the X coordinate 00737 * \param[in] y the Y coordinate 00738 * \param[in] text the text string to be displayed 00739 * \param[in] r the red channel of the color that the line should be rendered with (0.0 -> 1.0) 00740 * \param[in] g the green channel of the color that the line should be rendered with (0.0 -> 1.0) 00741 * \param[in] b the blue channel of the color that the line should be rendered with (0.0 -> 1.0) 00742 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00743 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00744 */ 00745 bool 00746 addText (unsigned int x, unsigned int y, const std::string& text, 00747 double r, double g, double b, 00748 const std::string &layer_id = "line", double opacity = 1.0); 00749 00750 /** \brief Add a 2D text with a given color 00751 * \param[in] x the X coordinate 00752 * \param[in] y the Y coordinate 00753 * \param[in] text the text string to be displayed 00754 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00755 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00756 */ 00757 bool 00758 addText (unsigned int x, unsigned int y, const std::string& text, 00759 const std::string &layer_id = "line", double opacity = 1.0); 00760 00761 /** \brief Add a generic 2D mask to an image 00762 * \param[in] image the organized point cloud dataset containing the image data 00763 * \param[in] mask the point data representing the mask that we want to draw 00764 * \param[in] r the red channel of the color that the mask should be rendered with 00765 * \param[in] g the green channel of the color that the mask should be rendered with 00766 * \param[in] b the blue channel of the color that the mask should be rendered with 00767 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00768 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00769 */ 00770 template <typename T> bool 00771 addMask (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask, 00772 double r, double g, double b, 00773 const std::string &layer_id = "image_mask", double opacity = 0.5); 00774 00775 /** \brief Add a generic 2D mask to an image (colored in red) 00776 * \param[in] image the organized point cloud dataset containing the image data 00777 * \param[in] mask the point data representing the mask that we want to draw 00778 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00779 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00780 */ 00781 template <typename T> bool 00782 addMask (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PointCloud<T> &mask, 00783 const std::string &layer_id = "image_mask", double opacity = 0.5); 00784 00785 /** \brief Add a generic 2D planar polygon to an image 00786 * \param[in] image the organized point cloud dataset containing the image data 00787 * \param[in] polygon the point data representing the polygon that we want to draw. 00788 * A line will be drawn from each point to the next in the dataset. 00789 * \param[in] r the red channel of the color that the polygon should be rendered with 00790 * \param[in] g the green channel of the color that the polygon should be rendered with 00791 * \param[in] b the blue channel of the color that the polygon should be rendered with 00792 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00793 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00794 */ 00795 template <typename T> bool 00796 addPlanarPolygon (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PlanarPolygon<T> &polygon, 00797 double r, double g, double b, 00798 const std::string &layer_id = "planar_polygon", double opacity = 1.0); 00799 00800 /** \brief Add a generic 2D planar polygon to an image 00801 * \param[in] image the organized point cloud dataset containing the image data 00802 * \param[in] polygon the point data representing the polygon that we want to draw. 00803 * A line will be drawn from each point to the next in the dataset. 00804 * \param[in] layer_id the 2D layer ID where we want the extra information to be drawn. 00805 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 1.0) 00806 */ 00807 template <typename T> bool 00808 addPlanarPolygon (const typename pcl::PointCloud<T>::ConstPtr &image, const pcl::PlanarPolygon<T> &polygon, 00809 const std::string &layer_id = "planar_polygon", double opacity = 1.0); 00810 00811 /** \brief Add a new 2D rendering layer to the viewer. 00812 * \param[in] layer_id the name of the layer 00813 * \param[in] width the width of the layer 00814 * \param[in] height the height of the layer 00815 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00816 */ 00817 bool 00818 addLayer (const std::string &layer_id, int width, int height, double opacity = 0.5); 00819 00820 /** \brief Remove a 2D layer given by its ID. 00821 * \param[in] layer_id the name of the layer 00822 */ 00823 void 00824 removeLayer (const std::string &layer_id); 00825 00826 /** \brief Add the specified correspondences to the display. 00827 * \param[in] source_img The source RGB image 00828 * \param[in] target_img The target RGB image 00829 * \param[in] correspondences The list of correspondences to display. 00830 * \param[in] nth display only the Nth correspondence (e.g., skip the rest) 00831 * \param[in] layer_id the layer id (default: "correspondences") 00832 */ 00833 template <typename PointT> bool 00834 showCorrespondences (const pcl::PointCloud<PointT> &source_img, 00835 const pcl::PointCloud<PointT> &target_img, 00836 const pcl::Correspondences &correspondences, 00837 int nth = 1, 00838 const std::string &layer_id = "correspondences"); 00839 00840 protected: 00841 /** \brief Trigger a render call. */ 00842 void 00843 render (); 00844 00845 /** \brief Convert the Intensity information in a PointCloud<Intensity> to an unsigned char array 00846 * \param[in] cloud the input cloud containing the grayscale intensity information 00847 * \param[out] data a boost shared array of unsigned char type 00848 * \note The method assumes that the data array has already been allocated and 00849 * contains enough space to copy all the data from cloud! 00850 */ 00851 void 00852 convertIntensityCloudToUChar (const pcl::PointCloud<pcl::Intensity> &cloud, 00853 boost::shared_array<unsigned char> data); 00854 00855 /** \brief Convert the Intensity8u information in a PointCloud<Intensity8u> to an unsigned char array 00856 * \param[in] cloud the input cloud containing the grayscale intensity information 00857 * \param[out] data a boost shared array of unsigned char type 00858 * \note The method assumes that the data array has already been allocated and 00859 * contains enough space to copy all the data from cloud! 00860 */ 00861 void 00862 convertIntensityCloud8uToUChar (const pcl::PointCloud<pcl::Intensity8u> &cloud, 00863 boost::shared_array<unsigned char> data); 00864 00865 /** \brief Convert the RGB information in a PointCloud<T> to an unsigned char array 00866 * \param[in] cloud the input cloud containing the RGB information 00867 * \param[out] data a boost shared array of unsigned char type 00868 * \note The method assumes that the data array has already been allocated and 00869 * contains enough space to copy all the data from cloud! 00870 */ 00871 template <typename T> void 00872 convertRGBCloudToUChar (const pcl::PointCloud<T> &cloud, 00873 boost::shared_array<unsigned char> &data); 00874 00875 /** \brief Set the stopped flag back to false */ 00876 void 00877 resetStoppedFlag () { stopped_ = false; } 00878 00879 /** \brief Fire up a mouse event with a specified event ID 00880 * \param[int] event_id the id of the event 00881 */ 00882 void 00883 emitMouseEvent (unsigned long event_id); 00884 00885 /** \brief Fire up a keyboard event with a specified event ID 00886 * \param[int] event_id the id of the event 00887 */ 00888 void 00889 emitKeyboardEvent (unsigned long event_id); 00890 00891 // Callbacks used to register for vtk command 00892 static void 00893 MouseCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata); 00894 static void 00895 KeyboardCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata); 00896 00897 protected: // types 00898 struct ExitMainLoopTimerCallback : public vtkCommand 00899 { 00900 ExitMainLoopTimerCallback () : right_timer_id (), window () {} 00901 00902 static ExitMainLoopTimerCallback* New () 00903 { 00904 return (new ExitMainLoopTimerCallback); 00905 } 00906 virtual void 00907 Execute (vtkObject* vtkNotUsed (caller), unsigned long event_id, void* call_data) 00908 { 00909 if (event_id != vtkCommand::TimerEvent) 00910 return; 00911 int timer_id = *static_cast<int*> (call_data); 00912 if (timer_id != right_timer_id) 00913 return; 00914 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 00915 window->interactor_->stopLoop (); 00916 #else 00917 window->interactor_->TerminateApp (); 00918 #endif 00919 } 00920 int right_timer_id; 00921 ImageViewer* window; 00922 }; 00923 struct ExitCallback : public vtkCommand 00924 { 00925 ExitCallback () : window () {} 00926 00927 static ExitCallback* New () 00928 { 00929 return (new ExitCallback); 00930 } 00931 virtual void 00932 Execute (vtkObject*, unsigned long event_id, void*) 00933 { 00934 if (event_id != vtkCommand::ExitEvent) 00935 return; 00936 window->stopped_ = true; 00937 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 00938 window->interactor_->stopLoop (); 00939 #else 00940 window->interactor_->TerminateApp (); 00941 #endif 00942 } 00943 ImageViewer* window; 00944 }; 00945 00946 private: 00947 /** \brief Internal structure describing a layer. */ 00948 struct Layer 00949 { 00950 Layer () : actor (), layer_name () {} 00951 vtkSmartPointer<vtkContextActor> actor; 00952 std::string layer_name; 00953 }; 00954 00955 typedef std::vector<Layer> LayerMap; 00956 00957 /** \brief Add a new 2D rendering layer to the viewer. 00958 * \param[in] layer_id the name of the layer 00959 * \param[in] width the width of the layer 00960 * \param[in] height the height of the layer 00961 * \param[in] opacity the opacity of the layer: 0 for invisible, 1 for opaque. (default: 0.5) 00962 * \param[in] fill_box set to true to fill in the image with one black box before starting 00963 */ 00964 LayerMap::iterator 00965 createLayer (const std::string &layer_id, int width, int height, double opacity = 0.5, bool fill_box = true); 00966 00967 boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_; 00968 boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_; 00969 00970 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 00971 vtkSmartPointer<PCLVisualizerInteractor> interactor_; 00972 #else 00973 vtkSmartPointer<vtkRenderWindowInteractor> interactor_; 00974 #endif 00975 vtkSmartPointer<vtkCallbackCommand> mouse_command_; 00976 vtkSmartPointer<vtkCallbackCommand> keyboard_command_; 00977 00978 /** \brief Callback object enabling us to leave the main loop, when a timer fires. */ 00979 vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_; 00980 vtkSmartPointer<ExitCallback> exit_callback_; 00981 00982 /** \brief The ImageViewer widget. */ 00983 vtkSmartPointer<vtkImageViewer> image_viewer_; 00984 00985 /** \brief The render window. */ 00986 vtkSmartPointer<vtkRenderWindow> win_; 00987 00988 /** \brief The renderer. */ 00989 vtkSmartPointer<vtkRenderer> ren_; 00990 00991 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION >= 10)) 00992 /** \brief Global prop. This is the actual "actor". */ 00993 vtkSmartPointer<vtkImageSlice> slice_; 00994 #endif 00995 /** \brief The interactor style. */ 00996 vtkSmartPointer<ImageViewerInteractorStyle> interactor_style_; 00997 00998 /** \brief The data array representing the image. Used internally. */ 00999 boost::shared_array<unsigned char> data_; 01000 01001 /** \brief The data array (representing the image) size. Used internally. */ 01002 size_t data_size_; 01003 01004 /** \brief Set to false if the interaction loop is running. */ 01005 bool stopped_; 01006 01007 /** \brief Global timer ID. Used in destructor only. */ 01008 int timer_id_; 01009 01010 // /** \brief Internal blender used to overlay 2D geometry over the image. */ 01011 // vtkSmartPointer<vtkImageBlend> blend_; 01012 01013 /** \brief Internal list with different 2D layers shapes. */ 01014 LayerMap layer_map_; 01015 01016 /** \brief Image reslice, used for flipping the image. */ 01017 vtkSmartPointer<vtkImageFlip> algo_; 01018 01019 /** \brief Internal data array. Used everytime add***Image is called. 01020 * Cleared, everytime the render loop is executed. 01021 */ 01022 std::vector<unsigned char*> image_data_; 01023 01024 struct LayerComparator 01025 { 01026 LayerComparator (const std::string &str) : str_ (str) {} 01027 const std::string &str_; 01028 01029 bool 01030 operator () (const Layer &layer) 01031 { 01032 return (layer.layer_name == str_); 01033 } 01034 }; 01035 01036 public: 01037 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 01038 }; 01039 } 01040 } 01041 01042 #include <pcl/visualization/impl/image_viewer.hpp> 01043 01044 #endif /* __IMAGE_VISUALIZER_H__ */ 01045
Except where otherwise noted, the PointClouds.org web pages are licensed under Creative Commons Attribution 3.0.
Pages generated on Wed Mar 25 00:26:25 2015