static SRWork_SeeThrough()
                {
                    SRWorkModule_API.GetSeeThrougParameterBool((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_4K_READY, ref b4KImageReady);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_WIDTH, ref DistortedImageWidth);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_HEIGHT, ref DistortedImageHeight);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_CHANNEL, ref DistortedImageChannel);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_WIDTH, ref UndistortedImageWidth);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_HEIGHT, ref UndistortedImageHeight);

                    SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_CHANNEL, ref UndistortedImageChannel);
                    //b4KImageReady = false;
                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_WIDTH, ref Distorted4KImageWidth);

                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_HEIGHT, ref Distorted4KImageHeight);

                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_CHANNEL, ref Distorted4KImageChannel);

                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_WIDTH, ref Undistorted4KImageWidth);

                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_HEIGHT, ref Undistorted4KImageHeight);

                    SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_CHANNEL, ref Undistorted4KImageChannel);

                    //IntPtr.Zero; //
                    see_through_data_.distorted_frame_left    = IntPtr.Zero;
                    see_through_data_.distorted_frame_right   = IntPtr.Zero;
                    see_through_data_.undistorted_frame_left  = IntPtr.Zero;
                    see_through_data_.undistorted_frame_right = IntPtr.Zero;

                    SeeThroughDataLeftDistort   = Marshal.AllocCoTaskMem(sizeof(char) * DistortedImageWidth * DistortedImageHeight * DistortedImageChannel);
                    SeeThroughDataRighttDistort = Marshal.AllocCoTaskMem(sizeof(char) * DistortedImageWidth * DistortedImageHeight * DistortedImageChannel);

                    see_through_data_.pose_left     = Marshal.AllocCoTaskMem(sizeof(float) * 16);
                    see_through_data_.pose_right    = Marshal.AllocCoTaskMem(sizeof(float) * 16);
                    see_through_data_.Camera_params = Marshal.AllocCoTaskMem(sizeof(char) * 1032);

                    see_through_data_.d3d11_texture2d_shared_handle_left  = Marshal.AllocCoTaskMem(IntPtr.Size);
                    see_through_data_.d3d11_texture2d_shared_handle_right = Marshal.AllocCoTaskMem(IntPtr.Size);

                    see_through_4k_data_.distorted_4k_frame_left    = IntPtr.Zero;
                    see_through_4k_data_.distorted_4k_frame_right   = IntPtr.Zero;
                    see_through_4k_data_.undistorted_4k_frame_left  = IntPtr.Zero;
                    see_through_4k_data_.undistorted_4k_frame_right = IntPtr.Zero;

                    see_through_4k_data_.output4k_pose_left  = Marshal.AllocCoTaskMem(sizeof(float) * 16);
                    see_through_4k_data_.output4k_pose_right = Marshal.AllocCoTaskMem(sizeof(float) * 16);
                    see_through_4k_data_.Camera4k_params     = Marshal.AllocCoTaskMem(sizeof(char) * 1032);

                    see_through_4k_data_.d3d11_texture2d_shared_handle_left  = Marshal.AllocCoTaskMem(IntPtr.Size);
                    see_through_4k_data_.d3d11_texture2d_shared_handle_right = Marshal.AllocCoTaskMem(IntPtr.Size);

                    //RegisterDistortedCallback();
                }
