Ejemplo n.º 1
0
        private void CaptureStillPicture()
        {
            try
            {
                // This is the CaptureRequest.Builder that we use to take a picture.
                if (_stillCaptureBuilder == null)
                {
                    _stillCaptureBuilder = _cameraDevice.CreateCaptureRequest(CameraTemplate.StillCapture);
                }

                _stillCaptureBuilder.AddTarget(_imageReader.Surface);

                // Use the same AE and AF modes as the preview.
                _stillCaptureBuilder.Set(CaptureRequest.ControlAfMode, (int)ControlAFMode.ContinuousPicture);
                Utils.SetAutoFlash(_stillCaptureBuilder, _manager, _cameraId);

                var rotation = Utils.CalculateRotation();
                _stillCaptureBuilder.Set(CaptureRequest.JpegOrientation, Utils.GetOrientation(rotation));

                _captureSession.StopRepeating();

                var stillCaptureListener = new CameraCaptureListener();
                stillCaptureListener.CaptureResultAvailable += StillCaptureHandler;
                _captureSession.Capture(_stillCaptureBuilder.Build(),
                                        stillCaptureListener, null);
            }
            catch (CameraAccessException e)
            {
                Debug.WriteLine(e);
                throw;
            }
        }
Ejemplo n.º 2
0
 public CameraPreview(Context context, CameraDevice camera, Android.Hardware.Camera2.CameraManager manager,
                      Handler backgroundHandler,
                      CameraCaptureListener captureListener)
 {
     _context           = context;
     _camera            = camera;
     _manager           = manager;
     _backgroundHandler = backgroundHandler;
     _captureListener   = captureListener;
 }