コード例 #1
0
        /// <summary>
        /// Load the custom calibration parameters from  DualCameraParameters.xml.
        /// </summary>
        public void LoadDeviceParameter()
        {
            foreach (DualCameraIndex camIndex in Enum.GetValues(typeof(DualCameraIndex)))
            {
                ViveSR_TrackedCamera trackedCamera = camIndex == DualCameraIndex.LEFT ? ViveSR_DualCameraRig.Instance.TrackedCameraLeft :
                                                     ViveSR_DualCameraRig.Instance.TrackedCameraRight;
                if (trackedCamera != null)
                {
                    int camValue = camIndex == DualCameraIndex.LEFT ? 0 : 1;
                    trackedCamera.Anchor.transform.localPosition = new Vector3(0,
                                                                               -ViveSR_DualCameraImageCapture.OffsetHeadToCamera[camValue * 3 + 1],
                                                                               -ViveSR_DualCameraImageCapture.OffsetHeadToCamera[camValue * 3 + 2]);

                    for (int planeIndex = 0; planeIndex < 2; planeIndex++)
                    {
                        ViveSR_DualCameraImagePlane imagePlane = planeIndex == 0 ? trackedCamera.ImagePlane :
                                                                 trackedCamera.ImagePlaneCalibration;
                        if (imagePlane != null)
                        {
                            imagePlane.DistortedImageWidth    = ViveSR_DualCameraImageCapture.DistortedImageWidth;
                            imagePlane.DistortedImageHeight   = ViveSR_DualCameraImageCapture.DistortedImageHeight;
                            imagePlane.UndistortedImageWidth  = ViveSR_DualCameraImageCapture.UndistortedImageWidth;
                            imagePlane.UndistortedImageHeight = ViveSR_DualCameraImageCapture.UndistortedImageHeight;
                            if (camIndex == DualCameraIndex.LEFT)
                            {
                                imagePlane.DistortedCx     = ViveSR_DualCameraImageCapture.DistortedCx_L;
                                imagePlane.DistortedCy     = ViveSR_DualCameraImageCapture.DistortedCy_L;
                                imagePlane.UndistortedCx   = ViveSR_DualCameraImageCapture.UndistortedCx_L;
                                imagePlane.UndistortedCy   = ViveSR_DualCameraImageCapture.UndistortedCy_L;
                                imagePlane.FocalLength     = ViveSR_DualCameraImageCapture.FocalLength_L;
                                imagePlane.UndistortionMap = ViveSR_DualCameraImageCapture.UndistortionMap_L;
                            }
                            else if (camIndex == DualCameraIndex.RIGHT)
                            {
                                imagePlane.DistortedCx     = ViveSR_DualCameraImageCapture.DistortedCx_R;
                                imagePlane.DistortedCy     = ViveSR_DualCameraImageCapture.DistortedCy_R;
                                imagePlane.UndistortedCx   = ViveSR_DualCameraImageCapture.UndistortedCx_R;
                                imagePlane.UndistortedCy   = ViveSR_DualCameraImageCapture.UndistortedCy_R;
                                imagePlane.FocalLength     = ViveSR_DualCameraImageCapture.FocalLength_R;
                                imagePlane.UndistortionMap = ViveSR_DualCameraImageCapture.UndistortionMap_R;
                            }
                        }
                    }
                }
            }
            ViveSR_DualCameraRig.Instance.HMDCameraShifter.CameraShiftZ = ViveSR_DualCameraImageCapture.OffsetHeadToCamera[2];

            Vector3 relativeAngle = new Vector3(float.Parse((string)Registry.GetValue(rootPaht, keyNameRelativeAngle + "_x", 0)),
                                                float.Parse((string)Registry.GetValue(rootPaht, keyNameRelativeAngle + "_y", 0)),
                                                float.Parse((string)Registry.GetValue(rootPaht, keyNameRelativeAngle + "_z", 0)));
            Vector3 absoluteAngle = new Vector3(float.Parse((string)Registry.GetValue(rootPaht, keyNameAbsoluteAngle + "_x", 0)),
                                                float.Parse((string)Registry.GetValue(rootPaht, keyNameAbsoluteAngle + "_y", 0)),
                                                float.Parse((string)Registry.GetValue(rootPaht, keyNameAbsoluteAngle + "_z", 0)));

            CurrentCalibrationType = CalibrationType.RELATIVE;
            Calibration(CalibrationAxis.X, relativeAngle.x);
            Calibration(CalibrationAxis.Y, relativeAngle.y);
            Calibration(CalibrationAxis.Z, relativeAngle.z);

            CurrentCalibrationType = CalibrationType.ABSOLUTE;
            Calibration(CalibrationAxis.X, absoluteAngle.x);
            Calibration(CalibrationAxis.Y, absoluteAngle.y);
            Calibration(CalibrationAxis.Z, absoluteAngle.z);
        }
