VS+ QT(一)使用CGAL实现点云分类

本文详细介绍了使用CGAL库进行点云数据处理和分类的步骤,包括依赖库的添加、点云读取、预处理、特征计算、标签定义、权重设置、分类算法以及标签颜色信息转换和点云保存。通过对点云数据进行预处理和特征提取,使用不同的分类方法,实现了对点云数据的高效分类。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、依赖的添加

1、附加包含文件目录

$(CGAL)\include
$(CGAL)\auxiliary\gmp\include

$(CGAL)代表CGAL的文件夹地址
例如我的是:($(SolutionDir)为解决方案文件夹目录)
$(SolutionDir)…\dependences\cgal\include;
$(SolutionDir)…\dependences\cgal\auxiliary\gmp\include;
附加包含目录

2、附加包含库文件目录

$(CGAL)\auxiliary\gmp\lib;

同上
库目录

3、附加包含库文件

libmpfr-4.lib;libgmp-10.lib;

在这里插入图片描述

4、头文件

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Classification.h> //分类
#include <CGAL/bounding_box.h> //生成包含点云的矩形(平行于坐标轴)
#include <CGAL/tags.h>

#include <CGAL/IO/read_points.h> //读写ply文件
#include <CGAL/IO/write_ply_points.h>

#include <CGAL/Real_timer.h>//用于计算运行时间

#include <lasreader.hpp>
#include <laswriter.hpp> //LASTools读取文件

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>

二、代码

1、类名定义

typedef CGAL::Parallel_if_available_tag Concurrency_tag;

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Iso_cuboid_3 Iso_cuboid_3;
typedef Kernel::Point_3 Point;
typedef std::vector<Point> Point_range;
typedef CGAL::Identity_property_map<Point> Pmap; //将 property map 映射到自身的属性映射(通过引用)

namespace Classification = CGAL::Classification;
typedef Classification::Sum_of_weighted_features_classifier Classifier;
typedef Classification::Planimetric_grid<Kernel, Point_range, Pmap>             Planimetric_grid;
typedef Classification::Point_set_neighborhood<Kernel, Point_range, Pmap>       Neighborhood;
typedef Classification::Local_eigen_analysis                                    Local_eigen_analysis;
typedef Classification::Label_handle                                            Label_handle;
typedef Classification::Feature_handle                                          Feature_handle;
typedef Classification::Label_set                                               Label_set;
typedef Classification::Feature_set                                             Feature_set;
typedef Classification::Feature::Distance_to_plane<Point_range, Pmap>           Distance_to_plane;
typedef Classification::Feature::Elevation<Kernel, Point_range, Pmap>           Elevation;
typedef Classification::Feature::Vertical_dispersion<Kernel, Point_range, Pmap> Dispersion;

重新定义类名,减少后续的代码量

2、点云读取

//点云读取
LASreadOpener lasreadopener;

cout << "read File " << Path << endl;
l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值