/// <summary> /// CameraStateListenerのOnOpenedから呼び出される /// </summary> internal void CreateCameraPreviewSession() { try { if (this.SurfaceTexture == null) { throw new IllegalStateException("SurfaceTexture is null"); } this.SurfaceTexture.SetDefaultBufferSize(PreviewSize.Width, PreviewSize.Height); //プレビュー用のRequestBuilderを作成 this.PreviewRequestBuilder = this.CameraDevice.CreateCaptureRequest(CameraTemplate.Preview); Surface previewSurface = new Surface(this.SurfaceTexture); PreviewRequestBuilder.AddTarget(previewSurface); //キャプチャ用 //プレビューキャプチャと同じタイミングで動作させるのではなく,独立させたい場合は,RequestBuilderを別に作成する. //this.StillCaptureBuilder = this.CameraDevice.CreateCaptureRequest(CameraTemplate.StillCapture); Surface readerSurface = this.ImageReader.Surface; PreviewRequestBuilder.AddTarget(readerSurface); List <Surface> surfaces = new List <Surface>(); surfaces.Add(previewSurface); surfaces.Add(readerSurface); //CameraCaptureSessionを生成 this.CameraDevice.CreateCaptureSession(surfaces, new CameraCaptureStateListener(this), BackgroundHandler); } catch (CameraAccessException ex) { ex.PrintStackTrace(); } }
public void CreateCameraPreviewSession() { try { SurfaceTexture texture = mTextureView.SurfaceTexture; if (texture == null) { throw new IllegalStateException("texture is null"); } // We configure the size of default buffer to be the size of camera preview we want. texture.SetDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height); // This is the output Surface we need to start preview. Surface surface = new Surface(texture); // We set up a CaptureRequest.Builder with the output Surface. PreviewRequestBuilder = Device.CreateCaptureRequest(CameraTemplate.Preview); PreviewRequestBuilder.AddTarget(surface); // Here, we create a CameraCaptureSession for camera preview. List <Surface> surfaces = new List <Surface>(); surfaces.Add(surface); surfaces.Add(mImageReader.Surface); Device.CreateCaptureSession(surfaces, new CameraCaptureSessionCallback(this), null); } catch (CameraAccessException e) { e.PrintStackTrace(); } }
public Command BuildPreviewCommand() { var command = new Command("preview"); var builder = new PreviewRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return(command); }
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(); } }