Go to the documentation of this file.00001 #include <pcl/visualization/pcl_visualizer.h>
00002 #include <pcl/io/pcd_io.h>
00003
00004 typedef pcl::PointXYZRGB Point;
00005
00006 int
00007 main (int argc, char **argv)
00008 {
00009 if (argc < 2)
00010 {
00011 std::cerr << "Needs a PCD file as input." << std::endl;
00012 return (-1);
00013 }
00014
00015 srand (time (0));
00016
00017 pcl::PointCloud<Point>::Ptr cloud (new pcl::PointCloud<Point>);
00018
00019 pcl::PCDReader pcd;
00020 if (pcd.read (argv[1], *cloud) == -1)
00021 return (-1);
00022
00023 pcl::visualization::PCLVisualizer p ("test");
00024 p.setBackgroundColor (1, 1, 1);
00025
00026
00027 {
00028 std::cerr << "PointCloudColorHandlerRandom demo." << std::endl;
00029 pcl::visualization::PointCloudColorHandlerRandom<Point> handler (cloud);
00030
00031 p.addPointCloud<Point> (cloud, "cloud_random");
00032 p.spin ();
00033 p.removePointCloud ("cloud_random");
00034
00035 p.addPointCloud (cloud, handler, "cloud_random");
00036 p.spin ();
00037 p.removePointCloud ("cloud_random");
00038 }
00039
00040
00041 {
00042 std::cerr << "PointCloudColorHandlerCustom demo." << std::endl;
00043 pcl::visualization::PointCloudColorHandlerCustom<Point> handler (cloud, 255, 0, 0);
00044
00045 p.addPointCloud (cloud, handler);
00046 p.spin ();
00047 p.removePointCloud ();
00048
00049 handler = pcl::visualization::PointCloudColorHandlerCustom<Point> (cloud, 255, 0, 0);
00050 p.addPointCloud (cloud, handler, "cloud");
00051 p.spin ();
00052 p.removePointCloud ("cloud");
00053 }
00054
00055
00056 {
00057 std::cerr << "PointCloudColorHandlerRGBField demo." << std::endl;
00058 pcl::visualization::PointCloudColorHandlerRGBField<Point> handler (cloud);
00059
00060 p.addPointCloud (cloud, handler, "cloud_rgb");
00061 p.spin ();
00062 p.removePointCloud ("cloud_rgb");
00063 }
00064
00065
00066 {
00067 std::cerr << "PointCloudColorHandlerGenericField demo." << std::endl;
00068 pcl::visualization::PointCloudColorHandlerGenericField<Point> handler_z (cloud, "z");
00069 pcl::visualization::PointCloudColorHandlerGenericField<Point> handler_x (cloud, "x");
00070
00071 p.addPointCloud (cloud, handler_x, "cloud_x");
00072 p.spin ();
00073 p.removePointCloud ("cloud_x");
00074
00075 p.addPointCloud (cloud, handler_z, "cloud_z");
00076 p.spin ();
00077 p.removePointCloud ("cloud_z");
00078 }
00079
00080 p.addCoordinateSystem (0.1);
00081
00082
00083 p.resetStoppedFlag();
00084 while (!p.wasStopped())
00085 {
00086 static int counter = 0;
00087 cout << "spinOnce was called "<<++counter<<" times.\n";
00088 p.spinOnce(1000);
00089 }
00090
00091
00092
00093 }