public void DoAsyn(NRPhotoCapture.OnCapturedToMemoryCallback oncapturedcallback)
        {
            if (!m_IsInit)
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.UnknownError;
                    oncapturedcallback(result, null);
                }
                return;
            }
            var captureTask = new CaptureTask();

            captureTask.Width         = m_CameraParameters.cameraResolutionWidth;
            captureTask.Height        = m_CameraParameters.cameraResolutionHeight;
            captureTask.BlendMode     = m_CameraParameters.blendMode;
            captureTask.CaptureFormat = m_CameraParameters.pixelFormat == CapturePixelFormat.PNG ? PhotoCaptureFileOutputFormat.PNG : PhotoCaptureFileOutputFormat.JPG;
            captureTask.OnReceive    += (task, data) =>
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.Success;
                    CapturePixelFormat format = task.CaptureFormat == PhotoCaptureFileOutputFormat.PNG ? CapturePixelFormat.PNG : CapturePixelFormat.JPEG;
                    PhotoCaptureFrame  frame  = new PhotoCaptureFrame(format, data);
                    oncapturedcallback(result, frame);
                }
            };

            this.DoAsyn(captureTask);
        }
예제 #2
0
        private void CommitResult(Texture2D texture, CaptureTask task)
        {
            if (task.OnReceive == null)
            {
                return;
            }

            if (texture == null)
            {
                task.OnReceive(task, null);
                return;
            }

            byte[] result = null;
            switch (task.CaptureFormat)
            {
            case PhotoCaptureFileOutputFormat.JPG:
                result = texture.EncodeToJPG();
                break;

            case PhotoCaptureFileOutputFormat.PNG:
                result = texture.EncodeToPNG();
                break;

            default:
                break;
            }
            task.OnReceive(task, result);
        }
예제 #3
0
        public void Capture(CaptureTask task)
        {
            switch (task.BlendMode)
            {
            case BlendMode.RGBOnly:
                CommitResult(m_RGBOrigin, task);
                break;

            case BlendMode.VirtualOnly:
                m_Requests.Enqueue(AsyncGPUReadback.Request(VirtualTexture));
                m_Tasks.Enqueue(task);
                break;

            case BlendMode.Blend:
                m_Requests.Enqueue(AsyncGPUReadback.Request(BlendTexture));
                m_Tasks.Enqueue(task);
                break;

            case BlendMode.WidescreenBlend:
                // Do not support..
                Debug.Log("Do not support WidescreenBlend mode now...");
                break;

            default:
                break;
            }
        }
예제 #4
0
 public void Commit(CaptureTask task)
 {
     if (m_CurrentFrame != null)
     {
         m_Requests.Enqueue(AsyncGPUReadback.Request(m_CurrentFrame));
         m_Tasks.Enqueue(task);
     }
     else
     {
         NRDebugger.LogWarning("[ImageEncoder] Lost frame data.");
     }
 }
예제 #5
0
 /// <summary>
 /// Capture a image Asyn. if system supports AsyncGPUReadback, using AsyncGPUReadback to get the
 /// captured image, else getting the image by synchronization way. </summary>
 /// <param name="task"> The task.</param>
 private void DoAsyn(CaptureTask task)
 {
     if (SystemInfo.supportsAsyncGPUReadback)
     {
         this.ImageEncoder.Commit(task);
     }
     else
     {
         var data = ImageEncoder.Encode(task.Width, task.Height, task.CaptureFormat);
         if (task.OnReceive != null)
         {
             task.OnReceive(task, data);
         }
     }
 }
        /**
         * @brief Capture a image Asyn.
         *
         * if system supports AsyncGPUReadback, using AsyncGPUReadback to get the captured image.
         * else getting the image by synchronization way.
         */
        public void DoAsyn(CaptureTask task)
        {
            if (!m_IsInit)
            {
                return;
            }

            if (SystemInfo.supportsAsyncGPUReadback)
            {
                m_CameraInput.Capture(task);
            }
            else
            {
                var data = Do(task.Width, task.Height, task.BlendMode, task.CaptureFormat);
                if (task.OnReceive != null)
                {
                    task.OnReceive(task, data);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Capture a image Asyn. if system supports AsyncGPUReadback, using AsyncGPUReadback to get the
        /// captured image, else getting the image by synchronization way. </summary>
        /// <param name="oncapturedcallback"> The oncapturedcallback.</param>
        public void DoAsyn(NRPhotoCapture.OnCapturedToMemoryCallback oncapturedcallback)
        {
            var captureTask = new CaptureTask();
            var cameraParam = this.GetContext().RequestCameraParam();

            captureTask.Width         = cameraParam.cameraResolutionWidth;
            captureTask.Height        = cameraParam.cameraResolutionHeight;
            captureTask.CaptureFormat = cameraParam.pixelFormat == CapturePixelFormat.PNG ? PhotoCaptureFileOutputFormat.PNG : PhotoCaptureFileOutputFormat.JPG;
            captureTask.OnReceive    += (task, data) =>
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.Success;
                    CapturePixelFormat format = task.CaptureFormat == PhotoCaptureFileOutputFormat.PNG ? CapturePixelFormat.PNG : CapturePixelFormat.JPEG;
                    PhotoCaptureFrame  frame  = new PhotoCaptureFrame(format, data);
                    oncapturedcallback(result, frame);
                }
            };

            this.DoAsyn(captureTask);
        }