diff --git a/PclPointCloud.cs b/PclPointCloud.cs index a62f5fa..7d730ec 100644 --- a/PclPointCloud.cs +++ b/PclPointCloud.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Runtime.InteropServices; public class PclPointCloudXYZ : IDisposable { @@ -12,11 +13,16 @@ public class PclPointCloudXYZ : IDisposable { public bool Load(string path) => load_pcd_xyz( path,handle); 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 { diff --git a/Program.cs b/Program.cs index 999538a..a0e76cd 100644 --- a/Program.cs +++ b/Program.cs @@ -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"); } } \ No newline at end of file diff --git a/pcl/libpclwrapper.dylib b/pcl/libpclwrapper.dylib index 5ba3811..ccf9e88 100755 Binary files a/pcl/libpclwrapper.dylib and b/pcl/libpclwrapper.dylib differ