Voxelgrid voxel Filter for the next sampling of point clouds

Source: Internet
Author: User

Using the Voxel grid method to achieve the next sampling, that is to reduce the number of points, reduce the point cloud data, while maintaining the shape of the point cloud features, in the improvement of registration, surface reconstruction, shape recognition algorithm speed is very practical.

The PCL -implemented Voxelgrid class creates a three-dimensional voxel raster from the input point cloud data (the voxel raster can be imagined as a collection of tiny three-dimensional cubes), and then within each voxel (i.e., three-dimensional cube), A bit of gravity in the voxel to approximate the other points in the voxel, so that the voxel in all points in the body with a center of gravity point of the final expression, for all voxel processing after the filtered point cloud. This method is slower than the method used to approximate the Voxel center, but it is more accurate for the representation of the corresponding surface of the sample point.

Therefore, this class is often used for the lower sampling processing of large data, especially in pre-registration and surface reconstruction, which can improve the program speed well.

Code:

#include <iostream>#include<pcl/io/pcd_io.h>#include<pcl/point_types.h>#include<pcl/filters/voxel_grid.h>#include<pcl/io/io.h>#include<pcl/visualization/cloud_viewer.h>intMainintargcChar**argv) {PCL::P ointcloud&LT;PCL::P ointxyzi>::P TR Cloud (NewPCL::P OINTCLOUD&LT;PCL::P ointxyzi>); PCL::P Ointcloud&LT;PCL::P ointxyzi>::P tr cloud_filtered (NewPCL::P OINTCLOUD&LT;PCL::P ointxyzi>); //fill in point cloud dataPcl::io::loadpcdfile ("TABLE_SCENE_LMS400.PCD", *cloud); //Creating Filter ObjectsPCL::VOXELGRID&LT;PCL::P ointxyzi> sor;//Filter Processing ObjectsSor.setinputcloud (Cloud); Sor.setleafsize (0.01f,0.01f,0.01f);//parameters for setting the Voxel size used in filter processingSor.filter (*cloud_filtered); Std::cerr<<"Pointcloud after filtering:"<< Cloud_filtered->width * cloud_filtered->Height<<"Data points ("<< pcl::getfieldslist (*cloud_filtered) <<")."; Pcl::visualization::cloudviewer Viewer ("Cloud Viewer"); //The Showcloud function is synchronous, waiting here until the rendering is displayedViewer.showcloud (cloud_filtered);  while(!viewer.wasstopped ()) {        //Here you can add additional processing            }    return(0);}

Although the amount of data after processing is greatly reduced, it is obvious that the shape characteristics and spatial structure information are almost the same as the original point cloud.

Voxelgrid voxel Filter for the next sampling of point clouds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.