public void Play()
 {
     if (m_IsPlaying)
     {
         return;
     }
     this.Initilize();
     NRKernalUpdater.Instance.OnUpdate += UpdateTexture;
     NRRgbCamera.Play();
     m_IsPlaying = true;
 }
 public void Play()
 {
     if (m_IsPlaying)
     {
         return;
     }
     NRRgbCamera.OnImageUpdate         += OnFrameUpdated;
     InternalUpdater.Instance.OnUpdate += UpdateTexture;
     NRRgbCamera.Play();
     m_IsPlaying = true;
 }
        private void Initilize()
        {
            if (m_IsInitilized)
            {
                return;
            }

            OnCreated();
            NRRgbCamera.Regist(this);
            m_IsInitilized = true;
        }
        /// <summary> Creates RGB camera proxy. </summary>
        /// <returns> The new RGB camera proxy. </returns>
        public static NativeCameraProxy CreateRGBCameraProxy()
        {
            NativeCameraProxy controller;

            if (!m_CameraControllerDict.TryGetValue(NRRgbCamera.ID, out controller))
            {
                controller = new NRRgbCamera();
                m_CameraControllerDict.Add(NRRgbCamera.ID, controller);
            }
            return(controller);
        }
 public void Stop()
 {
     if (!m_IsPlaying)
     {
         return;
     }
     NRRgbCamera.OnImageUpdate         -= OnFrameUpdated;
     InternalUpdater.Instance.OnUpdate -= UpdateTexture;
     NRRgbCamera.Stop();
     m_IsPlaying = false;
 }
 private void Initilize()
 {
     if (m_IsInitilized)
     {
         return;
     }
     if (m_texture == null)
     {
         m_texture = CreateTex();
     }
     NRRgbCamera.Regist(this);
     m_IsInitilized = true;
 }
 public void Stop()
 {
     if (!m_IsInitilized)
     {
         return;
     }
     NRRgbCamera.UnRegist(this);
     this.Pause();
     NRRgbCamera.Stop();
     GameObject.Destroy(m_texture);
     m_texture      = null;
     m_IsInitilized = false;
 }
        private void UpdateTexture()
        {
            if (!DidUpdateThisFrame || !IsPlaying)
            {
                return;
            }

            RGBRawDataFrame rgbRawDataFrame = NRRgbCamera.GetRGBFrame();

            if (rgbRawDataFrame.data == null)
            {
                Debug.LogError("Get Rgb camera data faild...");
                return;
            }

            OnLoadRawTextureData(rgbRawDataFrame);
        }
        public void Stop()
        {
            if (!m_IsInitilized)
            {
                return;
            }

            NRRgbCamera.UnRegist(this);
            NRRgbCamera.Stop();

            this.Pause();
            this.OnStopped();

            FrameCount     = 0;
            m_IsPlaying    = false;
            m_IsInitilized = false;
        }
        private void UpdateTexture()
        {
            if (!NRRgbCamera.HasFrame())
            {
                return;
            }
            RGBRawDataFrame rgbRawDataFrame = NRRgbCamera.GetRGBFrame();

            m_texture.LoadRawTextureData(rgbRawDataFrame.data);
            m_texture.Apply();

            CurrentFrame.timeStamp = rgbRawDataFrame.timeStamp;
            CurrentFrame.texture   = m_texture;
            FrameCount++;

            OnUpdate?.Invoke(CurrentFrame);
        }
        private void UpdateTexture()
        {
            if (!NRRgbCamera.HasFrame())
            {
                return;
            }
            RGBRawDataFrame rgbRawDataFrame = NRRgbCamera.GetRGBFrame();

            if (m_texture == null || m_texture.width != NRRgbCamera.Resolution.width ||
                m_texture.height != NRRgbCamera.Resolution.height)
            {
                m_texture = new Texture2D(NRRgbCamera.Resolution.width, NRRgbCamera.Resolution.height, TextureFormat.RGB24, false);
            }
            m_texture.LoadRawTextureData(rgbRawDataFrame.data);
            m_texture.Apply();

            CurrentFrame.timeStamp = rgbRawDataFrame.timeStamp;
            CurrentFrame.texture   = m_texture;

            if (OnUpdate != null)
            {
                OnUpdate(CurrentFrame);
            }
        }
Exemple #12
0
 /**
  * @brief Release the rgb camera.
  */
 public void Release()
 {
     NRRgbCamera.Release();
 }
Exemple #13
0
 /**
  * @brief Stop rgb camera.
  */
 public void Stop()
 {
     NRRgbCamera.Stop();
     StopCoroutine("RefreshTex");
 }
Exemple #14
0
 /**
  * @brief Start to play rgb camera.
  */
 public void Play()
 {
     NRRgbCamera.Play();
     StopCoroutine("RefreshTex");
     StartCoroutine("RefreshTex");
 }
 public void Dispose()
 {
     NRRgbCamera.Release();
     GameObject.Destroy(m_texture);
 }