コード例 #1
0
        /// <summary> Gets the frame. </summary>
        /// <returns> The frame. </returns>
        public FrameRawData GetFrame()
        {
            if (Time.frameCount != m_LastFrame && m_CameraFrames.Count > 0)
            {
                m_CurrentFrame = m_CameraFrames.Dequeue();
                m_LastFrame    = Time.frameCount;
            }

            return(m_CurrentFrame);
        }
コード例 #2
0
 /// <summary> Adds an object onto the end of this queue. </summary>
 /// <param name="obj"> The object.</param>
 public void Enqueue(FrameRawData obj)
 {
     lock (m_LockObj)
     {
         m_Queue.Enqueue(obj);
         if (m_Queue.Count > Limit)
         {
             var frame = m_Queue.Dequeue();
             m_ObjectPool.Put <FrameRawData>(frame);
         }
     }
 }
コード例 #3
0
 /// <summary> Makes a safe. </summary>
 /// <param name="textureptr"> The textureptr.</param>
 /// <param name="size">       The size.</param>
 /// <param name="timestamp">  The timestamp.</param>
 /// <param name="frame">      [in,out] The frame.</param>
 /// <returns> True if it succeeds, false if it fails. </returns>
 public static bool MakeSafe(IntPtr textureptr, int size, UInt64 timestamp, ref FrameRawData frame)
 {
     if (textureptr == IntPtr.Zero || size <= 0)
     {
         return(false);
     }
     if (frame.data == null || frame.data.Length != size)
     {
         frame.data = new byte[size];
     }
     frame.timeStamp = timestamp;
     Marshal.Copy(textureptr, frame.data, 0, size);
     return(true);
 }
コード例 #4
0
        /// <summary> Updates the texture. </summary>
        private void UpdateTexture()
        {
            if (!DidUpdateThisFrame || !IsPlaying)
            {
                return;
            }

            FrameRawData frame = m_NativeCameraProxy.GetFrame();

            if (frame.data == null)
            {
                NRDebugger.Error("[CameraModelView] Get camera raw data faild...");
                return;
            }
            FrameCount++;
            OnRawDataUpdate(frame);
        }
コード例 #5
0
        /// <summary> Queue frame. </summary>
        /// <param name="textureptr"> The textureptr.</param>
        /// <param name="size">       The size.</param>
        /// <param name="timestamp">  The timestamp.</param>
        protected void QueueFrame(IntPtr textureptr, int size, UInt64 timestamp)
        {
            if (!m_IsPlaying)
            {
                NRDebugger.Error("camera was not stopped properly, it still sending data.");
                return;
            }
            FrameRawData frame  = FramePool.Get <FrameRawData>();
            bool         result = FrameRawData.MakeSafe(m_TexturePtr, size, timestamp, ref frame);

            if (result)
            {
                m_CameraFrames.Enqueue(frame);
            }
            else
            {
                FramePool.Put <FrameRawData>(frame);
            }
        }
コード例 #6
0
 /// <summary> Load raw texture data. </summary>
 /// <param name="frame"> .</param>
 protected virtual void OnRawDataUpdate(FrameRawData frame)
 {
 }