Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "ros/ros.h"
00034
00035
00036 #include "terminal_tools/parse.h"
00037
00038
00039 #include "pcl/io/pcd_io.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include "pcl_visualization/pcl_visualizer.h"
00051
00052
00053
00054
00055 typedef pcl::PointXYZ PointT;
00056
00057
00058
00059
00060 bool step = false;
00061 bool clean = false;
00062 bool verbose = false;
00063 int size_of_hull = 10;
00064 int size_of_projected = 1;
00065
00066
00067
00069
00071 int main (int argc, char** argv)
00072 {
00073
00074
00075
00076
00077
00078
00079 if (argc < 2)
00080 {
00081 ROS_INFO (" ");
00082 ROS_INFO ("Syntax is: %s <input>.pcd <options>", argv[0]);
00083 ROS_INFO (" where <options> are: ");
00084 ROS_INFO (" -step B = wait or not wait");
00085 ROS_INFO (" -clean B = remove or not remove");
00086 ROS_INFO (" -verbose B = display step by step info");
00087 ROS_INFO (" -size_of_hull D = set the size of hull points");
00088 ROS_INFO (" -size_of_projected D = set the size of projected points");
00089 ROS_INFO (" ");
00090 return (-1);
00091 }
00092
00093
00094 std::vector<int> pFileIndicesPCD = terminal_tools::parse_file_extension_argument (argc, argv, ".pcd");
00095 if (pFileIndicesPCD.size () == 0)
00096 {
00097 ROS_ERROR ("No .pcd files given as input !");
00098 return (-1);
00099 }
00100
00101
00102 terminal_tools::parse_argument (argc, argv, "-step", step);
00103 terminal_tools::parse_argument (argc, argv, "-clean", clean);
00104 terminal_tools::parse_argument (argc, argv, "-verbose", verbose);
00105 terminal_tools::parse_argument (argc, argv, "-size_of_hull", size_of_hull);
00106 terminal_tools::parse_argument (argc, argv, "-size_of_projected", size_of_projected);
00107
00108
00109
00110
00111
00112
00113 srand (time(0));
00114
00115
00116 ros::Time::init();
00117
00118
00119 terminal_tools::TicToc tt;
00120
00121
00122 tt.tic ();
00123
00124 if ( verbose )
00125 {
00126
00127 ROS_WARN ("Timer started !");
00128 }
00129
00130
00131
00132
00133
00134
00135 pcl_visualization::PCLVisualizer viewer ("3D VIEWER");
00136
00137 viewer.setBackgroundColor (1.0, 1.0, 1.0);
00138
00139 viewer.getCameraParameters (argc, argv);
00140
00141 viewer.updateCamera ();
00142
00143
00144
00145
00146
00147
00148 pcl::PointCloud<PointT>::Ptr cloud_of_projected (new pcl::PointCloud<PointT> ());
00149
00150
00151 pcl::PointCloud<PointT>::Ptr cloud_of_hull (new pcl::PointCloud<PointT> ());
00152
00153
00154 std::vector<pcl::PointCloud<PointT>::Ptr> vector_of_projected;
00155
00156
00157 std::vector<pcl::PointCloud<PointT>::Ptr> vector_of_hull;
00158
00159 for (int cloud = 0; cloud < (int) pFileIndicesPCD.size (); cloud++)
00160 {
00161
00162 std::string file = argv [pFileIndicesPCD [cloud]];
00163
00164 if ( ( (int) file.find ("projected") != -1 ) || ( (int) file.find ("hull") != -1 ) )
00165 {
00166
00167 pcl::PointCloud<PointT>::Ptr input (new pcl::PointCloud<PointT> ());
00168
00169
00170 if (pcl::io::loadPCDFile (argv [pFileIndicesPCD [cloud]], *input) == -1)
00171 {
00172 ROS_ERROR ("Couldn't read file %s", argv [pFileIndicesPCD [cloud]]);
00173 return (-1);
00174 }
00175 ROS_INFO ("Loaded %5d data points from %s with the following fields: %s", (int) (input->points.size ()), argv [pFileIndicesPCD [cloud]], pcl::getFieldsList (*input).c_str ());
00176
00177 if ( (int) file.find ("projected") != -1 )
00178 {
00179
00180 *cloud_of_projected += *input;
00181
00182
00183 vector_of_projected.push_back (input);
00184 }
00185 else if ( (int) file.find ("hull") != -1 )
00186 {
00187
00188 *cloud_of_hull += *input;
00189
00190
00191 vector_of_hull.push_back (input);
00192 }
00193 }
00194 }
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00220
00221 for (int cloud = 0; cloud < (int) vector_of_projected.size (); cloud++)
00222 {
00223
00224 std::stringstream id_of_projected;
00225 id_of_projected << "PROJECTED_" << ros::Time::now();
00226
00227
00228 viewer.addPointCloud (*vector_of_projected.at (cloud), id_of_projected.str());
00229
00230
00231 viewer.setPointCloudRenderingProperties (pcl_visualization::PCL_VISUALIZER_POINT_SIZE, size_of_projected, id_of_projected.str());
00232
00233 }
00234
00235
00236 if ( step )
00237 {
00238
00239 viewer.spin ();
00240 }
00241
00242
00243
00245
00246
00247 viewer.addPointCloud (*cloud_of_hull, "HULL");
00248
00249
00250 viewer.setPointCloudRenderingProperties (pcl_visualization::PCL_VISUALIZER_COLOR, 0.0, 0.0, 0.0, "HULL");
00251
00252
00253 viewer.setPointCloudRenderingProperties (pcl_visualization::PCL_VISUALIZER_POINT_SIZE, size_of_hull, "HULL");
00254
00255
00256 if ( step )
00257 {
00258
00259 viewer.spin ();
00260 }
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 if ( verbose )
00290 {
00291
00292 ROS_WARN ("Finished in %5.3g [s] !", tt.toc ());
00293 }
00294
00295 return (0);
00296 }