/// <summary>
        /// Renders the latest frame.
        /// </summary>
        /// <param name="cameraId">Camera identifier.</param>
        public static void RenderLatestFrame(TangoEnums.TangoCameraId cameraId)
        {
            int returnValue = VideoOverlayAPI.TangoService_updateTexture(cameraId);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("VideoOverlayProvider.UpdateTexture() Texture was not updated by camera!");
            }
        }
예제 #2
0
        /// <summary>
        /// Renders the latest frame.
        /// </summary>
        /// <param name="cameraId">Camera identifier.</param>
        public static void RenderLatestFrame(TangoEnums.TangoCameraId cameraId)
        {
            int returnValue = VideoOverlayAPI.TangoService_updateTexture(cameraId);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                                   "VideoOverlayProvider.UpdateTexture() Texture was not updated by camera!");
            }
        }
        /// <summary>
        /// Update the texture that has been connected to camera referenced by TangoCameraId with the latest image
        /// from the camera.
        /// </summary>
        /// <returns>The timestamp of the image that has been pushed to the connected texture.</returns>
        /// <param name="cameraId">
        /// The ID of the camera to connect this texture to.  Only <code>TANGO_CAMERA_COLOR</code> and
        /// <code>TANGO_CAMERA_FISHEYE</code> are supported.
        /// </param>
        public static double RenderLatestFrame(TangoEnums.TangoCameraId cameraId)
        {
#if UNITY_EDITOR
            if (m_emulatedExpId_Y != null && m_emulatedExpId_CbCr != null)
            {
                m_emulatedExpId_Y.DiscardContents();
                m_emulatedExpId_CbCr.DiscardContents();
                Graphics.Blit(m_emulatedColorRenderTexture, m_emulatedExpId_Y, m_yuvFilterY);
                Graphics.Blit(m_emulatedColorRenderTexture, m_emulatedExpId_CbCr, m_yuvFilterCbCr);
#if UNITY_EDITOR_WIN
                // A crash occurs when assigning the pointer of a Unity RenderTexture to a Texture2D in a DirectX
                // environment, so must use the slower technique of using normal Texture2D objects with ReadPixels().
                // See emulation comments in ExperimentalConnectTexture().
                RenderTexture.active = m_emulatedExpId_Y;
                m_emulationTexIdCaptureTextures.m_videoOverlayTextureY.ReadPixels(new Rect(0, 0,
                                                                                           m_emulatedExpId_Y.width,
                                                                                           m_emulatedExpId_Y.height),
                                                                                  0, 0, false);
                m_emulationTexIdCaptureTextures.m_videoOverlayTextureY.Apply();

                RenderTexture.active = m_emulatedExpId_CbCr;
                m_emulationTexIdCaptureTextures.m_videoOverlayTextureCb.ReadPixels(new Rect(0, 0,
                                                                                            m_emulatedExpId_CbCr.width,
                                                                                            m_emulatedExpId_CbCr.height),
                                                                                   0, 0, false);
                m_emulationTexIdCaptureTextures.m_videoOverlayTextureCb.Apply();
#endif  // UNITY_EDITOR_WIN
            }

            return(m_lastColorEmulationTime);
#else
            double timestamp   = 0.0;
            int    returnValue = VideoOverlayAPI.TangoService_updateTexture(cameraId, ref timestamp);
            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("VideoOverlayProvider.UpdateTexture() Texture was not updated by camera!");
            }

            return(timestamp);
#endif
        }
예제 #4
0
        /// <summary>
        /// Update the texture that has been connected to camera referenced by TangoCameraId with the latest image
        /// from the camera.
        /// </summary>
        /// <returns>The timestamp of the image that has been pushed to the connected texture.</returns>
        /// <param name="cameraId">
        /// The ID of the camera to connect this texture to.  Only <code>TANGO_CAMERA_COLOR</code> and
        /// <code>TANGO_CAMERA_FISHEYE</code> are supported.
        /// </param>
        public static double RenderLatestFrame(TangoEnums.TangoCameraId cameraId)
        {
#if UNITY_EDITOR
            if (m_emulatedExpId_Y != null && m_emulatedExpId_CbCr != null)
            {
                m_emulatedExpId_Y.DiscardContents();
                m_emulatedExpId_CbCr.DiscardContents();
                Graphics.Blit(m_emulatedColorRenderTexture, m_emulatedExpId_Y, m_yuvFilterY);
                Graphics.Blit(m_emulatedColorRenderTexture, m_emulatedExpId_CbCr, m_yuvFilterCbCr);
            }

            return(m_lastColorEmulationTime);
#else
            double timestamp   = 0.0;
            int    returnValue = VideoOverlayAPI.TangoService_updateTexture(cameraId, ref timestamp);
            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("VideoOverlayProvider.UpdateTexture() Texture was not updated by camera!");
            }

            return(timestamp);
#endif
        }