Exemplo n.º 1
0
        public static bool GetDepthColliderFrameInfo()
        {
            int result = (int)Error.FAILED;

            if (!InitialDepthColliderPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepthCollider, DataInfoDepthCollider.Length);
                InitialDepthColliderPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoDepthCollider[(int)DepthDataMask.TIME_STP] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return(false);
            }

            Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.TIME_STP].ptr, RawDepthColliderTimeIndex, 0, RawDepthColliderTimeIndex.Length);
            if (LastDepthColliderTimeIndex == DepthColliderTimeIndex)
            {
                return(false);
            }
            else
            {
                LastDepthColliderTimeIndex = DepthColliderTimeIndex;
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update the buffer of depth texture, frame index and time index.
        /// </summary>
        public static void UpdateDepthImage()
        {
            int result = (int)Error.FAILED;

            if (!InitialDepthPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepth, DataInfoDepth.Length);
                InitialDepthPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoDepth[(int)DepthDataMask.FRAME_SEQ] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return;
            }

            Marshal.Copy(DataInfoDepth[(int)DepthDataMask.FRAME_SEQ].ptr, RawDepthFrameIndex, 0, RawDepthFrameIndex.Length);
            if (LastDepthFrameIndex == DepthFrameIndex)
            {
                return;
            }
            else
            {
                LastDepthFrameIndex = DepthFrameIndex;
            }

            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepth, DataInfoDepth.Length);
            if (result == (int)Error.WORK)
            {
                ParseDepthPtrData();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update the buffer of undistorted texture, frame index and time index.
        /// </summary>
        public static void UpdateUndistortedImage()
        {
            int result = (int)Error.FAILED;

            if (!InitialUndistortedPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_SEETHROUGH, DataInfoUndistorted, DataInfoUndistorted.Length);
                InitialUndistortedPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoUndistorted[(int)SeeThroughDataMask.FRAME_SEQ] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_SEETHROUGH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return;
            }

            Marshal.Copy(DataInfoUndistorted[(int)SeeThroughDataMask.FRAME_SEQ].ptr, RawUndistortedFrameIndex, 0, RawUndistortedFrameIndex.Length);
            if (LastUndistortedFrameIndex == UndistortedFrameIndex)
            {
                return;
            }
            else
            {
                LastUndistortedFrameIndex = UndistortedFrameIndex;
            }

            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_SEETHROUGH, DataInfoUndistorted, DataInfoUndistorted.Length);
            if (result == (int)Error.WORK)
            {
                ParseUndistortedPtrData();
            }
        }
Exemplo n.º 4
0
        public static bool GetRigidReconstructionData(ref int frame,
                                                      out float[] pose,
                                                      ref int verticesNum,
                                                      out float[] verticesBuff,
                                                      ref int vertStrideInFloat,
                                                      out int[] sectorIDList,
                                                      ref int sectorNum,
                                                      out int[] sectorVertNum,
                                                      out int[] sectorMeshIdNum,
                                                      ref int indicesNum,
                                                      out int[] indicesBuff)
        {
            if (!UsingCallback)
            {
                int result = (int)Error.FAILED;
                if (!InitialPointCloudPtrSize)
                {
                    result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, DataInfoPointCloud, DataInfoPointCloud.Length);
                    InitialPointCloudPtrSize = (result == (int)Error.WORK);
                }
                result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, DataInfoPointCloud, DataInfoPointCloud.Length);
                if (result == (int)Error.WORK)
                {
                    ParseReconstructionPtrData();
                }
            }

            bool isUpdated = (verticesNum != VertNum);

            verticesNum       = VertNum;
            indicesNum        = IdxNum;
            frame             = FrameSeq;
            vertStrideInFloat = VertStrideInByte / 4;
            verticesBuff      = OutVertex;
            indicesBuff       = OutIndex;
            pose            = TrackedPose;
            sectorIDList    = SectorIDList;
            sectorNum       = SectorNum;
            sectorVertNum   = SectorVertNum;
            sectorMeshIdNum = SectorMeshIdNum;

            return(isUpdated);
        }
Exemplo n.º 5
0
        public static bool GetRigidReconstructionFrame(ref int frame)
        {
            int result = (int)Error.FAILED;

            if (!UsingCallback)
            {
                if (!InitialPointCloudPtrSize)
                {
                    result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, DataInfoPointCloud, DataInfoPointCloud.Length);
                    InitialPointCloudPtrSize = (result == (int)Error.WORK);
                }
                DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoPointCloud[(int)ReconstructionDataMask.FRAME_SEQ] };
                result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, dataInfoFrame, dataInfoFrame.Length);
                if (result != (int)Error.WORK)
                {
                    return(false);
                }
                Marshal.Copy(DataInfoPointCloud[(int)ReconstructionDataMask.FRAME_SEQ].ptr, RawPointCloudFrameIndex, 0, RawPointCloudFrameIndex.Length);
            }
            frame = RawPointCloudFrameIndex[0];
            return(true);
        }
Exemplo n.º 6
0
        public static bool GetDepthColliderData(ref int verticesNum, out float[] verticesBuff, ref int indicesNum, out int[] indicesBuff)
        {
            int result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepthCollider, DataInfoDepthCollider.Length);

            if (result == (int)Error.WORK)
            {
                Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.NUM_VERTICES].ptr, RawDepthColliderVerticesNum, 0, RawDepthColliderVerticesNum.Length);
                Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.BYTEPERVERT].ptr, RawDepthColliderBytePervert, 0, RawDepthColliderBytePervert.Length);
                Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.VERTICES].ptr, RawDepthColliderVertices, 0, ColliderVerticeNum * ColliderBytePervert / 3);
                Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.NUM_INDICES].ptr, RawDepthColliderIndicesNum, 0, RawDepthColliderIndicesNum.Length);
                Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.INDICES].ptr, RawDepthColliderIndices, 0, ColliderIndicesNum);
            }
            else
            {
                RawDepthColliderVerticesNum[0] = 0;
                RawDepthColliderBytePervert[0] = 0;
                RawDepthColliderIndicesNum[0]  = 0;
            }
            verticesNum  = ColliderVerticeNum;
            indicesNum   = ColliderIndicesNum;
            verticesBuff = RawDepthColliderVertices;
            indicesBuff  = RawDepthColliderIndices;
            return(true);
        }