List of usage examples for android.hardware.camera2 CaptureRequest CONTROL_AF_TRIGGER
Key CONTROL_AF_TRIGGER
To view the source code for android.hardware.camera2 CaptureRequest CONTROL_AF_TRIGGER.
Click Source Link
Whether the camera device will trigger autofocus for this request.
This entry is normally set to IDLE, or is not included at all in the request settings.
When included and set to START, the camera device will trigger the autofocus algorithm.
From source file:org.odk.collect.android.fragments.Camera2Fragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished./*from ww w . j a va2 s . c o m*/ */ private void unlockFocus() { try { // Reset the auto-focus trigger previewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(previewRequestBuilder); captureSession.capture(previewRequestBuilder.build(), captureCallback, backgroundHandler); // After this, the camera will go back to the normal state of preview. state = STATE_PREVIEW; captureSession.setRepeatingRequest(previewRequest, captureCallback, backgroundHandler); } catch (CameraAccessException e) { Timber.e(e); } }
From source file:info.staticfree.mqtt_camera.fragment.CameraFragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished./*from w w w . java 2s . c o m*/ */ private void unlockFocus() { try { // Reset the auto-focus trigger previewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(previewRequestBuilder); captureSession.capture(previewRequestBuilder.build(), captureCallback, backgroundHandler); } catch (CameraAccessException e) { Log.e(TAG, "Error unlocking focus", e); } }
From source file:camera2basic.Camera2BasicFragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished./*from ww w .ja va2s. co m*/ */ private void unlockFocus() { try { // Reset the auto-focus trigger mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(mPreviewRequestBuilder); mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); // After this, the camera will go back to the normal state of preview. mState = STATE_PREVIEW; mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.android.camera.one.v2.OneCameraZslImpl.java
/** * Request a stream of images.// w w w .ja va2s.com * * @return true if successful, false if there was an error submitting the * capture request. */ private boolean sendRepeatingCaptureRequest() { Log.v(TAG, "sendRepeatingCaptureRequest()"); try { CaptureRequest.Builder builder; if (ZSL_ENABLED) { builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG); } else { builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); } builder.addTarget(mPreviewSurface); if (ZSL_ENABLED) { builder.addTarget(mCaptureImageReader.getSurface()); } builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE); builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON); builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF); addRegionsToCaptureRequestBuilder(builder); mCaptureSession.setRepeatingRequest(builder.build(), mCaptureManager, mCameraHandler); return true; } catch (CameraAccessException e) { if (ZSL_ENABLED) { Log.v(TAG, "Could not execute zero-shutter-lag repeating request.", e); } else { Log.v(TAG, "Could not execute preview request.", e); } return false; } }
From source file:com.oddsix.nutripro.fragments.Camera2Fragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished.// w w w . j a v a 2s . c o m */ public void unlockFocus() { try { // Reset the auto-focus trigger mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(mPreviewRequestBuilder); mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); // After this, the camera will go back to the normal state of preview. mState = STATE_PREVIEW; mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.obviousengine.android.focus.ZslFocusCamera.java
/** *//*from w w w . j av a 2 s . c o m*/ private boolean sendAutoFocusTriggerRequest() { Timber.v("sendAutoFocusTriggerRequest()"); try { CaptureRequest.Builder builder; if (ZSL_ENABLED) { builder = device.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG); } else { builder = device.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); } builder.addTarget(previewSurface); if (ZSL_ENABLED) { builder.addTarget(captureImageReader.getSurface()); } builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); addRegionsToCaptureRequestBuilder(builder); builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO); builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START); captureSession.capture(builder.build(), captureManager, cameraHandler); return true; } catch (CameraAccessException e) { Timber.w(e, "Could not execute auto focus trigger request."); return false; } }
From source file:com.example.joshf.conc.CameraFragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished./* w ww.ja va2s . c o m*/ */ private void unlockFocus() { try { // Reset the auto-focus trigger mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(mPreviewRequestBuilder); Log.e("camera", " capture request"); mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); // After this, the camera will go back to the normal state of preview. mState = STATE_PREVIEW; mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.android.camera.one.v2.OneCameraZslImpl.java
/** * Request a single image./* w w w .j a v a 2 s.c o m*/ * * @return true if successful, false if there was an error submitting the * capture request. */ private boolean sendSingleRequest(OneCamera.PhotoCaptureParameters params) { Log.v(TAG, "sendSingleRequest()"); try { CaptureRequest.Builder builder; builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); builder.addTarget(mPreviewSurface); // Always add this surface for single image capture requests. builder.addTarget(mCaptureImageReader.getSurface()); builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); Flash flashMode = Flash.OFF; addFlashToCaptureRequestBuilder(builder, flashMode); addRegionsToCaptureRequestBuilder(builder); builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO); builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE); // Tag this as a special request which should be saved. builder.setTag(RequestTag.EXPLICIT_CAPTURE); if (sCaptureImageFormat == ImageFormat.JPEG) { builder.set(CaptureRequest.JPEG_QUALITY, (byte) (JPEG_QUALITY)); builder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(params.orientation, mCharacteristics)); } mCaptureSession.capture(builder.build(), mCaptureManager, mCameraHandler); return true; } catch (CameraAccessException e) { Log.v(TAG, "Could not execute single still capture request.", e); return false; } }
From source file:com.microsoft.projectoxford.face.samples.ui.Camera2BasicFragment.java
/** * Unlock the focus. This method should be called when still image capture sequence is * finished.// w w w . j av a 2 s. co m */ private void unlockFocus() { try { // Reset the auto-focus trigger mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL); setAutoFlash(mPreviewRequestBuilder); mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); // After this, the camera will go back to the normal state of preview. mState = STATE_PREVIEW; mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); if (!flashon) { flashon = true; lockFocus(); } else { flashon = false; detectAndFrame(); } } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.example.aschere.cdhprototype2.Camera2RawFragment.java
/** * Initiate a still image capture./*from w ww . j a va 2 s . co m*/ * <p/> * This function sends a capture request that initiates a pre-capture sequence in our state * machine that waits for auto-focus to finish, ending in a "locked" state where the lens is no * longer moving, waits for auto-exposure to choose a good exposure value, and waits for * auto-white-balance to converge. */ public String takePicture() { synchronized (mCameraStateLock) { mPendingUserCaptures++; Log.i("fragmentTakePicture", "Take Picture called!"); // If we already triggered a pre-capture sequence, or are in a state where we cannot // do this, return immediately. /*if (mState != STATE_PREVIEW) { Log.w(TAG, "return immediately"); return null; }*/ setUpCameraOutputs(); openCamera(); startBackgroundThread(); try { Log.i(TAG, "inside try"); if (mPreviewRequestBuilder == null) { Log.i(TAG, "Have to create preview request builder"); if (mCameraDevice == null) { Log.w(TAG, "Camera device not opened?"); setUpCameraOutputs(); openCamera(); } createCameraPreviewSessionLocked(); } // Update state machine to wait for auto-focus, auto-exposure, and // auto-white-balance (aka. "3A") to converge. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START); mState = STATE_WAITING_FOR_3A_CONVERGENCE; // Start a timer for the pre-capture sequence. startTimerLocked(); // Replace the existing repeating request with one with updated 3A triggers. mCaptureSession.capture(mPreviewRequestBuilder.build(), mPreCaptureCallback, mBackgroundHandler); //closeCamera(); int count = 0; while (!imageReturnable) { count++; } Log.i(TAG, "Image acquired!" + count); imageReturnable = false; return imageToReturn; } catch (CameraAccessException e) { e.printStackTrace(); } finally { closeCamera(); } return null; } }