using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace LB_SmartVisionCameraSDK { //typedef void(__stdcall* PCLPointPickCallback)(double x, double y, double z); /// /// 获取点云中点的回调函数 /// /// x坐标 /// y坐标 /// z坐标 [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void PCLPointPickCallback(double x, double y, double z); //typedef void (__stdcall* ShowParameterCallback) (void* pData, int nSize); /// /// 显示参数信息的回调函数格式,无返回值 /// /// 消息字符串 /// 字符串长度 [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void ShowParameterCallback(IntPtr pData, int nSize); public class PclEntry { /// /// 相对应窗体发送信息 /// /// 对应窗体句柄 /// 指定被寄送的消息 /// 指定附加的消息特定的信息 /// 指定附加的消息特定的信息 /// 如果函数调用成功,返回非零值:如果函数调用失败,返回值是零。 [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr hWnd, uint Msg, ushort wParam, ulong lParam); //PCLAPI(void*) CreatePCLWindow(void* hWnd); /// /// 创建PCL显示实例,返回其句柄 /// /// 为容纳二维显示控件的容器句柄 /// 返回PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "CreatePCLWindow")] public static extern IntPtr CreatePCLWindow(IntPtr hWnd); //PCLAPI(void) DestroyPCLWindow(void* pInstance); /// /// 销毁PCL显示实例,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "DestroyPCLWindow")] public static extern void DestroyPCLWindow(IntPtr pInstance); //PCLAPI(void) ShowPCLWindow(void* pInstance); /// /// 显示PCL实例窗口,无返回值(不使用) /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ShowPCLWindow")] public static extern void ShowPCLWindow(IntPtr pInstance); //PCLAPI(void) HidePCLWindow(void* pInstance); /// /// 隐藏PCL实例窗口,无返回值(不使用) /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "HidePCLWindow")] public static extern void HidePCLWindow(IntPtr pInstance); //PCLAPI(int) LoadPointsFromFile(void* pInstance, const char* szFilename); /// /// 打开点云文件,以pcd、ply或csv为扩展名,加载成功返回点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 待打开的文件名 /// 返回打开的文件中包含的点的个数 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "LoadPointsFromFile")] public static extern int LoadPointsFromFile(IntPtr pInstance, byte[] szFilename); //PCLAPI(int) SavePointsToFile(void* pInstance, const char* szFilename); /// /// 存储点云文件,以pcd、ply或csv为扩展名,保存成功返回点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 待保存的文件名 /// 返回保存的文件中包含的点的个数 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "SavePointsToFile")] public static extern int SavePointsToFile(IntPtr pInstance, byte[] szFilename); // /*********************************************************************** // * 不使用 // ************************************************************************/ // PCLAPI(int) PointCloudToMemery(void* pInstance, unsigned char** buffer, unsigned int* size); // /*********************************************************************** // * 不使用 // ************************************************************************/ // PCLAPI(int) MemeryToPointCloud(void* pInstance, unsigned char** buffer, unsigned int* size); // /*********************************************************************** // * 不使用 // ************************************************************************/ // PCLAPI(int) PointCloudToArray(void* pInstance, void* PointsArray); // /*********************************************************************** // * 不使用 // ************************************************************************/ // PCLAPI(int) ArrayToPointCloud(void* pInstance, void* PointsArray); //PCLAPI(int) AddZPoints(void* pInstance, LBPointZ* points, int nCount); /// /// 向点云实例增加数据点,失败返回-1,否则返回当前点云中点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 包含Z信息的点数据, LBPointZ* points /// 点的数量 /// 失败返回-1,否则返回当前点云中点的个数(不小于0)。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "AddZPoints")] public static extern int AddZPoints(IntPtr pInstance, IntPtr points, int nCount); //PCLAPI(int) AddXZPoints(void* pInstance, LBPointXZ* points, int nCount); /// /// 向点云实例增加数据点,失败返回-1,否则返回当前点云中点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 包含X和Z信息的点数据, LBPointXZ* points /// 点的数量 /// 失败返回-1,否则返回当前点云中点的个数(不小于0)。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "AddXZPoints")] public static extern int AddXZPoints(IntPtr pInstance, IntPtr points, int nCount); //PCLAPI(int) AddZAPoints(void* pInstance, LBPointZA* points, int nCount, float fStepX, float fStepY, int nDownSample); /// /// 向点云实例增加数据点,失败返回-1,否则返回当前点云中点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 包含深度(Z)和强度(A)信息的点数据, LBPointZA* points /// 点的数量 /// x分辨率 /// y分辨率 /// 降采样倍数 /// 失败返回-1,否则返回当前点云中点的个数(不小于0)。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "AddZAPoints")] public static extern int AddZAPoints(IntPtr pInstance, IntPtr points, int nCount, float fStepX, float fStepY, int nDownSample); //PCLAPI(int) AddXYZPoints(void* pInstance, LBPointXYZ* points, int nCount); /// /// 向点云实例增加数据点,失败返回-1,否则返回当前点云中点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 包含X、Y和Z信息的点数据, LBPointXYZ* points /// 点的数量 /// 失败返回-1,否则返回当前点云中点的个数(不小于0)。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "AddXYZPoints")] public static extern int AddXYZPoints(IntPtr pInstance, IntPtr points, int nCount); //PCLAPI(int) AddXYZBGRAPoints(void* pInstance, LBPointXYZBGRA* points, int nCount); /// /// 向点云实例增加数据点,失败返回-1,否则返回当前点云中点的个数(不小于0)。 /// /// PCL显示实例句柄 /// 包含X、Y和Z以及B、G、R和A信息的点数据, LBPointXYZBGRA* points /// 点的数量 /// 失败返回-1,否则返回当前点云中点的个数(不小于0)。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "AddXYZBGRAPoints")] public static extern int AddXYZBGRAPoints(IntPtr pInstance, IntPtr points, int nCount); //PCLAPI(int) ClearPCLPoints(void* pInstance); /// /// 清除点云实例增加数据点内部数据点 /// /// PCL显示实例句柄 /// 失败返回0,成功返回1。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ClearPCLPoints")] public static extern int ClearPCLPoints(IntPtr pInstance); //PCLAPI(int) UpdatePCLPointColors(void* pInstance, const char* szColoring = "z"); /// /// 更新PCL点云数据显示的颜色 /// /// PCL显示实例句柄 /// W,B,r,g,b,x,y,z 对应于白黑红绿蓝和xyz三轴 /// 失败返回0,成功返回1。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "UpdatePCLPointColors", CharSet = CharSet.Ansi)] public static extern int UpdatePCLPointColors(IntPtr pInstance, string szColoring = "z"); //PCLAPI(int) GetPointCloudBound(void* pInstance, double* pMin, double* pMax); /// /// 获取PCL点云数据的范围 /// /// PCL显示实例句柄 /// 返回最小值 /// 返回最大值 /// 失败返回0,成功返回1。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "GetPointCloudBound")] public static extern int GetPointCloudBound(IntPtr pInstance, ref double pMin, ref double pMax); //PCLAPI(int) SetPointCloudBound(void* pInstance, double* pMin, double* pMax); /// /// 设置PCL点云数据的范围 /// /// PCL显示实例句柄 /// 输入最小值, double* pMin /// 输入最大值, double* pMax /// 失败返回0,成功返回1。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "SetPointCloudBound")] public static extern int SetPointCloudBound(IntPtr pInstance, IntPtr pMin, IntPtr pMax); //PCLAPI(int) ResizePCLWindow(void* pInstance, int nWidth, int nHeight); /// /// 调整显示点云窗口的大小 /// /// PCL显示实例句柄 /// 窗口宽度 /// 窗口高度 /// 失败返回0,成功返回1。 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ResizePCLWindow")] public static extern int ResizePCLWindow(IntPtr pInstance, int nWidth, int nHeight); //PCLAPI(void) RenderPCLWindow(void* pInstance, int nWidth, int nHeight); /// /// 渲染点云窗口,无返回 /// /// PCL显示实例句柄 /// 窗口宽度 /// 窗口高度 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "RenderPCLWindow")] public static extern void RenderPCLWindow(IntPtr pInstance, int nWidth, int nHeight); //PCLAPI(void) ShowCubeAxes(void* pInstance, int bInit = 0); /// /// 显示正方体坐标系,无返回 /// /// PCL显示实例句柄 /// 是否初始化 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ShowCubeAxes")] public static extern void ShowCubeAxes(IntPtr pInstance, int bInit = 0); //PCLAPI(void) HideCubeAxes(void* pInstance); /// /// 隐藏正方体坐标系,无返回 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "HideCubeAxes")] public static extern void HideCubeAxes(IntPtr pInstance); //PCLAPI(void) ShowAxes(void* pInstance); /// /// 在左下角显示坐标系,无返回 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ShowAxes")] public static extern void ShowAxes(IntPtr pInstance); //PCLAPI(void) HideAxes(void* pInstance); /// /// 隐藏在左下角坐标系,无返回 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "HideAxes")] public static extern void HideAxes(IntPtr pInstance); //PCLAPI(void) ShowLookUpTable(void* pInstance, double x = 0.9, double y = 0.0, double xWide = 0.08, double yWide = 0.35); /// /// 显示颜色表 /// /// PCL显示实例句柄 /// 显示位置,数值是与窗口宽度的比值 /// 显示位置,数值是与窗口高度的比值 /// 水平宽度,数值是与窗口宽度的比值 /// 垂直宽度,数值是与窗口高度的比值 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "ShowLookUpTable")] public static extern void ShowLookUpTable(IntPtr pInstance, double x = 0.9, double y = 0.0, double xWide = 0.08, double yWide = 0.35); //PCLAPI(void) HideLookUpTable(void* pInstance); /// /// 隐藏颜色表,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "HideLookUpTable")] public static extern void HideLookUpTable(IntPtr pInstance); //PCLAPI(void) SetLookUpTableRange(void* pInstance, double fMin, double fMax); /// /// 设置颜色表范围,无返回值 /// /// PCL显示实例句柄 /// 最小值 /// 最大值 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "SetLookUpTableRange")] public static extern void SetLookUpTableRange(IntPtr pInstance, double fMin, double fMax); //PCLAPI(void) InsertBox(void* pInstance); /// /// 插入盒子,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "InsertBox")] public static extern void InsertBox(IntPtr pInstance); //PCLAPI(void) InsertSphere(void* pInstance); /// /// 插入球体,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "InsertSphere")] public static extern void InsertSphere(IntPtr pInstance); //PCLAPI(void) InsertRule(void* pInstance); /// /// 插入标尺,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "InsertRule")] public static extern void InsertRule(IntPtr pInstance); //PCLAPI(void) InsertPlane(void* pInstance); /// /// 插入平面,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "InsertPlane")] public static extern void InsertPlane(IntPtr pInstance); //PCLAPI(void) InsertText(void* pInstance, char* szText); /// /// 插入文字,无返回值 /// /// PCL显示实例句柄 /// 插入文字 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "InsertText", CharSet = CharSet.Ansi)] public static extern void InsertText(IntPtr pInstance, string szText); //PCLAPI(void) DeleteWidget(void* pInstance); /// /// 删除部件,盒子、球体等都是部件,无返回值 /// /// PCL显示实例句柄 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "DeleteWidget")] public static extern void DeleteWidget(IntPtr pInstance); //PCLAPI(void) RegisterShowParameter(void* pInstance, ShowParameterCallback callback); /// /// 注册显示参数的函数,无返回值 /// /// PCL显示实例句柄 /// 待注册的回调函数 [DllImport("PointCloud3D", CallingConvention = CallingConvention.StdCall, EntryPoint = "RegisterShowParameter")] public static extern void RegisterShowParameter(IntPtr pInstance, ShowParameterCallback callback); } }