/// <summary>
        /// Get the intrinsic calibration parameters for a given camera.
        ///
        /// The intrinsics are as specified by the TangoCameraIntrinsics struct.  Intrinsics are read from the
        /// on-device intrinsics file (typically <code>/sdcard/config/calibration.xml</code>, but to ensure
        /// compatibility applications should only access these parameters via the API), or default internal model
        /// parameters corresponding to the device are used if the calibration.xml file is not found.
        /// </summary>
        /// <param name="cameraId">The camera ID to retrieve the calibration intrinsics for.</param>
        /// <param name="intrinsics">A TangoCameraIntrinsics filled with calibration intrinsics for the camera.</param>
        public static void GetIntrinsics(TangoEnums.TangoCameraId cameraId, [Out] TangoCameraIntrinsics intrinsics)
        {
            int returnValue = VideoOverlayAPI.TangoService_getCameraIntrinsics(cameraId, intrinsics);

#if UNITY_EDITOR
            // In editor, base 'intrinsics' off of properties of emulation camera.
            if (cameraId == TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR && EmulatedEnvironmentRenderHelper.m_emulationCamera != null)
            {
                // Instantiate any resources that we haven't yet.
                if (!m_emulationIsInitialized)
                {
                    _InitializeResourcesForEmulation();
                    m_emulationIsInitialized = true;
                }

                EmulatedEnvironmentRenderHelper.m_emulationCamera.targetTexture = m_emulatedColorRenderTexture;

                intrinsics.width  = (uint)EMULATED_CAMERA_WIDTH;
                intrinsics.height = (uint)EMULATED_CAMERA_HEIGHT;

                float height = Screen.height;
                float fov    = EmulatedEnvironmentRenderHelper.m_emulationCamera.fieldOfView;
                float focalLengthInPixels = (1 / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad)) * (intrinsics.height * 0.5f);
                intrinsics.fy = intrinsics.fx = focalLengthInPixels;
                intrinsics.cx = intrinsics.width / 2f;
                intrinsics.cy = intrinsics.height / 2f;
            }
#endif

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("IntrinsicsProviderAPI.TangoService_getCameraIntrinsics() failed!");
            }
        }
예제 #2
0
        /// <summary>
        /// Get the camera/sensor intrinsics.
        /// </summary>
        /// <param name="cameraId">Camera identifier.</param>
        /// <param name="intrinsics">Camera intrinsics data.</param>
        public static void GetIntrinsics(TangoEnums.TangoCameraId cameraId, [Out] TangoCameraIntrinsics intrinsics)
        {
            int returnValue = VideoOverlayAPI.TangoService_getCameraIntrinsics(cameraId, intrinsics);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("IntrinsicsProviderAPI.TangoService_getCameraIntrinsics() failed!");
            }
        }