点云平均密度计算
原理:计算输入点与近邻点的平均距离 |
# 代码
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/Point_set_3.h>
#include <vector>
#include <fstream>
#include <boost/tuple/tuple.hpp>
// Types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef CGAL::Point_set_3<Point> Point_set;
typedef boost::tuple<int, Point, int, int, int> IndexedPointWithColorTuple;
typedef CGAL::Parallel_if_available_tag Concurrency_tag;
int main(int argc, char* argv[])
{
Point_set cloud;
CGAL::IO::read_XYZ(argv[1],cloud);
CGAL::IO::write_XYZ("copy_xyz.xyz", cloud);
//计算平均距离
const unsigned int nb_neighbors = 6; //
FT average_spacing = CGAL::compute_average_spacing<Concurrency_tag>(cloud, nb_neighbors, CGAL::parameters::point_map(cloud.point_map()));
std::cout << "Average spacing: " << average_spacing << std::endl;
return EXIT_SUCCESS;
}
结果
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容