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
00034
00035
00036
00037
00038
00039
00040
00041 #include <iostream>
00042 using namespace std;
00043
00044 #include "pcl_visualization/range_image_visualizer.h"
00045
00046 #include <Eigen/Geometry>
00047 #include "pcl/point_cloud.h"
00048 #include "pcl/point_types.h"
00049 #include "pcl/io/pcd_io.h"
00050 #include "pcl/range_image/range_image.h"
00051
00052 using namespace pcl;
00053
00054 typedef PointWithViewpoint PointType;
00055
00056 int
00057 main (int argc, char** argv)
00058 {
00059 pcl::PointCloud<PointType> point_cloud;
00060
00061 bool use_point_cloud_from_file = argc >= 2;
00062 if (use_point_cloud_from_file) {
00063 string fileName = argv[1];
00064 ROS_INFO_STREAM ("Trying to open \""<<fileName<<"\".\n");
00065 if (pcl::io::loadPCDFile(fileName, point_cloud) == -1) {
00066 ROS_ERROR_STREAM("Was not able to open file \""<<fileName<<"\".\n");
00067 use_point_cloud_from_file = false;
00068 }
00069 }
00070 else {
00071 cout << "\n\nUsage: "<<argv[0]<<" <file.pcl> <angular resolution (default 0.5)> <coordinate frame (default 0)>\n\n";
00072 }
00073
00074 if (!use_point_cloud_from_file) {
00075 ROS_INFO_STREAM ("No file given or could not read file => Genarating example point cloud.\n");
00076 for (float y=-0.5f; y<=0.5f; y+=0.01f) {
00077 for (float z=-0.5f; z<=0.5f; z+=0.01f) {
00078 PointType point;
00079 point.x = 2.0f - y;
00080 point.y = y;
00081 point.z = z;
00082 point_cloud.points.push_back(point);
00083 }
00084 }
00085 point_cloud.width = point_cloud.points.size();
00086 point_cloud.height = 1;
00087 }
00088
00089 float angular_resolution = DEG2RAD(0.5f);
00090 if (argc >= 3) {
00091 float tmp_angular_resolution = strtod(argv[2], NULL);
00092 if (tmp_angular_resolution >= 0.1f)
00093 {
00094 cout << "Using angular resolution "<<tmp_angular_resolution<<"deg from command line.\n";
00095 angular_resolution = DEG2RAD(tmp_angular_resolution);
00096 }
00097 }
00098
00099 RangeImage::CoordinateFrame coordinate_frame = RangeImage::CAMERA_FRAME;
00100 if (argc >= 4)
00101 {
00102 coordinate_frame = (RangeImage::CoordinateFrame)strtol(argv[3], NULL, 0);
00103 cout << "Using coordinate frame "<<coordinate_frame<<".\n";
00104 }
00105
00106
00107 float max_angle_width = DEG2RAD(360.0f);
00108 float max_angle_height = DEG2RAD(180.0f);
00109 float noise_level=0.0f;
00110 float min_range = 0.0f;
00111 int border_size = 2;
00112
00113 RangeImage range_image;
00114
00115
00116
00117 range_image.createFromPointCloudWithViewpoints(point_cloud, angular_resolution, max_angle_width, max_angle_height,
00118 coordinate_frame, noise_level, min_range, border_size);
00119
00120 cout << PVARN(range_image);
00121
00122 pcl_visualization::RangeImageVisualizer range_image_widget ("Range Image");
00123 range_image_widget.setRangeImage (range_image);
00124
00125
00126
00127 pcl_visualization::RangeImageVisualizer::spin ();
00128
00129
00130
00131
00132
00133
00134
00135 wxEntryCleanup();
00136
00137 return (0);
00138 }
00139
00140