pcl_wrapper_test/Program.cs

29 lines
928 B
C#
Raw Permalink Normal View History

2025-04-12 18:09:49 +08:00
class Program
2025-04-12 00:43:02 +08:00
{
static void Main()
{
using var cloud = new PclPointCloudXYZ();
2025-04-12 11:37:29 +08:00
cloud.Load("./dataset/0.pcd");
Console.WriteLine("加载点云大小为:" + cloud.Size);
2025-04-12 00:43:02 +08:00
using var voxel = new PclVoxelGridXYZ();
2025-04-12 11:37:29 +08:00
voxel.SetLeafSize(0.1f, 0.1f, 0.1f);
2025-04-12 00:43:02 +08:00
voxel.SetInputCloud(cloud);
using var filtered = voxel.Filter();
Console.WriteLine("体素滤波后点云大小为:" + filtered.Size);
2025-04-12 00:43:02 +08:00
filtered.Save("output.pcd");
2025-04-12 18:09:49 +08:00
using var cloud1 = new PclPointCloudXYZ();
cloud1.Resize(3);
cloud1.SetPoint(0, 0, 0, 0);
cloud1.SetPoint(1, 1, 1, 1);
cloud1.SetPoint(2, 2, 2, 2);
using var kdtree = new PclKdTreeXYZ();
kdtree.SetInputCloud(cloud1);
var (idx, dist) = kdtree.NearestKSearch(0.5f, 0.5f, 0.5f, 2);
Console.WriteLine($"KNN indices: {string.Join(",", idx)}");
2025-04-12 00:43:02 +08:00
}
}