feat: 测试点云大小的接口和根据索引的访问接口
parent
80c17b89f8
commit
b321f2e9b0
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class PclPointCloudXYZ : IDisposable {
|
||||
|
@ -13,10 +14,15 @@ public class PclPointCloudXYZ : IDisposable {
|
|||
public int Save(string path) => save_pcd_xyz(path,handle);
|
||||
public IntPtr Handle => handle;
|
||||
|
||||
public int Size => get_pointcloud_size(handle);
|
||||
public bool GetPoint(int index, out float x, out float y, out float z) => get_point_xyz(handle, index, out x, out y, out z);
|
||||
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_pointcloud_xyz();
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_pointcloud(IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern bool load_pcd_xyz(string path,IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern int save_pcd_xyz(string path,IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] static extern int get_pointcloud_size(IntPtr cloud);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] static extern bool get_point_xyz(IntPtr cloud, int index, out float x, out float y, out float z);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,11 +37,15 @@ public class PclPointCloudXYZI : IDisposable {
|
|||
public bool Load(string path) => load_pcd_xyzi( path,handle);
|
||||
public int Save(string path) => save_pcd_xyzi(path,handle);
|
||||
public IntPtr Handle => handle;
|
||||
public int Size => get_pointcloud_size(handle);
|
||||
public bool GetPoint(int index, out float x, out float y, out float z, out float intensity) => get_point_xyzi(handle, index, out x, out y, out z, out intensity);
|
||||
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_pointcloud_xyzi();
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_pointcloud(IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern bool load_pcd_xyzi(string path,IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] private static extern int save_pcd_xyzi(string path,IntPtr ptr);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] static extern int get_pointcloud_size(IntPtr cloud);
|
||||
[DllImport("./pcl/libpclwrapper.dylib")] static extern bool get_point_xyzi(IntPtr cloud, int index, out float x, out float y, out float z, out float intensity);
|
||||
}
|
||||
|
||||
public class PclVoxelGridXYZ : IDisposable {
|
||||
|
|
|
@ -7,12 +7,14 @@ class Program
|
|||
{
|
||||
using var cloud = new PclPointCloudXYZ();
|
||||
cloud.Load("./dataset/0.pcd");
|
||||
Console.WriteLine("加载点云大小为:" + cloud.Size);
|
||||
|
||||
using var voxel = new PclVoxelGridXYZ();
|
||||
voxel.SetLeafSize(0.1f, 0.1f, 0.1f);
|
||||
voxel.SetInputCloud(cloud);
|
||||
|
||||
using var filtered = voxel.Filter();
|
||||
Console.WriteLine("体素滤波后点云大小为:" + filtered.Size);
|
||||
filtered.Save("output.pcd");
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue