List of usage examples for android.hardware.camera2 CameraMetadata CONTROL_AF_TRIGGER_START
int CONTROL_AF_TRIGGER_START
To view the source code for android.hardware.camera2 CameraMetadata CONTROL_AF_TRIGGER_START.
Click Source Link
Autofocus will trigger now.
From source file:com.visualnavigate.CameraFragment.java
/** * Lock the focus as the first step for a still image capture. *//* w w w. j a v a 2s .c o m*/ private void lockFocus() { try { // This is how to tell the camera to lock focus. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); // Tell #mCaptureCallback to wait for the lock. mState = STATE_WAITING_LOCK; List<CaptureRequest> list = new ArrayList<CaptureRequest>(); list.add(mPreviewRequestBuilder.build()); mCaptureSession.captureBurst(list, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.mgtv.qxx.ttsdemo.Camera2BasicFragment.java
/** * Lock the focus as the first step for a still image capture. *///from w w w. j ava 2s . co m private void lockFocus() { try { // This is how to tell the camera to lock focus. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); // Tell #mCaptureCallback to wait for the lock. mState = STATE_WAITING_LOCK; Log.v(LOG_TAG, "lockFocus"); mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.vest.album.fragment.CameraBasicFragment.java
/** * Lock the focus as the first step for a still image capture. *///w ww .j a v a 2 s . com private void lockFocus() { try { // This is how to tell the camera to lock focus. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); // Tell #mCaptureCallback to wait for the lock. mState = STATE_WAITING_LOCK; mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { callback.onPhotoError("?"); e.printStackTrace(); } }
From source file:com.example.aschere.cdhprototype2.Camera2RawFragment.java
/** * Initiate a still image capture.//from w w w . ja v a2 s . c om * <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; } }
From source file:com.ape.camera2raw.Camera2RawFragment.java
/** * Initiate a still image capture.// w w w . j av a 2 s .com * <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. */ private void takePicture() { synchronized (mCameraStateLock) { mPendingUserCaptures++; // If we already triggered a pre-capture sequence, or are in a state where we cannot // do this, return immediately. if (mState != STATE_PREVIEW) { return; } try { // Trigger an auto-focus run if camera is capable. If the camera is already focused, // this should do nothing. if (!mNoAFRun) { mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); } // If this is not a legacy device, we can also trigger an auto-exposure metering // run. if (!isLegacyLocked()) { // Tell the camera to lock focus. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START); } // Update state machine to wait for auto-focus, auto-exposure, and // auto-white-balance (aka. "3A") to converge. 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); } catch (CameraAccessException e) { e.printStackTrace(); } } }