00001 00059 #include "cob_3d_features/segmentation.h" 00060 #include <pcl/io/pcd_io.h> 00061 #include <highgui.h> 00062 00063 int main() 00064 { 00065 cob_3d_features::Segmentation seg; 00066 pcl::PointCloud<PointLabel>::Ptr cloud_in = pcl::PointCloud<PointLabel>::Ptr (new pcl::PointCloud<PointLabel>); 00067 cv::Mat seg_img; 00068 std::vector<pcl::PointIndices> cluster_indices; 00069 /*cloud_in->points.resize(900); 00070 cloud_in->width = 30; 00071 cloud_in->height = 30; 00072 for(unsigned int i=0; i<30; i++) 00073 { 00074 for(unsigned int j=0; j<30; j++) 00075 { 00076 cloud_in->points[i*30+j].label = 0; 00077 if(i<14 && j==14) cloud_in->points[i*30+j].label = 1; 00078 if(i>16 && j==14) cloud_in->points[i*30+j].label = 1; 00079 } 00080 } 00081 //pcl::io::loadPCDFile("/home/goa/pcl_daten/corner/output/edge_cloud.pcd",*cloud_in); 00082 seg.propagateWavefront2(cloud_in); 00083 seg.getClusterIndices(cloud_in, cluster_indices, seg_img); 00084 cv::imshow("seg",seg_img); 00085 00086 for(unsigned int i=0; i<30; i++) 00087 { 00088 for(unsigned int j=0; j<30; j++) 00089 { 00090 cloud_in->points[i*30+j].label = 0; 00091 if(j<14 && i==14) cloud_in->points[i*30+j].label = 1; 00092 if(j>16 && i==14) cloud_in->points[i*30+j].label = 1; 00093 } 00094 } 00095 //pcl::io::loadPCDFile("/home/goa/pcl_daten/corner/output/edge_cloud.pcd",*cloud_in); 00096 seg.propagateWavefront2(cloud_in); 00097 seg.getClusterIndices(cloud_in, cluster_indices, seg_img); 00098 cv::imshow("seg2",seg_img); 00099 00100 for(unsigned int i=0; i<30; i++) 00101 { 00102 for(unsigned int j=0; j<30; j++) 00103 { 00104 cloud_in->points[i*30+j].label = 0; 00105 if(i<14 && j==14) cloud_in->points[i*30+j].label = 1; 00106 if(i>16 && j==15) cloud_in->points[i*30+j].label = 1; 00107 } 00108 } 00109 //pcl::io::loadPCDFile("/home/goa/pcl_daten/corner/output/edge_cloud.pcd",*cloud_in); 00110 seg.propagateWavefront2(cloud_in); 00111 seg.getClusterIndices(cloud_in, cluster_indices, seg_img); 00112 cv::imshow("seg3",seg_img); 00113 00114 for(unsigned int i=0; i<30; i++) 00115 { 00116 for(unsigned int j=0; j<30; j++) 00117 { 00118 cloud_in->points[i*30+j].label = 0; 00119 if(i<14 && j==14) cloud_in->points[i*30+j].label = 1; 00120 } 00121 } 00122 //pcl::io::loadPCDFile("/home/goa/pcl_daten/corner/output/edge_cloud.pcd",*cloud_in); 00123 seg.propagateWavefront2(cloud_in); 00124 seg.getClusterIndices(cloud_in, cluster_indices, seg_img); 00125 cv::imshow("seg4",seg_img);*/ 00126 00127 pcl::io::loadPCDFile("/home/goa/pcl_daten/corner/output/edge_cloud.pcd",*cloud_in); 00128 pcl::PointCloud<PointLabel>::Ptr cloud_in_c = pcl::PointCloud<PointLabel>::Ptr (new pcl::PointCloud<PointLabel>); 00129 for(unsigned int i=0; i<cloud_in->points.size(); i++) 00130 { 00131 if(i>=64000) 00132 { 00133 cloud_in_c->points.push_back(cloud_in->points[i]); 00134 } 00135 } 00136 cloud_in_c->width = 640; 00137 cloud_in_c->height = 380; 00138 seg.propagateWavefront2(cloud_in_c); 00139 seg.getClusterIndices(cloud_in_c, cluster_indices, seg_img); 00140 cv::imshow("seg_real",seg_img); 00141 00142 cv::waitKey(); 00143 return 0; 00144 }