当前位置: 首页>>代码示例>>C++>>正文


C++ Segmentation::segment方法代码示例

本文整理汇总了C++中Segmentation::segment方法的典型用法代码示例。如果您正苦于以下问题:C++ Segmentation::segment方法的具体用法?C++ Segmentation::segment怎么用?C++ Segmentation::segment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Segmentation的用法示例。


在下文中一共展示了Segmentation::segment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) 
{
	pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
	pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloudFiltered (new pcl::PointCloud<pcl::PointXYZRGBA>);
	
	int k=atoi(argv[1]);
	double min_mah_dist=atof(argv[2]);
	int max_gauss=atoi(argv[3]);
	
	std::vector <Gauss> gaussians_learned;

	pcl::PCDReader reader;
	reader.read (argv[4], *cloud); 
	
	pcl::console::TicToc timer;
	
	timer.tic();
	
	// Filtering
	Filtering filtering;
	cloudFiltered=filtering.filter(cloud);
	
	// Segmentation
	Segmentation segmentation;
	std::vector <Surface> surfaces=segmentation.segment (cloudFiltered);
	
	// Colour extraction from point cloud
	ExtractColour extractcolour;
	cv::Mat samples=extractcolour.pcd2colourRGB(surfaces[0].segmented_cloud);
	
	// Point cloud analysis
	ColourAnalysis colouranalysis;
	std::vector <Gauss> gaussians = colouranalysis.analyzeColourCluster(k, surfaces[0].segmented_cloud, surfaces[0].b, surfaces[0].d, samples);
	
	// Learning
	Learning learning;
	gaussians_learned=learning.learnGaussians(gaussians, gaussians_learned, max_gauss);
	
	// ROI
	ROI roi;
	std::vector<Line> lines=roi.roi(surfaces);
	std::vector<int> index=roi.extractIndex(lines);
	
	// Colour extraction from image
	std::vector<Matrix_double> colours=extractcolour.indexPCD2VectorRGB(*cloud, index);
	
	// Image analysis
	std::vector <int> pixels_labeled=colouranalysis.labelIndex(colours, k, gaussians_learned, min_mah_dist);
	
	// Map reconstruction
	Map map;
	std::vector<Matrix_double> distancesLabeled=map.mapDistances(index, surfaces[0].a ,surfaces[0].b, surfaces[0].c, surfaces[0].d);
	
	std::cout << "Part 1 finished" << std::endl;
	timer.toc_print();
	
	timer.tic();
	// Generate image
	cv::Mat environment=extractcolour.pcd2image(*cloud);
	
	// Calcule begin and end points for a line
	std::vector <LinePoint> linePoints=roi.calculeLinePoints(lines);
	
	// Draw lines
	Visualize visualize;
	environment=visualize.drawLines (environment, linePoints, "green");
	
	// Print floor
	std::vector<int> pixels=colouranalysis.labelPixel(pixels_labeled, index, colours);
	environment=visualize.drawFloor (pixels, environment, "cyan");
	
	std::vector <int> kinectIndex=roi.extractFloorIdx(surfaces[0].a, surfaces[0].b, surfaces[0].c, surfaces[0].d, cloud);
	environment=visualize.drawFloor (kinectIndex, environment, "blue");
	
	// Reconstruct kinect floor
	std::vector <int> kinect (kinectIndex.size(), 1);
	std::vector<Matrix_double> distancesKinect=map.mapDistances(kinectIndex, surfaces[0].a ,surfaces[0].b, surfaces[0].c, surfaces[0].d);
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloudEnhanced=map.mapEnhance(distancesLabeled, index, cloud, pixels_labeled, surfaces[0].a ,surfaces[0].b, surfaces[0].c, surfaces[0].d);
	
	// Generate map reconstruction image
	cv::Mat map_reconstruction(cv::Size(400,650),CV_8UC3);
	map_reconstruction=cv::Scalar(0,0,0);
	map_reconstruction=visualize.mapGeneration(map_reconstruction, pixels_labeled, distancesLabeled, "blue", "white");
	map_reconstruction=visualize.mapGeneration(map_reconstruction, kinect, distancesKinect, "red", "yellow");
	
	// Show images on a window
	std::string name_window="Floor window";
    visualize.visualizeImage (environment, name_window);
	name_window="Map window";
    visualize.visualizeImage (map_reconstruction, name_window);
    visualize.visualizeCloud(cloudEnhanced, "Cloud");
	
	// Save images
	Save save;
	char name[50]="map.png";
	save.saveImage(map_reconstruction, name);
	char name2[50]="environment.png";
	save.saveImage(environment, name2);
	
	// Save cloud
//.........这里部分代码省略.........
开发者ID:caomw,项目名称:FloorReconstruction,代码行数:101,代码来源:main.cpp


注:本文中的Segmentation::segment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。