public void CaptureStillPicture() { try { if (Device == null) { return; } // This is the CaptureRequest.Builder that we use to take a picture. if (stillCaptureBuilder == null) { stillCaptureBuilder = Device.CreateCaptureRequest(CameraTemplate.StillCapture); } stillCaptureBuilder.AddTarget(mImageReader.Surface); // Use the same AE and AF modes as the preview. stillCaptureBuilder.Set(CaptureRequest.ControlAfMode, (int)ControlAFMode.ContinuousPicture); SetAutoFlash(stillCaptureBuilder); // Orientation var windowManager = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); int rotation = (int)windowManager.DefaultDisplay.Rotation; stillCaptureBuilder.Set(CaptureRequest.JpegOrientation, GetOrientation(rotation)); CaptureSession.StopRepeating(); CaptureSession.Capture(stillCaptureBuilder.Build(), new CameraCaptureStillPictureSessionCallback(this), null); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
// Capture a still picture. This method should be called when we get a response in // {@link #mCaptureCallback} from both {@link #lockFocus()}. public void CaptureStillPicture() { try { var activity = Activity; if (null == activity || null == CameraDevice) { return; } // 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); SetAutoFlash(_stillCaptureBuilder); CaptureSession.StopRepeating(); CaptureSession.Capture(_stillCaptureBuilder.Build(), new CameraCaptureStillPictureSessionCallback(this), null); } catch (CameraAccessException ex) { #if DEBUG ex.PrintStackTrace(); #endif } }
/// <summary> /// Capture a still picture. This method should be called when we get a response in /// CaptureCallback from both LockFocus() /// </summary> public void CaptureStillPicture() { try { var activity = Activity; if (null == activity || null == CameraDevice) { return; } // This is the CaptureRequest.Builder that we use to take a picture. CaptureRequest.Builder captureBuilder = CameraDevice.CreateCaptureRequest(CameraTemplate.StillCapture); captureBuilder.AddTarget(mImageReader.Surface); // Use the same AE and AF modes as the preview. captureBuilder.Set(CaptureRequest.ControlAfMode, (int)ControlAFMode.ContinuousPicture); SetAutoFlash(captureBuilder); // Orientation int rotation = (int)activity.WindowManager.DefaultDisplay.Rotation; captureBuilder.Set(CaptureRequest.JpegOrientation, GetOrientation(rotation)); var captureCallback = new CameraCaptureSessionCaptureCallback2(this); CaptureSession.StopRepeating(); CaptureSession.Capture(captureBuilder.Build(), captureCallback, null); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
public void RunPrecaptureSequence() { try { // This is how to tell the camera to trigger. PreviewRequestBuilder.Set(CaptureRequest.ControlAePrecaptureTrigger, (int)ControlAEPrecaptureTrigger.Start); // Tell #mCaptureCallback to wait for the precapture sequence to be set. State = CameraState.WaitingPrecapture; CaptureSession.Capture(PreviewRequestBuilder.Build(), CaptureCallback, BackgroundHandler); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
public void LockFocus() { try { // This is how to tell the camera to lock focus. PreviewRequestBuilder.Set(CaptureRequest.ControlAfTrigger, (int)ControlAFTrigger.Start); // Tell #mCaptureCallback to wait for the lock. State = CameraState.WaitingLock; CaptureSession.Capture(PreviewRequestBuilder.Build(), CaptureCallback, BackgroundHandler); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
/// <summary> /// Lock the focus as the first step for a still image capture. /// </summary> private void LockFocus() { try { // This is how to tell the camera to lock focus. PreviewRequestBuilder.Set(CaptureRequest.ControlAfTrigger, (int)ControlAFTrigger.Start); // Tell #CaptureCallback to wait for the lock. CurrentCameraState = STATE_WAITING_LOCK; // this will kick off the image-capture pipeline CaptureSession.Capture(PreviewRequestBuilder.Build(), CaptureCallback, BackgroundHandler); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
public void UnlockFocus() { try { // Reset the auto-focus trigger PreviewRequestBuilder.Set(CaptureRequest.ControlAfTrigger, (int)ControlAFTrigger.Cancel); SetAutoFlash(PreviewRequestBuilder); CaptureSession.Capture(PreviewRequestBuilder.Build(), CaptureCallback, BackgroundHandler); // After this, the camera will go back to the normal state of preview. State = CameraState.Preview; CaptureSession.SetRepeatingRequest(PreviewRequest, CaptureCallback, BackgroundHandler); } catch (CameraAccessException e) { e.PrintStackTrace(); } }