示例#2
0
        private static void GetParameters()
        {
            double[] cameraparams = new double[(int)CAMERA_Param.CAMERA_PARAMS_MAX];
            if (SeeThrough.SRWork_SeeThrough.b4KImageReady)
            {
                SRWorkModule_API.Get4KCameraParams(cameraparams);
            }
            else
            {
                SRWorkModule_API.GetCameraParams(cameraparams);
            }

            DistortedCx_L = cameraparams[0];
            DistortedCy_L = cameraparams[2];
            DistortedCx_R = cameraparams[1];
            DistortedCy_R = cameraparams[3];
            FocalLength_L = cameraparams[4];
            FocalLength_R = cameraparams[5];

            if (SeeThrough.SRWork_SeeThrough.b4KImageReady)
            {
                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_DISTORTED_4K_WIDTH, ref DistortedImageWidth);
                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_DISTORTED_4K_HEIGHT, ref DistortedImageHeight);
                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_DISTORTED_4K_CHANNEL, ref DistortedImageChannel);

                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_WIDTH, ref UndistortedImageWidth);
                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_HEIGHT, ref UndistortedImageHeight);
                SRWorkModule_API.GetSeeThroug4KParameterInt((int)SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_CHANNEL, ref UndistortedImageChannel);
            }
            else
            {
                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_DISTORTED_WIDTH, ref DistortedImageWidth);
                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_DISTORTED_HEIGHT, ref DistortedImageHeight);
                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_DISTORTED_CHANNEL, ref DistortedImageChannel);

                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_UNDISTORTED_WIDTH, ref UndistortedImageWidth);
                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_UNDISTORTED_HEIGHT, ref UndistortedImageHeight);
                SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.OUTPUT_UNDISTORTED_CHANNEL, ref UndistortedImageChannel);
            }

            if (ViveSR.Instance.EnableDepthModule)
            {
                SRWorkModule_API.GetDepthParameterInt((int)DepthParam.OUTPUT_WIDTH, ref DepthImageWidth);
                SRWorkModule_API.GetDepthParameterInt((int)DepthParam.OUTPUT_HEIGHT, ref DepthImageHeight);
                SRWorkModule_API.GetDepthParameterInt((int)DepthParam.OUTPUT_CHAANEL_1, ref DepthImageChannel);
                SRWorkModule_API.GetDepthParameterDouble((int)DepthParam.BASELINE, ref Baseline);
            }

            int undistortionMapSize = 0;

            SRWorkModule_API.GetSeeThrougParameterInt((int)SeeThroughParam.UNDISTORTION_MAP_SIZE, ref undistortionMapSize);

            //Todo : Runtime support structure data passing to client.
            //UndistortionMap_L = new float[undistortionMapSize / sizeof(float)];
            //UndistortionMap_R = new float[undistortionMapSize / sizeof(float)];
            //ViveSR_Framework.GetParameterFloatArray(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.UNDISTORTION_MAP_L, ref UndistortionMap_L);
            //ViveSR_Framework.GetParameterFloatArray(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.UNDISTORTION_MAP_R, ref UndistortionMap_R);


            UndistortedCx_L = cameraparams[18];
            UndistortedCy_L = cameraparams[19];
            UndistortedCx_R = cameraparams[20];
            UndistortedCy_R = cameraparams[21];

            //Get offset head to camera from hardware design.
            if (SeeThrough.SRWork_SeeThrough.b4KImageReady)
            {
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_x0, ref OffsetHeadToCamera[0]);
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_y0, ref OffsetHeadToCamera[1]);
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_z0, ref OffsetHeadToCamera[2]);
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_x1, ref OffsetHeadToCamera[3]);
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_y1, ref OffsetHeadToCamera[4]);
                SRWorkModule_API.GetSeeThroug4KParameterFloat((int)SeeThrough4KParam.OFFSET_HEAD_TO_4K_CAMERA_z1, ref OffsetHeadToCamera[5]);
            }
            else
            {
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_x0, ref OffsetHeadToCamera[0]);
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_y0, ref OffsetHeadToCamera[1]);
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_z0, ref OffsetHeadToCamera[2]);
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_x1, ref OffsetHeadToCamera[3]);
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_y1, ref OffsetHeadToCamera[4]);
                SRWorkModule_API.GetSeeThrougParameterFloat((int)SeeThroughParam.OFFSET_HEAD_TO_CAMERA_z1, ref OffsetHeadToCamera[5]);
            }
        }