コード例 #1
0
        public static void InitialDepthCollider(int depthImageWidth, int depthImageHeight)
        {
            InitialDepthColliderPtrSize = false;

            RawDepthColliderVertices = new float[depthImageWidth * depthImageHeight * 3];
            RawDepthColliderIndices  = new int[depthImageWidth * depthImageHeight * 6];

            // To use enum DepthDataMask, It needs to assign each type.
            DataInfoDepthCollider = ViveSR_Framework.CreateDataInfo(new IntPtr[] {
                IntPtr.Zero,                                           //
                IntPtr.Zero,                                           //
                IntPtr.Zero,                                           //
                Marshal.AllocCoTaskMem(sizeof(uint)),                  // TIME_STP
                IntPtr.Zero,                                           //
                Marshal.AllocCoTaskMem(sizeof(uint)),                  // NUM_VERTICES
                Marshal.AllocCoTaskMem(sizeof(uint)),                  // BYTEPERVERT
                Marshal.AllocCoTaskMem(sizeof(float) * 640 * 480 * 3), // VERTICES
                Marshal.AllocCoTaskMem(sizeof(uint)),                  // NUM_INDICES
                Marshal.AllocCoTaskMem(sizeof(int) * 640 * 480 * 6),
            });                                                        // INDICES
        }
コード例 #2
0
        public static void AllocOutputDataMemory()
        {
            InitialPointCloudPtrSize = false;
            OutVertex   = new float[8 * 2500000];
            OutIndex    = new int[2500000];
            TrackedPose = new float[16];
            //ExternalPose = new float[16];
            SectorIDList    = new int[1000000];
            SectorVertNum   = new int[1000000];
            SectorMeshIdNum = new int[1000000];
            Debug.Log("[ViveSR] [RigidReconstruction] AllocOutputMemory Done");

            ExportAdaptiveMesh      = true;
            LiveAdaptiveMaxGridSize = ExportAdaptiveMaxGridSize = 64;
            LiveAdaptiveMinGridSize = ExportAdaptiveMinGridSize = 4;
            LiveAdaptiveErrorThres  = ExportAdaptiveErrorThres = 0.4f;

            // To use enum ReconstructionDataMask, It needs to assign each type.
            DataInfoPointCloud = ViveSR_Framework.CreateDataInfo(new IntPtr[] {
                Marshal.AllocCoTaskMem(sizeof(uint)),                // FRAME_SEQ
                Marshal.AllocCoTaskMem(sizeof(float) * 16),          // POSEMTX44
                Marshal.AllocCoTaskMem(sizeof(int)),                 // NUM_VERTICES
                Marshal.AllocCoTaskMem(sizeof(int)),                 // BYTEPERVERT
                Marshal.AllocCoTaskMem(sizeof(float) * 8 * 2500000), // VERTICES
                Marshal.AllocCoTaskMem(sizeof(int)),                 // NUM_INDICES
                Marshal.AllocCoTaskMem(sizeof(int) * 2500000),       // INDICES
                IntPtr.Zero,                                         // CLDTYPE
                IntPtr.Zero,                                         // COLLIDERNUM
                IntPtr.Zero,                                         // CLD_NUM_VERTS
                IntPtr.Zero,                                         // CLD_NUMIDX
                IntPtr.Zero,                                         // CLD_VERTICES
                IntPtr.Zero,                                         // CLD_INDICES
                Marshal.AllocCoTaskMem(sizeof(int)),                 // SECTOR_NUM
                Marshal.AllocCoTaskMem(sizeof(int) * 1000000),       // SECTOR_ID_LIST
                Marshal.AllocCoTaskMem(sizeof(int) * 1000000),       // SECTOR_VERT_NUM
                Marshal.AllocCoTaskMem(sizeof(int) * 1000000)
            });                                                      // SECTOR_IDX_NUM
        }
コード例 #3
0
        /// <summary>
        /// Initialize the image capturing tool.
        /// </summary>
        /// <returns></returns>
        public static int Initial()
        {
            GetParameters();
            InitialDistortedPtrSize   = false;
            InitialUndistortedPtrSize = false;
            InitialDepthPtrSize       = false;
            TextureDistortedLeft      = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.RGBA32, false);
            TextureDistortedRight     = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.RGBA32, false);
            TextureUndistortedLeft    = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false);
            TextureUndistortedRight   = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false);
            TextureDepth = new Texture2D(DepthImageWidth, DepthImageHeight, TextureFormat.RFloat, false);