コード例 #2
0
        /// <summary>
        /// Load the custom calibration parameters from  DualCameraParameters.xml.
        /// </summary>
        public void LoadDeviceParameter()
        {
            foreach (DualCameraIndex camIndex in Enum.GetValues(typeof(DualCameraIndex)))
            {
                ViveSR_TrackedCamera trackedCamera = camIndex == DualCameraIndex.LEFT ? ViveSR_DualCameraRig.Instance.TrackedCameraLeft :
                                                     ViveSR_DualCameraRig.Instance.TrackedCameraRight;
                if (trackedCamera != null)
                {
                    int camValue = camIndex == DualCameraIndex.LEFT ? 0 : 1;
                    trackedCamera.Anchor.transform.localPosition = new Vector3(0,
                                                                               -ViveSR_DualCameraImageCapture.OffsetHeadToCamera[camValue * 3 + 1],
                                                                               -ViveSR_DualCameraImageCapture.OffsetHeadToCamera[camValue * 3 + 2]);

                    for (int planeIndex = 0; planeIndex < 2; planeIndex++)
                    {
                        ViveSR_DualCameraImagePlane imagePlane = planeIndex == 0 ? trackedCamera.ImagePlane :
                                                                 trackedCamera.ImagePlaneCalibration;
                        if (imagePlane != null)
                        {
                            imagePlane.DistortedImageWidth    = ViveSR_DualCameraImageCapture.DistortedImageWidth;
                            imagePlane.DistortedImageHeight   = ViveSR_DualCameraImageCapture.DistortedImageHeight;
                            imagePlane.UndistortedImageWidth  = ViveSR_DualCameraImageCapture.UndistortedImageWidth;
                            imagePlane.UndistortedImageHeight = ViveSR_DualCameraImageCapture.UndistortedImageHeight;
                            if (camIndex == DualCameraIndex.LEFT)
                            {
                                imagePlane.DistortedCx     = ViveSR_DualCameraImageCapture.DistortedCx_L;
                                imagePlane.DistortedCy     = ViveSR_DualCameraImageCapture.DistortedCy_L;
                                imagePlane.UndistortedCx   = ViveSR_DualCameraImageCapture.UndistortedCx_L;
                                imagePlane.UndistortedCy   = ViveSR_DualCameraImageCapture.UndistortedCy_L;
                                imagePlane.FocalLength     = ViveSR_DualCameraImageCapture.FocalLength_L;
                                imagePlane.UndistortionMap = ViveSR_DualCameraImageCapture.UndistortionMap_L;
                            }
                            else if (camIndex == DualCameraIndex.RIGHT)
                            {
                                imagePlane.DistortedCx     = ViveSR_DualCameraImageCapture.DistortedCx_R;
                                imagePlane.DistortedCy     = ViveSR_DualCameraImageCapture.DistortedCy_R;
                                imagePlane.UndistortedCx   = ViveSR_DualCameraImageCapture.UndistortedCx_R;
                                imagePlane.UndistortedCy   = ViveSR_DualCameraImageCapture.UndistortedCy_R;
                                imagePlane.FocalLength     = ViveSR_DualCameraImageCapture.FocalLength_R;
                                imagePlane.UndistortionMap = ViveSR_DualCameraImageCapture.UndistortionMap_R;
                            }
                        }
                    }
                }
            }
            // Shift the VR camera along the y and z direction of the camera coordinate system.
            ViveSR_DualCameraRig.Instance.HMDCameraShifter.CameraShift = new Vector3(
                0f, ViveSR_DualCameraImageCapture.OffsetHeadToCamera[1], ViveSR_DualCameraImageCapture.OffsetHeadToCamera[2]);

            //load to temp variable which will update variable in calibiration function
            Vector3 _RelativeAngle = new Vector3(GetRegistryValue(keyNamePath, keyNameRelativeAngle + "_x", 0.0f),
                                                 GetRegistryValue(keyNamePath, keyNameRelativeAngle + "_y", 0.0f),
                                                 GetRegistryValue(keyNamePath, keyNameRelativeAngle + "_z", 0.0f));
            Vector3 _AbsoluteAngle = new Vector3(GetRegistryValue(keyNamePath, keyNameAbsoluteAngle + "_x", 0.0f),
                                                 GetRegistryValue(keyNamePath, keyNameAbsoluteAngle + "_y", 0.0f),
                                                 GetRegistryValue(keyNamePath, keyNameAbsoluteAngle + "_z", 0.0f));

            CurrentCalibrationType = CalibrationType.RELATIVE;
            Calibration(CalibrationAxis.X, _RelativeAngle.x);
            Calibration(CalibrationAxis.Y, _RelativeAngle.y);
            Calibration(CalibrationAxis.Z, _RelativeAngle.z);

            CurrentCalibrationType = CalibrationType.ABSOLUTE;
            Calibration(CalibrationAxis.X, _AbsoluteAngle.x);
            Calibration(CalibrationAxis.Y, _AbsoluteAngle.y);
            Calibration(CalibrationAxis.Z, _AbsoluteAngle.z);
        }