Exemple #1
0
        // Use this for initialization
        void Create()
        {
            if (m_PhotoCaptureObject != null)
            {
                Debug.LogError("The NRPhotoCapture has already been created.");
                return;
            }

            // Create a PhotoCapture object
            NRPhotoCapture.CreateAsync(false, delegate(NRPhotoCapture captureObject)
            {
                m_CameraResolution = NRPhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

                if (captureObject != null)
                {
                    m_PhotoCaptureObject = captureObject;
                }
                else
                {
                    Debug.LogError("Can not get a captureObject.");
                }

                CameraParameters cameraParameters       = new CameraParameters();
                cameraParameters.cameraResolutionWidth  = m_CameraResolution.width;
                cameraParameters.cameraResolutionHeight = m_CameraResolution.height;
                cameraParameters.pixelFormat            = CapturePixelFormat.BGRA32;
                cameraParameters.blendMode = BlendMode.Blend;

                // Activate the camera
                m_PhotoCaptureObject.StartPhotoModeAsync(cameraParameters, delegate(NRPhotoCapture.PhotoCaptureResult result)
                {
                    Debug.Log("Start PhotoMode Async");
                });
            });
        }
        private IEnumerator Open()
        {
            if (_photoCapture != null)
            {
                Debug.LogError("The NRPhotoCapture has already been created.");
                yield break;
            }

            NRPhotoCapture.CreateAsync(false, captureObject =>
            {
                if (captureObject == null)
                {
                    Debug.LogError("Can't get a NRPhotoCapture object.");
                    return;
                }

                var cameraParameters = new CameraParameters
                {
                    cameraResolutionWidth  = _texture.width,
                    cameraResolutionHeight = _texture.height,
                    pixelFormat            = CapturePixelFormat.BGRA32,
                    blendMode = BlendMode.Blend
                };

                _photoCapture = captureObject;
                _photoCapture.StartPhotoModeAsync(cameraParameters, result => SetState(State.Opened));
            });
        }
Exemple #3
0
 void OnStoppedPhotoMode(NRPhotoCapture.PhotoCaptureResult result)
 {
     if (m_PhotoCaptureObject == null)
     {
         Debug.LogError("The NRPhotoCapture has not been created.");
         return;
     }
     // Shutdown our photo capture resource
     m_PhotoCaptureObject.Dispose();
     m_PhotoCaptureObject = null;
 }
 private void Dispose()
 {
     _photoCapture?.Dispose(); // BUG Leak NRCaptureBehavior
     _photoCapture = null;
     SetState(State.Closed);
 }