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>
56 #include <vtkOrientationMarkerWidget.h>
57 #include <vtkRenderWindowInteractor.h>
62 class vtkRenderWindow;
63 class vtkAppendPolyData;
64 class vtkRenderWindow;
66 class vtkInteractorStyle;
71 class vtkUnstructuredGrid;
77 template <
typename T>
class PlanarPolygon;
79 namespace visualization
96 using Ptr = shared_ptr<PCLVisualizer>;
97 using ConstPtr = shared_ptr<const PCLVisualizer>;
111 PCLVisualizer (
const std::string &name =
"",
const bool create_interactor =
true);
121 PCLVisualizer (
int &argc,
char **argv,
const std::string &name =
"",
141 const bool create_interactor =
true);
153 setFullScreen (
bool mode);
159 setWindowName (
const std::string &name);
167 setWindowBorders (
bool mode);
173 boost::signals2::connection
181 inline boost::signals2::connection
193 template<
typename T>
inline boost::signals2::connection
203 boost::signals2::connection
211 inline boost::signals2::connection
223 template<
typename T>
inline boost::signals2::connection
233 boost::signals2::connection
241 boost::signals2::connection
250 template<
typename T>
inline boost::signals2::connection
260 boost::signals2::connection
268 boost::signals2::connection
277 template<
typename T>
inline boost::signals2::connection
293 spinOnce (
int time = 1,
bool force_redraw =
false);
299 addOrientationMarkerWidgetAxes (vtkRenderWindowInteractor* interactor);
303 removeOrientationMarkerWidgetAxes ();
311 addCoordinateSystem (
double scale = 1.0,
const std::string&
id =
"reference",
int viewport = 0);
322 addCoordinateSystem (
double scale,
float x,
float y,
float z,
const std::string &
id =
"reference",
int viewport = 0);
360 addCoordinateSystem (
double scale,
const Eigen::Affine3f& t,
const std::string &
id =
"reference",
int viewport = 0);
367 removeCoordinateSystem (
const std::string &
id =
"reference",
int viewport = 0);
376 removePointCloud (
const std::string &
id =
"cloud",
int viewport = 0);
386 return (removePointCloud (
id, viewport));
395 removeShape (
const std::string &
id =
"cloud",
int viewport = 0);
402 removeText3D (
const std::string &
id =
"cloud",
int viewport = 0);
408 removeAllPointClouds (
int viewport = 0);
414 removeAllShapes (
int viewport = 0);
420 removeAllCoordinateSystems (
int viewport = 0);
429 setBackgroundColor (
const double &r,
const double &g,
const double &b,
int viewport = 0);
439 addText (
const std::string &text,
441 const std::string &
id =
"",
int viewport = 0);
454 addText (
const std::string &text,
int xpos,
int ypos,
double r,
double g,
double b,
455 const std::string &
id =
"",
int viewport = 0);
469 addText (
const std::string &text,
int xpos,
int ypos,
int fontsize,
double r,
double g,
double b,
470 const std::string &
id =
"",
int viewport = 0);
480 updateText (
const std::string &text,
482 const std::string &
id =
"");
494 updateText (
const std::string &text,
495 int xpos,
int ypos,
double r,
double g,
double b,
496 const std::string &
id =
"");
509 updateText (
const std::string &text,
510 int xpos,
int ypos,
int fontsize,
double r,
double g,
double b,
511 const std::string &
id =
"");
523 updateShapePose (
const std::string &
id,
const Eigen::Affine3f& pose);
535 updateCoordinateSystemPose (
const std::string &
id,
const Eigen::Affine3f& pose);
547 updatePointCloudPose (
const std::string &
id,
const Eigen::Affine3f& pose);
559 template <
typename Po
intT>
bool
560 addText3D (
const std::string &text,
562 double textScale = 1.0,
563 double r = 1.0,
double g = 1.0,
double b = 1.0,
564 const std::string &
id =
"",
int viewport = 0);
580 template <
typename Po
intT>
bool
581 addText3D (
const std::string &text,
583 double orientation[3],
584 double textScale = 1.0,
585 double r = 1.0,
double g = 1.0,
double b = 1.0,
586 const std::string &
id =
"",
int viewport = 0);
595 return (cloud_actor_map_->find (
id) != cloud_actor_map_->end () ||
596 shape_actor_map_->find (
id) != shape_actor_map_->end () ||
597 coordinate_actor_map_->find (
id) != coordinate_actor_map_-> end());
607 template <
typename Po
intNT>
bool
609 int level = 100,
float scale = 0.02f,
610 const std::string &
id =
"cloud",
int viewport = 0);
620 template <
typename Po
intT,
typename Po
intNT>
bool
623 int level = 100,
float scale = 0.02f,
624 const std::string &
id =
"cloud",
int viewport = 0);
634 template <
typename Po
intNT>
bool
635 addPointCloudPrincipalCurvatures (
638 int level = 100,
float scale = 1.0f,
639 const std::string &
id =
"cloud",
int viewport = 0);
650 template <
typename Po
intT,
typename Po
intNT>
bool
651 addPointCloudPrincipalCurvatures (
655 int level = 100,
float scale = 1.0f,
656 const std::string &
id =
"cloud",
int viewport = 0);
666 template <
typename Po
intT,
typename GradientT>
bool
669 int level = 100,
double scale = 1e-6,
670 const std::string &
id =
"cloud",
int viewport = 0);
677 template <
typename Po
intT>
bool
679 const std::string &
id =
"cloud",
int viewport = 0);
686 template <
typename Po
intT>
bool
688 const std::string &
id =
"cloud");
696 template <
typename Po
intT>
bool
699 const std::string &
id =
"cloud");
707 template <
typename Po
intT>
bool
710 const std::string &
id =
"cloud");
718 template <
typename Po
intT>
bool
721 const std::string &
id =
"cloud",
int viewport = 0);
735 template <
typename Po
intT>
bool
737 const GeometryHandlerConstPtr &geometry_handler,
738 const std::string &
id =
"cloud",
int viewport = 0);
746 template <
typename Po
intT>
bool
749 const std::string &
id =
"cloud",
int viewport = 0);
763 template <
typename Po
intT>
bool
765 const ColorHandlerConstPtr &color_handler,
766 const std::string &
id =
"cloud",
int viewport = 0);
781 template <
typename Po
intT>
bool
783 const GeometryHandlerConstPtr &geometry_handler,
784 const ColorHandlerConstPtr &color_handler,
785 const std::string &
id =
"cloud",
int viewport = 0);
804 const GeometryHandlerConstPtr &geometry_handler,
805 const ColorHandlerConstPtr &color_handler,
806 const Eigen::Vector4f& sensor_origin,
807 const Eigen::Quaternion<float>& sensor_orientation,
808 const std::string &
id =
"cloud",
int viewport = 0);
826 const GeometryHandlerConstPtr &geometry_handler,
827 const Eigen::Vector4f& sensor_origin,
828 const Eigen::Quaternion<float>& sensor_orientation,
829 const std::string &
id =
"cloud",
int viewport = 0);
847 const ColorHandlerConstPtr &color_handler,
848 const Eigen::Vector4f& sensor_origin,
849 const Eigen::Quaternion<float>& sensor_orientation,
850 const std::string &
id =
"cloud",
int viewport = 0);
859 template <
typename Po
intT>
bool
863 const std::string &
id =
"cloud",
int viewport = 0);
872 const std::string &
id =
"cloud",
int viewport = 0)
874 return (addPointCloud<pcl::PointXYZ> (cloud,
id, viewport));
885 const std::string &
id =
"cloud",
int viewport = 0)
888 return (addPointCloud<pcl::PointXYZRGB> (cloud, color_handler,
id, viewport));
898 const std::string &
id =
"cloud",
int viewport = 0)
901 return (addPointCloud<pcl::PointXYZRGBA> (cloud, color_handler,
id, viewport));
911 const std::string &
id =
"cloud",
int viewport = 0)
914 return (addPointCloud<pcl::PointXYZL> (cloud, color_handler,
id, viewport));
924 const std::string &
id =
"cloud")
926 return (updatePointCloud<pcl::PointXYZ> (cloud,
id));
936 const std::string &
id =
"cloud")
939 return (updatePointCloud<pcl::PointXYZRGB> (cloud, color_handler,
id));
949 const std::string &
id =
"cloud")
952 return (updatePointCloud<pcl::PointXYZRGBA> (cloud, color_handler,
id));
962 const std::string &
id =
"cloud")
965 return (updatePointCloud<pcl::PointXYZL> (cloud, color_handler,
id));
975 const std::string &
id =
"polygon",
984 template <
typename Po
intT>
bool
986 const std::vector<pcl::Vertices> &vertices,
987 const std::string &
id =
"polygon",
996 template <
typename Po
intT>
bool
998 const std::vector<pcl::Vertices> &vertices,
999 const std::string &
id =
"polygon");
1008 const std::string &
id =
"polygon");
1017 const std::string &
id =
"polyline",
1027 template <
typename Po
intT>
bool
1030 const std::vector<int> & correspondences,
1031 const std::string &
id =
"correspondences",
1041 const std::string &
id =
"texture",
1053 template <
typename Po
intT>
bool
1058 const std::string &
id =
"correspondences",
1060 bool overwrite =
false);
1069 template <
typename Po
intT>
bool
1073 const std::string &
id =
"correspondences",
1077 return (addCorrespondences<PointT> (source_points, target_points,
1078 correspondences, 1,
id, viewport));
1089 template <
typename Po
intT>
bool
1090 updateCorrespondences (
1095 const std::string &
id =
"correspondences",
1105 template <
typename Po
intT>
bool
1110 const std::string &
id =
"correspondences",
1114 return (updateCorrespondences<PointT> (source_points, target_points,
1115 correspondences, 1,
id, viewport));
1123 removeCorrespondences (
const std::string &
id =
"correspondences",
int viewport = 0);
1129 getColorHandlerIndex (
const std::string &
id);
1135 getGeometryHandlerIndex (
const std::string &
id);
1142 updateColorHandlerIndex (
const std::string &
id,
int index);
1154 setPointCloudRenderingProperties (
int property,
double val1,
double val2,
double val3,
1155 const std::string &
id =
"cloud",
int viewport = 0);
1166 setPointCloudRenderingProperties (
int property,
double val1,
double val2,
1167 const std::string &
id =
"cloud",
int viewport = 0);
1177 setPointCloudRenderingProperties (
int property,
double value,
1178 const std::string &
id =
"cloud",
int viewport = 0);
1187 getPointCloudRenderingProperties (
int property,
double &value,
1188 const std::string &
id =
"cloud");
1200 getPointCloudRenderingProperties (
RenderingProperties property,
double &val1,
double &val2,
double &val3,
1201 const std::string &
id =
"cloud");
1208 setPointCloudSelected (
const bool selected,
const std::string &
id =
"cloud" );
1219 setShapeRenderingProperties (
int property,
double value,
1220 const std::string &
id,
int viewport = 0);
1231 setShapeRenderingProperties (
int property,
double val1,
double val2,
1232 const std::string &
id,
int viewport = 0);
1244 setShapeRenderingProperties (
int property,
double val1,
double val2,
double val3,
1245 const std::string &
id,
int viewport = 0);
1249 wasStopped ()
const;
1253 resetStoppedFlag ();
1271 createViewPort (
double xmin,
double ymin,
double xmax,
double ymax,
int &viewport);
1277 createViewPortCamera (
const int viewport);
1288 template <
typename Po
intT>
bool
1290 double r,
double g,
double b,
1291 const std::string &
id =
"polygon",
int viewport = 0);
1299 template <
typename Po
intT>
bool
1301 const std::string &
id =
"polygon",
1312 template <
typename Po
intT>
bool
1314 double r,
double g,
double b,
1315 const std::string &
id =
"polygon",
1324 template <
typename P1,
typename P2>
bool
1325 addLine (
const P1 &pt1,
const P2 &pt2,
const std::string &
id =
"line",
1337 template <
typename P1,
typename P2>
bool
1338 addLine (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
1339 const std::string &
id =
"line",
int viewport = 0);
1353 template <
typename P1,
typename P2>
bool
1354 addArrow (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
1355 const std::string &
id =
"arrow",
int viewport = 0);
1370 template <
typename P1,
typename P2>
bool
1371 addArrow (
const P1 &pt1,
const P2 &pt2,
double r,
double g,
double b,
bool display_length,
1372 const std::string &
id =
"arrow",
int viewport = 0);
1389 template <
typename P1,
typename P2>
bool
1390 addArrow (
const P1 &pt1,
const P2 &pt2,
1391 double r_line,
double g_line,
double b_line,
1392 double r_text,
double g_text,
double b_text,
1393 const std::string &
id =
"arrow",
int viewport = 0);
1402 template <
typename Po
intT>
bool
1403 addSphere (
const PointT ¢er,
double radius,
const std::string &
id =
"sphere",
1415 template <
typename Po
intT>
bool
1416 addSphere (
const PointT ¢er,
double radius,
double r,
double g,
double b,
1417 const std::string &
id =
"sphere",
int viewport = 0);
1427 template <
typename Po
intT>
bool
1428 updateSphere (
const PointT ¢er,
double radius,
double r,
double g,
double b,
1429 const std::string &
id =
"sphere");
1438 const std::string &
id =
"PolyData",
1450 const std::string &
id =
"PolyData",
1459 addModelFromPLYFile (
const std::string &filename,
1460 const std::string &
id =
"PLYModel",
1470 addModelFromPLYFile (
const std::string &filename,
1472 const std::string &
id =
"PLYModel",
1503 const std::string &
id =
"cylinder",
1530 const std::string &
id =
"sphere",
1558 const std::string &
id =
"line",
1586 const char *
id =
"line",
1589 return addLine (coefficients, std::string (
id), viewport);
1614 const std::string &
id =
"plane",
1619 const std::string &
id =
"plane",
1642 const std::string &
id =
"circle",
1652 const std::string &
id =
"cone",
1662 const std::string &
id =
"cube",
1675 addCube (
const Eigen::Vector3f &translation,
const Eigen::Quaternionf &rotation,
1676 double width,
double height,
double depth,
1677 const std::string &
id =
"cube",
1694 addCube (
float x_min,
float x_max,
float y_min,
float y_max,
float z_min,
float z_max,
1695 double r = 1.0,
double g = 1.0,
double b = 1.0,
const std::string &
id =
"cube",
int viewport = 0);
1706 addEllipsoid (
const Eigen::Isometry3d &transform,
1707 double radius_x,
double radius_y,
double radius_z,
1708 const std::string &
id =
"ellipsoid",
1713 setRepresentationToSurfaceForAllActors ();
1717 setRepresentationToPointsForAllActors ();
1721 setRepresentationToWireframeForAllActors ();
1727 setShowFPS (
bool show_fps);
1762 renderViewTesselatedSphere (
1765 std::vector<Eigen::Matrix4f,Eigen::aligned_allocator< Eigen::Matrix4f > > & poses, std::vector<float> & enthropies,
int tesselation_level,
1766 float view_angle = 45,
float radius_sphere = 1,
bool use_vertices =
true);
1771 initCameraParameters ();
1778 getCameraParameters (
int argc,
char **argv);
1784 loadCameraParameters (
const std::string &file);
1791 cameraParamsSet ()
const;
1800 cameraFileLoaded ()
const;
1808 getCameraFile ()
const;
1811 PCL_DEPRECATED(1,15,
"updateCamera will be removed, as it does nothing.")
1823 resetCameraViewpoint (
const std::string &
id =
"cloud");
1838 setCameraPosition (
double pos_x,
double pos_y,
double pos_z,
1839 double view_x,
double view_y,
double view_z,
1840 double up_x,
double up_y,
double up_z,
int viewport = 0);
1852 setCameraPosition (
double pos_x,
double pos_y,
double pos_z,
1853 double up_x,
double up_y,
double up_z,
int viewport = 0);
1862 setCameraParameters (
const Eigen::Matrix3f &intrinsics,
const Eigen::Matrix4f &extrinsics,
int viewport = 0);
1869 setCameraParameters (
const Camera &camera,
int viewport = 0);
1877 setCameraClipDistances (
double near,
double far,
int viewport = 0);
1884 setCameraFieldOfView (
double fovy,
int viewport = 0);
1888 getCameras (std::vector<Camera>& cameras);
1893 getViewerPose (
int viewport = 0);
1899 saveScreenshot (
const std::string &file);
1905 saveCameraParameters (
const std::string &file);
1909 getCameraParameters (
Camera &camera,
int viewport = 0)
const;
1929 return (cloud_actor_map_);
1936 return (shape_actor_map_);
1944 setPosition (
int x,
int y);
1951 setSize (
int xw,
int yw);
1959 setUseVbos (
bool use_vbos);
1965 setLookUpTableID (
const std::string
id);
1969 createInteractor ();
1977 setupInteractor (vtkRenderWindowInteractor *iren,
1978 vtkRenderWindow *win);
1987 setupInteractor (vtkRenderWindowInteractor *iren,
1988 vtkRenderWindow *win,
1989 vtkInteractorStyle *style);
2014 void setupRenderWindow (
const std::string& name);
2022 void setDefaultWindowSizeAndPos ();
2030 void setupCamera (
int argc,
char **argv);
2032 struct PCL_EXPORTS ExitMainLoopTimerCallback :
public vtkCommand
2034 static ExitMainLoopTimerCallback* New ()
2036 return (
new ExitMainLoopTimerCallback);
2039 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2045 struct PCL_EXPORTS ExitCallback :
public vtkCommand
2047 static ExitCallback* New ()
2049 return (
new ExitCallback);
2052 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2054 PCLVisualizer* pcl_visualizer;
2058 struct PCL_EXPORTS FPSCallback :
public vtkCommand
2060 static FPSCallback *New () {
return (
new FPSCallback); }
2062 FPSCallback () : actor (), pcl_visualizer (), decimated (), last_fps(0.0f) {}
2063 FPSCallback (
const FPSCallback& src) : vtkCommand (src), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated), last_fps (src.last_fps) {}
2064 FPSCallback& operator = (
const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; last_fps = src.last_fps;
return (*
this); }
2067 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
2069 vtkTextActor *actor;
2070 PCLVisualizer* pcl_visualizer;
2113 bool camera_file_loaded_;
2161 bool use_scalars =
true)
const;
2171 bool use_scalars =
true)
const;
2179 template <
typename Po
intT>
void
2190 template <
typename Po
intT>
void
2191 convertPointCloudToVTKPolyData (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2202 convertPointCloudToVTKPolyData (
const GeometryHandlerConstPtr &geometry_handler,
2217 vtkIdType nr_points);
2229 template <
typename Po
intT>
bool
2230 fromHandlersToScreen (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2231 const PointCloudColorHandler<PointT> &color_handler,
2232 const std::string &
id,
2234 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2235 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2247 template <
typename Po
intT>
bool
2248 fromHandlersToScreen (
const PointCloudGeometryHandler<PointT> &geometry_handler,
2249 const ColorHandlerConstPtr &color_handler,
2250 const std::string &
id,
2252 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2253 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2266 fromHandlersToScreen (
const GeometryHandlerConstPtr &geometry_handler,
2267 const ColorHandlerConstPtr &color_handler,
2268 const std::string &
id,
2270 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2271 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2283 template <
typename Po
intT>
bool
2284 fromHandlersToScreen (
const GeometryHandlerConstPtr &geometry_handler,
2285 const PointCloudColorHandler<PointT> &color_handler,
2286 const std::string &
id,
2288 const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2289 const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2315 getTransformationMatrix (
const Eigen::Vector4f &origin,
2316 const Eigen::Quaternion<float> &orientation,
2317 Eigen::Matrix4f &transformation);
2328 vtkTexture* vtk_tex)
const;
2335 getUniqueCameraFile (
int argc,
char **argv);
2344 convertToVtkMatrix (
const Eigen::Matrix4f &m,
2353 convertToVtkMatrix (
const Eigen::Vector4f &origin,
2354 const Eigen::Quaternion<float> &orientation,
2363 Eigen::Matrix4f &m);
2369 #include <pcl/visualization/impl/pcl_visualizer.hpp>