#if USE_DISTORT_TEX_NATIVE_BUFFER
            DistortTextureIsNative = true;
            var deviceTexture = new Texture2D(2, 2);
            ViveSR_Framework.SetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.VIDEO_RES_NATIVE_PTR, deviceTexture.GetNativeTexturePtr());
            ViveSR_Framework.SetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.VIDEO_RES_VIEW_NATIVE_PTR, nativeTex);
#endif

#if USE_UNDISTORT_TEX_NATIVE_BUFFER
            UndistortTextureIsNative = true;
            TextureUndistortedLeft.Apply();
            TextureUndistortedRight.Apply();
            ViveSR_Framework.SetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.IMAGE_NATIVE_TEXTURE_PTR_L, TextureUndistortedLeft.GetNativeTexturePtr());
            ViveSR_Framework.SetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.IMAGE_NATIVE_TEXTURE_PTR_R, TextureUndistortedRight.GetNativeTexturePtr());
#endif

            DataInfoDistorted = ViveSR_Framework.CreateDataInfo(new IntPtr[] {
#if USE_DISTORT_TEX_NATIVE_BUFFER
                IntPtr.Zero,                                                                                // DISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                // DISTORTED_FRAME_RIGHT
                IntPtr.Zero,                                                                                // UNDISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                // UNDISTORTED_FRAME_RIGHT
#else
                Marshal.AllocCoTaskMem(DistortedImageWidth * DistortedImageHeight * DistortedImageChannel), // LEFT_FRAME
                Marshal.AllocCoTaskMem(DistortedImageWidth * DistortedImageHeight * DistortedImageChannel), // RIGHT_FRAME
                IntPtr.Zero,                                                                                // UNDISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                // UNDISTORTED_FRAME_RIGHT
#endif
                Marshal.AllocCoTaskMem(sizeof(int)),                                                        // FRAME_SEQ
                Marshal.AllocCoTaskMem(sizeof(int)),                                                        // TIME_STP
                Marshal.AllocCoTaskMem(sizeof(float) * 16),                                                 // LEFT_POSE
                Marshal.AllocCoTaskMem(sizeof(float) * 16),
            });                                                                                             // RIGHT_POSE

            DataInfoUndistorted = ViveSR_Framework.CreateDataInfo(new IntPtr[] {
#if USE_UNDISTORT_TEX_NATIVE_BUFFER
                IntPtr.Zero,                                                                                      // DISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                      // DISTORTED_FRAME_RIGHT
                IntPtr.Zero,                                                                                      // UNDISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                      // UNDISTORTED_FRAME_RIGHT
#else
                IntPtr.Zero,                                                                                      // DISTORTED_FRAME_LEFT
                IntPtr.Zero,                                                                                      // DISTORTED_FRAME_RIGHT
                Marshal.AllocCoTaskMem(UndistortedImageWidth * UndistortedImageHeight * UndistortedImageChannel), // UNDISTORTED_FRAME_LEFT
                Marshal.AllocCoTaskMem(UndistortedImageWidth * UndistortedImageHeight * UndistortedImageChannel), // UNDISTORTED_FRAME_RIGHT
#endif
                Marshal.AllocCoTaskMem(sizeof(int)),                                                              // FRAME_SEQ
                Marshal.AllocCoTaskMem(sizeof(int)),                                                              // TIME_STP
                Marshal.AllocCoTaskMem(sizeof(float) * 16),                                                       // LEFT_POSE
                Marshal.AllocCoTaskMem(sizeof(float) * 16),
            });                                                                                                   // RIGHT_POSE

            // To use enum DepthDataMask, It needs to assign each type.
            DataInfoDepth = ViveSR_Framework.CreateDataInfo(new IntPtr[] {
                IntPtr.Zero,                                                                                        // LEFT_FRAME
                Marshal.AllocCoTaskMem(DepthImageWidth * DepthImageHeight * DepthImageChannel * DepthDataSize),     // DEPTH_MAP
                Marshal.AllocCoTaskMem(sizeof(int)),                                                                // FRAME_SEQ
                Marshal.AllocCoTaskMem(sizeof(int)),                                                                // TIME_STP
                Marshal.AllocCoTaskMem(sizeof(float) * 16)
            });                                                                                                     // POSE

            return((int)Error.WORK);
        }