Esempio n. 1
0
        public CameraState addPreviewLayerToView(UIView view, Action completion, bool tensorflowAnalysis)
        {
            this.tensorflowAnalysis = tensorflowAnalysis;

            if (_canLoadCamera())
            {
                if (embeddingView != null)
                {
                    if (previewLayer != null)
                    {
                        previewLayer.RemoveFromSuperLayer();
                    }
                }

                if (cameraIsSetup)
                {
                    _addPreviewLayerToView(view);
                    completion?.Invoke();
                }
                else
                {
                    _setupCamera(
                        () =>
                    {
                        this._addPreviewLayerToView(view);
                        completion?.Invoke();
                    });
                }
            }

            return(_checkIfCameraIsAvailable());
        }
        public void ConfigureCaptureSession(AVCaptureSession captureSession, AVCaptureStillImageOutput captureOutput)
        {
            if (previewLayer != null)
            {
                previewLayer.RemoveFromSuperLayer();
                previewLayer = null;
            }

            previewLayer = new AVCaptureVideoPreviewLayer(captureSession)
            {
                VideoGravity = AVPlayerLayer.GravityResizeAspect,
                Frame        = Bounds
            };

            Layer.AddSublayer(previewLayer);

            CaptureOutput = captureOutput;

            CaptureOutput.AddObserver(this, capturingStillImageKeypath, NSKeyValueObservingOptions.New, IntPtr.Zero);
        }
Esempio n. 3
0
        public CameraState addPreviewLayerToView(UIView view, CameraOutputMode newCameraOutputMode, Action completion)
        {
            if (_canLoadCamera())
            {
                if (embeddingView != null)
                {
                    if (previewLayer != null)
                    {
                        previewLayer.RemoveFromSuperLayer();
                    }
                }

                if (cameraIsSetup)
                {
                    _addPreviewLayerToView(view);
                    OutputMode = newCameraOutputMode;
                    if (completion != null)
                    {
                        completion();
                    }
                }
                else
                {
                    _setupCamera(
                        () =>
                    {
                        this._addPreviewLayerToView(view);
                        this.OutputMode = newCameraOutputMode;
                        if (completion != null)
                        {
                            completion();
                        }
                    }
                        );
                }
            }
            return(_checkIfCameraIsAvailable());
        }
Esempio n. 4
0
 void TeardownAVCapture()
 {
     previewLayer.RemoveFromSuperLayer();
     previewLayer = null;
 }