42 #include <pcl/correspondence.h>
43 #include <pcl/ModelCoefficients.h>
44 #include <pcl/PolygonMesh.h>
45 #include <pcl/TextureMesh.h>
47 #include <pcl/console/print.h>
48 #include <pcl/visualization/common/actor_map.h>
49 #include <pcl/visualization/common/common.h>
50 #include <pcl/visualization/point_cloud_geometry_handlers.h>
51 #include <pcl/visualization/point_cloud_color_handlers.h>
52 #include <pcl/visualization/point_picking_event.h>
53 #include <pcl/visualization/area_picking_event.h>
54 #include <pcl/visualization/interactor_style.h>
59 class vtkRenderWindow;
60 class vtkOrientationMarkerWidget;
61 class vtkAppendPolyData;
62 class vtkRenderWindow;
63 class vtkRenderWindowInteractor;
65 class vtkInteractorStyle;
70 class vtkUnstructuredGrid;
75 template <
typename T>
class PlanarPolygon;
77 namespace visualization
89 using Ptr = shared_ptr<PCLVisualizer>;
90 using ConstPtr = shared_ptr<const PCLVisualizer>;
104 PCLVisualizer (
const std::string &name =
"",
const bool create_interactor =
true);
114 PCLVisualizer (
int &argc,
char **argv,
const std::string &name =
"",
134 const bool create_interactor =
true);
146 setFullScreen (
bool mode);
152 setWindowName (
const std::string &name);
160 setWindowBorders (
bool mode);
166 boost::signals2::connection
174 inline boost::signals2::connection
186 template<
typename T>
inline boost::signals2::connection
196 boost::signals2::connection
204 inline boost::signals2::connection
216 template<
typename T>
inline boost::signals2::connection
226 boost::signals2::connection
234 boost::signals2::connection
243 template<
typename T>
inline boost::signals2::connection
253 boost::signals2::connection
261 boost::signals2::connection
270 template<
typename T>
inline boost::signals2::connection
286 spinOnce (
int time = 1,
bool force_redraw =
false);
292 addOrientationMarkerWidgetAxes (vtkRenderWindowInteractor* interactor);
296 removeOrientationMarkerWidgetAxes ();
304 addCoordinateSystem (
double scale = 1.0,
const std::string&
id =
"reference",
int viewport = 0);
315 addCoordinateSystem (
double scale,
float x,
float y,
float z,
const std::string &
id =
"reference",
int viewport = 0);
353 addCoordinateSystem (
double scale,
const Eigen::Affine3f& t,
const std::string &
id =
"reference",
int viewport = 0);
360 removeCoordinateSystem (
const std::string &
id =
"reference",
int viewport = 0);
369 removePointCloud (
const std::string &
id =
"cloud",
int viewport = 0);
379 return (removePointCloud (
id, viewport));
388 removeShape (
const std::string &
id =
"cloud",
int viewport = 0);
395 removeText3D (
const std::string &
id =
"cloud",
int viewport = 0);
401 removeAllPointClouds (
int viewport = 0);
407 removeAllShapes (
int viewport = 0);
413 removeAllCoordinateSystems (
int viewport = 0);
422 setBackgroundColor (
const double &r,
const double &g,
const double &b,
int viewport = 0);
432 addText (
const std::string &text,
434 const std::string &
id =
"",
int viewport = 0);
447 addText (
const std::string &text,
int xpos,
int ypos,
double r,
double g,
double b,
448 const std::string &
id =
"",
int viewport = 0);
462 addText (
const std::string &text,
int xpos,
int ypos,
int fontsize,
double r,
double g,
double b,
463 const std::string &
id =
"",
int viewport = 0);
473 updateText (
const std::string &text,
475 const std::string &
id =
"");
487 updateText (
const std::string &text,
488 int xpos,
int ypos,
double r,
double g,
double b,
489 const std::string &
id =
"");
502 updateText (
const std::string &text,
503 int xpos,
int ypos,
int fontsize,
double r,
double g,
double b,
504 const std::string &
id =
"");
516 updateShapePose (
const std::string &
id,
const Eigen::Affine3f& pose);
528 updateCoordinateSystemPose (
const std::string &
id,
const Eigen::Affine3f& pose);
540 updatePointCloudPose (
const std::string &
id,
const Eigen::Affine3f& pose);
552 template <
typename Po
intT>
bool
553 addText3D (
const std::string &text,
555 double textScale = 1.0,
556 double r = 1.0,
double g = 1.0,
double b = 1.0,
557 const std::string &
id =
"",
int viewport = 0);
573 template <
typename Po
intT>
bool
574 addText3D (
const std::string &text,
576 double orientation[3],
577 double textScale = 1.0,
578 double r = 1.0,
double g = 1.0,
double b = 1.0,
579 const std::string &
id =
"",
int viewport = 0);
588 return (cloud_actor_map_->find (
id) != cloud_actor_map_->end () ||
589 shape_actor_map_->find (
id) != shape_actor_map_->end () ||
590 coordinate_actor_map_->find (
id) != coordinate_actor_map_-> end());
600 template <
typename Po
intNT>
bool
602 int level = 100,
float scale = 0.02f,
603 const std::string &
id =
"cloud",
int viewport = 0);
613 template <
typename Po
intT,
typename Po
intNT>
bool
616 int level = 100,
float scale = 0.02f,
617 const std::string &
id =
"cloud",
int viewport = 0);
627 template <
typename Po
intNT>
bool
628 addPointCloudPrincipalCurvatures (
631 int level = 100,
float scale = 1.0f,
632 const std::string &
id =
"cloud",
int viewport = 0);
643 template <
typename Po
intT,
typename Po
intNT>
bool
644 addPointCloudPrincipalCurvatures (
648 int level = 100,
float scale = 1.0f,
649 const std::string &
id =
"cloud",
int viewport = 0);
659 template <
typename Po
intT,
typename GradientT>
bool
662 int level = 100,
double scale = 1e-6,
663 const std::string &
id =
"cloud",
int viewport = 0);
670 template <
typename Po
intT>
bool
672 const std::string &
id =
"cloud",
int viewport = 0);
679 template <
typename Po
intT>
bool
681 const std::string &
id =
"cloud");
689 template <
typename Po
intT>
bool
692 const std::string &
id =
"cloud");
700 template <
typename Po
intT>
bool
703 const std::string &
id =
"cloud");
711 template <
typename Po
intT>
bool
714 const std::string &
id =
"cloud",
int viewport = 0);
728 template <
typename Po
intT>
bool
730 const GeometryHandlerConstPtr &geometry_handler,
731 const std::string &
id =
"cloud",
int viewport = 0);
739 template <
typename Po
intT>
bool
742 const std::string &
id =
"cloud",
int viewport = 0);
756 template <
typename Po
intT>
bool
758 const ColorHandlerConstPtr &color_handler,
759 const std::string &
id =
"cloud",
int viewport = 0);
774 template <
typename Po
intT>
bool
776 const GeometryHandlerConstPtr &geometry_handler,
777 const ColorHandlerConstPtr &color_handler,
778 const std::string &
id =
"cloud",
int viewport = 0);
797 const GeometryHandlerConstPtr &geometry_handler,
798 const ColorHandlerConstPtr &color_handler,
799 const Eigen::Vector4f& sensor_origin,
800 const Eigen::Quaternion<float>& sensor_orientation,
801 const std::string &
id =
"cloud",
int viewport = 0);
819 const GeometryHandlerConstPtr &geometry_handler,
820 const Eigen::Vector4f& sensor_origin,
821 const Eigen::Quaternion<float>& sensor_orientation,
822 const std::string &
id =
"cloud",
int viewport = 0);
840 const ColorHandlerConstPtr &color_handler,
841 const Eigen::Vector4f& sensor_origin,
842 const Eigen::Quaternion<float>& sensor_orientation,
843 const std::string &
id =
"cloud",
int viewport = 0);
852 template <
typename Po
intT>
bool
856 const std::string &
id =
"cloud",
int viewport = 0);
865 const std::string &
id =
"cloud",
int viewport = 0)
867 return (addPointCloud<pcl::PointXYZ> (cloud,
id, viewport));
878 const std::string &
id =
"cloud",
int viewport = 0)
881 return (addPointCloud<pcl::PointXYZRGB> (cloud, color_handler,
id, viewport));
891 const std::string &
id =
"cloud",
int viewport = 0)
894 return (addPointCloud<pcl::PointXYZRGBA> (cloud, color_handler,
id, viewport));
904 const std::string &
id =
"cloud",
int viewport = 0)
907 return (addPointCloud<pcl::PointXYZL> (cloud, color_handler,
id, viewport));
917 const std::string &
id =
"cloud")
919 return (updatePointCloud<pcl::PointXYZ> (cloud,
id));
929 const std::string &
id =
"cloud")
932 return (updatePointCloud<pcl::PointXYZRGB> (cloud, color_handler,
id));
942 const std::string &
id =
"cloud")
945 return (updatePointCloud<pcl::PointXYZRGBA> (cloud, color_handler,
id));
955 const std::string &
id =
"cloud")
958 return (updatePointCloud<pcl::PointXYZL> (cloud, color_handler,
id));
968 const std::string &
id =
"polygon",
977 template <
typename Po
intT>
bool
979 const std::vector<pcl::Vertices> &vertices,
980 const std::string &
id =
"polygon",
989 template <
typename Po
intT>
bool
991 const std::vector<pcl::Vertices> &vertices,
992 const std::string &
id =
"polygon");
1001 const std::string &
id =
"polygon");
1010 const std::string &
id =
"polyline",
1020 template <
typename Po
intT>
bool
1023 const std::vector<int> & correspondences,
1024 const std::string &
id =
"correspondences",
1034 const std::string &
id =
"texture",
1046 template <
typename Po
intT>
bool
1051 const std::string &
id =
"correspondences",
1053 bool overwrite =
false);
1062 template <
typename Po
intT>
bool
1066 const std::string &
id =
"correspondences",
1070 return (addCorrespondences<PointT> (source_points, target_points,
1071 correspondences, 1,
id, viewport));
1082 template <
typename Po
intT>
bool
1083 updateCorrespondences (
1088 const std::string &
id =
"correspondences",
1098 template <
typename Po
intT>
bool
1103 const std::string &
id =
"correspondences",
1107 return (updateCorrespondences<PointT> (source_points, target_points,
1108 correspondences, 1,
id, viewport));
1116 removeCorrespondences (
const std::string &
id =
"correspondences",
int viewport = 0);
1122 getColorHandlerIndex (
const std::string &
id);
1128 getGeometryHandlerIndex (
const std::string &
id);
1135 updateColorHandlerIndex (
const std::string &
id,
int index);
1147 setPointCloudRenderingProperties (
int property,
double val1,
double val2,
double val3,
1148 const std::string &
id =
"cloud",
int viewport = 0);
1159 setPointCloudRenderingProperties (
int property,
double val1,
double val2,
1160 const std::string &
id =
"cloud",
int viewport = 0);
1170 setPointCloudRenderingProperties (
int property,
double value,
1171 const std::string &
id =
"cloud",
int viewport = 0);
1180 getPointCloudRenderingProperties (
int property,
double &value,
1181 const std::string &
id =
"cloud");
1193 getPointCloudRenderingProperties (
RenderingProperties property,
double &val1,
double &val2,
double &val3,
1194 const std::string &
id =
"cloud");
1201 setPointCloudSelected (
const bool selected,
const std::string &
id =
"cloud" );
1212 setShapeRenderingProperties (
int property,
double value,
1213 const std::string &
id,
int viewport = 0);
1224 setShapeRenderingProperties (
int property,
double val1,
double val2,
1225 const std::string &
id,
int viewport = 0);
1237 setShapeRenderingProperties (
int property,
double val1,
double val2,
double val3,
1238 const std::string &
id,
int viewport = 0);
1242 wasStopped ()
const;
1246 resetStoppedFlag ();
1264 createViewPort (
double xmin,
double ymin,
double xmax,
double ymax,
int &viewport);
1270 createViewPortCamera (
const int viewport);
1281 template <
typename Po
intT>
bool
1283 double r,
double g,
double b,
1284 const std::string &
id =
"polygon",
int viewport = 0);
1292 template <
typename Po
intT>
bool
1294 const std::string &
id =
"polygon",
1305 template <
typename Po
intT>
bool
1307 double r,
double g,
double b,
1308 const std::string &
id =
"polygon",
1317 template <
typename P1,
typename P2>
bool
1318 addLine (
const P1 &pt1,
const P2 &pt2,
const std::string &
id =
"line",
1330 template <
typename P1,
typename P2>
bool
1331 addLine (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
1332 const std::string &
id =
"line",
int viewport = 0);
1346 template <
typename P1,
typename P2>
bool
1347 addArrow (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
1348 const std::string &
id =
"arrow",
int viewport = 0);
1363 template <
typename P1,
typename P2>
bool
1364 addArrow (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
bool display_length,
1365 const std::string &
id =
"arrow",
int viewport = 0);
1382 template <
typename P1,
typename P2>
bool
1383 addArrow (
const P1 &pt1,
const P2 &pt2,
1384 double r_line,
double g_line,
double b_line,
1385 double r_text,
double g_text,
double b_text,
1386 const std::string &
id =
"arrow",
int viewport = 0);
1395 template <
typename Po
intT>
bool
1396 addSphere (
const PointT ¢er,
double radius,
const std::string &
id =
"sphere",
1408 template <
typename Po
intT>
bool
1409 addSphere (
const PointT ¢er,
double radius,
double r,
double g,
double b,
1410 const std::string &
id =
"sphere",
int viewport = 0);
1420 template <
typename Po
intT>
bool
1421 updateSphere (
const PointT ¢er,
double radius,
double r,
double g,
double b,
1422 const std::string &
id =
"sphere");
1431 const std::string &
id =
"PolyData",
1443 const std::string &
id =
"PolyData",
1452 addModelFromPLYFile (
const std::string &filename,
1453 const std::string &
id =
"PLYModel",
1463 addModelFromPLYFile (
const std::string &filename,
1465 const std::string &
id =
"PLYModel",
1496 const std::string &
id =
"cylinder",
1523 const std::string &
id =
"sphere",
1551 const std::string &
id =
"line",
1579 const char *
id =
"line",
1582 return addLine (coefficients, std::string (
id), viewport);
1607 const std::string &
id =
"plane",
1612 const std::string &
id =
"plane",
1635 const std::string &
id =
"circle",
1645 const std::string &
id =
"cone",
1655 const std::string &
id =
"cube",
1668 addCube (
const Eigen::Vector3f &translation,
const Eigen::Quaternionf &rotation,
1669 double width,
double height,
double depth,
1670 const std::string &
id =
"cube",
1687 addCube (
float x_min,
float x_max,
float y_min,
float y_max,
float z_min,
float z_max,
1688 double r = 1.0,
double g = 1.0,
double b = 1.0,
const std::string &
id =
"cube",
int viewport = 0);
1692 setRepresentationToSurfaceForAllActors ();
1696 setRepresentationToPointsForAllActors ();
1700 setRepresentationToWireframeForAllActors ();
1706 setShowFPS (
bool show_fps);
1741 renderViewTesselatedSphere (
1744 std::vector<Eigen::Matrix4f,Eigen::aligned_allocator< Eigen::Matrix4f > > & poses, std::vector<float> & enthropies,
int tesselation_level,
1745 float view_angle = 45,
float radius_sphere = 1,
bool use_vertices =
true);
1750 initCameraParameters ();
1757 getCameraParameters (
int argc,
char **argv);
1763 loadCameraParameters (
const std::string &file);
1770 cameraParamsSet ()
const;
1779 cameraFileLoaded ()
const;
1787 getCameraFile ()
const;
1801 resetCameraViewpoint (
const std::string &
id =
"cloud");
1816 setCameraPosition (
double pos_x,
double pos_y,
double pos_z,
1817 double view_x,
double view_y,
double view_z,
1818 double up_x,
double up_y,
double up_z,
int viewport = 0);
1830 setCameraPosition (
double pos_x,
double pos_y,
double pos_z,
1831 double up_x,
double up_y,
double up_z,
int viewport = 0);
1840 setCameraParameters (
const Eigen::Matrix3f &intrinsics,
const Eigen::Matrix4f &extrinsics,
int viewport = 0);
1847 setCameraParameters (
const Camera &camera,
int viewport = 0);
1855 setCameraClipDistances (
double near,
double far,
int viewport = 0);
1862 setCameraFieldOfView (
double fovy,
int viewport = 0);
1866 getCameras (std::vector<Camera>& cameras);
1871 getViewerPose (
int viewport = 0);
1877 saveScreenshot (
const std::string &file);
1883 saveCameraParameters (
const std::string &file);
1887 getCameraParameters (
Camera &camera,
int viewport = 0)
const;
1907 return (cloud_actor_map_);
1914 return (shape_actor_map_);
1922 setPosition (
int x,
int y);
1929 setSize (
int xw,
int yw);
1937 setUseVbos (
bool use_vbos);
1943 setLookUpTableID (
const std::string
id);
1947 createInteractor ();
1955 setupInteractor (vtkRenderWindowInteractor *iren,
1956 vtkRenderWindow *win);
1965 setupInteractor (vtkRenderWindowInteractor *iren,
1966 vtkRenderWindow *win,
1967 vtkInteractorStyle *style);
1992 void setupRenderWindow (
const std::string& name);
2000 void setDefaultWindowSizeAndPos ();
2008 void setupCamera (
int argc,
char **argv);
2010 struct PCL_EXPORTS ExitMainLoopTimerCallback :
public vtkCommand
2012 static ExitMainLoopTimerCallback* New ()
2014 return (
new ExitMainLoopTimerCallback);
2017 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2023 struct PCL_EXPORTS ExitCallback :
public vtkCommand
2025 static ExitCallback* New ()
2027 return (
new ExitCallback);
2030 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2032 PCLVisualizer* pcl_visualizer;
2036 struct PCL_EXPORTS FPSCallback :
public vtkCommand
2038 static FPSCallback *New () {
return (
new FPSCallback); }
2040 FPSCallback () : actor (), pcl_visualizer (), decimated (), last_fps(0.0f) {}
2041 FPSCallback (
const FPSCallback& src) : vtkCommand (src), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated), last_fps (src.last_fps) {}
2042 FPSCallback& operator = (
const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; last_fps = src.last_fps;
return (*
this); }
2045 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2047 vtkTextActor *actor;
2048 PCLVisualizer* pcl_visualizer;
2091 bool camera_file_loaded_;
2139 bool use_scalars =
true)
const;
2149 bool use_scalars =
true)
const;
2157 template <
typename Po
intT>
void
2168 template <
typename Po
intT>
void
2169 convertPointCloudToVTKPolyData (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2180 convertPointCloudToVTKPolyData (
const GeometryHandlerConstPtr &geometry_handler,
2195 vtkIdType nr_points);
2207 template <
typename Po
intT>
bool
2208 fromHandlersToScreen (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2209 const PointCloudColorHandler<PointT> &color_handler,
2210 const std::string &
id,
2212 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2213 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2225 template <
typename Po
intT>
bool
2226 fromHandlersToScreen (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2227 const ColorHandlerConstPtr &color_handler,
2228 const std::string &
id,
2230 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2231 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2244 fromHandlersToScreen (
const GeometryHandlerConstPtr &geometry_handler,
2245 const ColorHandlerConstPtr &color_handler,
2246 const std::string &
id,
2248 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2249 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2261 template <
typename Po
intT>
bool
2262 fromHandlersToScreen (
const GeometryHandlerConstPtr &geometry_handler,
2263 const PointCloudColorHandler<PointT> &color_handler,
2264 const std::string &
id,
2266 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2267 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2293 getTransformationMatrix (
const Eigen::Vector4f &origin,
2294 const Eigen::Quaternion<float> &orientation,
2295 Eigen::Matrix4f &transformation);
2306 vtkTexture* vtk_tex)
const;
2313 getUniqueCameraFile (
int argc,
char **argv);
2322 convertToVtkMatrix (
const Eigen::Matrix4f &m,
2331 convertToVtkMatrix (
const Eigen::Vector4f &origin,
2332 const Eigen::Quaternion<float> &orientation,
2341 Eigen::Matrix4f &m);
2347 #include <pcl/visualization/impl/pcl_visualizer.hpp>