CGAL学习记录——点云密度计算

点云平均密度计算

原理:计算输入点与近邻点的平均距离

# 代码

#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
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片