pcl_wrapper_test/PclPointCloud.cs

88 lines
5.0 KiB
C#

using System;
using System.Drawing;
using System.Runtime.InteropServices;
public class PclPointCloudXYZ : IDisposable {
private IntPtr handle;
public PclPointCloudXYZ() => handle = create_pointcloud_xyz();
// 构造函数用于内部封装 handle 对象
public PclPointCloudXYZ(IntPtr handle) => this.handle = handle;
public void Dispose() { delete_pointcloud(handle); handle = IntPtr.Zero; }
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);
}
public class PclPointCloudXYZI : IDisposable {
private IntPtr handle;
public PclPointCloudXYZI() => handle = create_pointcloud_xyzi();
// 构造函数用于内部封装 handle 对象
public PclPointCloudXYZI(IntPtr handle) => this.handle = handle;
public void Dispose() { delete_pointcloud(handle); handle = IntPtr.Zero; }
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 {
private IntPtr handle;
public PclVoxelGridXYZ() => handle = create_voxel_filter_xyz();
public void Dispose() { delete_voxel_filter(handle); handle = IntPtr.Zero; }
public void SetLeafSize(float x, float y, float z) => set_voxel_leaf_size(handle, x, y, z);
public void SetInputCloud(PclPointCloudXYZ cloud) => set_voxel_input_cloud(handle, cloud.Handle);
public PclPointCloudXYZ Filter() => new PclPointCloudXYZ(apply_voxel_filter_xyz(handle));
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_voxel_filter_xyz();
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_voxel_filter(IntPtr ptr);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_leaf_size(IntPtr ptr, float x, float y, float z);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_input_cloud(IntPtr filterPtr, IntPtr cloudPtr);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr apply_voxel_filter_xyz(IntPtr filterPtr);
}
public class PclVoxelGridXYZI : IDisposable {
private IntPtr handle;
public PclVoxelGridXYZI() => handle = create_voxel_filter_xyzi();
public void Dispose() { delete_voxel_filter(handle); handle = IntPtr.Zero; }
public void SetLeafSize(float x, float y, float z) => set_voxel_leaf_size(handle, x, y, z);
public void SetInputCloud(PclPointCloudXYZI cloud) => set_voxel_input_cloud(handle, cloud.Handle);
public PclPointCloudXYZI Filter() => new PclPointCloudXYZI(apply_voxel_filter_xyzi(handle));
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_voxel_filter_xyzi();
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_voxel_filter(IntPtr ptr);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_leaf_size(IntPtr ptr, float x, float y, float z);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_input_cloud(IntPtr filterPtr, IntPtr cloudPtr);
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr apply_voxel_filter_xyzi(IntPtr filterPtr);
}