以下代碼展示了如何利用C++與Techlego庫執(zhí)行平面擬合并刪除指定平面上的點云:
```cpp
#include "pch.h"
int main()
{
// 創(chuàng)建協(xié)議通過IP端口
auto protocol = techlego::create_binary_protocol(L"localhost", 5252);
// 使用協(xié)議創(chuàng)建客戶端
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);
// 執(zhí)行一次掃描并獲取點云
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;
}
```