cloud_viewer.cpp
Go to the documentation of this file.
00001 #include <pcl/visualization/cloud_viewer.h>
00002 #include <iostream>
00003 #include <pcl/io/io.h>
00004 #include <pcl/io/pcd_io.h>
00005     
00006 int user_data;
00007     
00008 void 
00009 viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
00010 {
00011     viewer.setBackgroundColor (1.0, 0.5, 1.0);
00012     pcl::PointXYZ o;
00013     o.x = 1.0;
00014     o.y = 0;
00015     o.z = 0;
00016     viewer.addSphere (o, 0.25, "sphere", 0);
00017     std::cout << "i only run once" << std::endl;
00018     
00019 }
00020     
00021 void 
00022 viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
00023 {
00024     static unsigned count = 0;
00025     std::stringstream ss;
00026     ss << "Once per viewer loop: " << count++;
00027     viewer.removeShape ("text", 0);
00028     viewer.addText (ss.str(), 200, 300, "text", 0);
00029     
00030     //FIXME: possible race condition here:
00031     user_data++;
00032 }
00033     
00034 int 
00035 main ()
00036 {
00037     pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
00038     pcl::io::loadPCDFile ("my_point_cloud.pcd", *cloud);
00039     
00040     pcl::visualization::CloudViewer viewer("Cloud Viewer");
00041     
00042     //blocks until the cloud is actually rendered
00043     viewer.showCloud(cloud);
00044     
00045     //use the following functions to get access to the underlying more advanced/powerful
00046     //PCLVisualizer
00047     
00048     //This will only get called once
00049     viewer.runOnVisualizationThreadOnce (viewerOneOff);
00050     
00051     //This will get called once per visualization iteration
00052     viewer.runOnVisualizationThread (viewerPsycho);
00053     while (!viewer.wasStopped ())
00054     {
00055     //you can also do cool processing here
00056     //FIXME: Note that this is running in a separate thread from viewerPsycho
00057     //and you should guard against race conditions yourself...
00058     user_data++;
00059     }
00060     return 0;
00061 }


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:14:40