API 接口目录
Xvisio SDK 文档主页

平面检测接口


1. 开启tof

public static extern void xslam_tof_set_framerate(float framerate);

Input:

framerate 每秒tof检测速度,一般设置成5,表示5秒一次

2. 开启平面检测

public static extern bool xslam_start_detect_plane_from_tof_nosurface();

3. 平面检测获取数据接口

public static extern bool xslam_get_plane_from_tof(IntPtr data, ref int len);

Input:

data 数据地址指针
len 数据长度

数据解析参考:

public  plane[] parsePlane(byte[] rdata, int len)
    {
        if (len < 4)
            return null;
        int pos = 0;
        int nPlane = System.BitConverter.ToInt32(rdata, pos); pos += 4;
        if (nPlane > 0 && len > pos)
        {
            planes = new plane[nPlane];
            for (int i = 0; i < nPlane; i++)
            {
                if (len <= pos)
                    break;
                planes[i] = new plane();
                int nPoint = System.BitConverter.ToInt32(rdata, pos); pos += 4;
                planes[i].points = new List<Vector3D>();
                for (int j = 0; j < nPoint; j++)
                {
                    Vector3D point;
                    point.X = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                    point.Y = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                    point.Z = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                    planes[i].points.Add(point);
                }
                planes[i].normal.X = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                planes[i].normal.Y = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                planes[i].normal.Z = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                planes[i].d = System.BitConverter.ToDouble(rdata, pos); pos += 8;
                int idLen = System.BitConverter.ToInt32(rdata, pos); pos += 4;
                planes[i].id = System.BitConverter.ToString(rdata, pos, idLen); pos += idLen;
            }
            return planes;            
        }
        return null;
    }

API 接口目录
Xvisio SDK 文档主页