以下代码展示了如何利用C++与Techlego库执行平面拟合并删除指定平面上的点云:
```cpp
#include "pch.h"
int main()
{
// 创建协议通过IP端口
auto protocol = techlego::create_binary_protocol(L"localhost", 5252);
// 使用协议创建客户端
auto client = techlego::h_scan3d_client::make_shared(protocol);
// 获取底面点云
std::vector<techlego::point3d> points;
auto returns = techlego::read_file(L"D:\\plane.asc", points);
if (returns == nullptr)
{
std::cout << "读取文件成功\n";
}
else
{
std::cout << "读取文件错误\n";
return -1;
}
// 拟合平面并获取平面上的点和法线
techlego::pos6d plane{};
double a = plane.fit_plane(points);
// 执行一次扫描并获取点云
if (!client->scan_and_get_data(points))
{
std::cout << "扫描错误\n";
}
// 将当前点作为平面上的点,点的法线作为平面的法线,删除点云(删除底面)
plane.filter_points_by_plane(points, -50, 5);
// 将删除后的点云替换到指定扫描组
client->replace_scan_data_by_index(0, points, 0);
return 0;
}
```