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 srand (time (0));
00010
00011 pcl::PointCloud<Point> cloud;
00012
00013 pcl::PCDReader pcd;
00014 if (pcd.read (argv[1], cloud) == -1)
00015 return (-1);
00016
00017 pcl_visualization::PCLVisualizer p ("test");
00018 p.setBackgroundColor (1, 1, 1);
00019
00020
00021 {
00022 std::cerr << "PointCloudColorHandlerRandom demo." << std::endl;
00023 pcl_visualization::PointCloudColorHandlerRandom<Point> handler (cloud);
00024
00025 p.addPointCloud (cloud, "cloud_random");
00026 p.spin ();
00027 p.removePointCloud ("cloud_random");
00028
00029 p.addPointCloud (cloud, handler, "cloud_random");
00030 p.spin ();
00031 p.removePointCloud ("cloud_random");
00032 }
00033
00034
00035 {
00036 std::cerr << "PointCloudColorHandlerCustom demo." << std::endl;
00037 pcl_visualization::PointCloudColorHandlerCustom<Point> handler (cloud, 255, 0, 0);
00038
00039 p.addPointCloud (cloud, handler);
00040 p.spin ();
00041 p.removePointCloud ();
00042
00043 handler = pcl_visualization::PointCloudColorHandlerCustom<Point> (cloud, 255, 0, 0);
00044 p.addPointCloud (cloud, handler, "cloud");
00045 p.spin ();
00046 p.removePointCloud ("cloud");
00047 }
00048
00049
00050 {
00051 std::cerr << "PointCloudColorHandlerRGBField demo." << std::endl;
00052 pcl_visualization::PointCloudColorHandlerRGBField<Point> handler (cloud);
00053
00054 p.addPointCloud (cloud, handler, "cloud_rgb");
00055 p.spin ();
00056 p.removePointCloud ("cloud_rgb");
00057 }
00058
00059
00060 {
00061 std::cerr << "PointCloudColorHandlerGenericField demo." << std::endl;
00062 pcl_visualization::PointCloudColorHandlerGenericField<Point> handler_z (cloud, "z");
00063 pcl_visualization::PointCloudColorHandlerGenericField<Point> handler_x (cloud, "x");
00064
00065 p.addPointCloud (cloud, handler_x, "cloud_x");
00066 p.spin ();
00067 p.removePointCloud ("cloud_x");
00068
00069 p.addPointCloud (cloud, handler_z, "cloud_z");
00070 p.spin ();
00071 p.removePointCloud ("cloud_z");
00072 }
00073
00074 p.addCoordinateSystem (0.1);
00075
00076
00077 p.resetStoppedFlag();
00078 while (!p.wasStopped())
00079 {
00080 static int counter = 0;
00081 cout << "spinOnce was called "<<++counter<<" times.\n";
00082 p.spinOnce(1000);
00083 }
00084
00085
00086
00087 }