本文整理了Java中android.hardware.Camera.cancelAutoFocus()
方法的一些代码示例,展示了Camera.cancelAutoFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.cancelAutoFocus()
方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:cancelAutoFocus
暂无
代码示例来源:origin: googlesamples/android-vision
/**
* Cancels any auto-focus function in progress.
* Whether or not auto-focus is currently in progress,
* this function will return the focus position to the default.
* If the camera does not support auto-focus, this is a no-op.
*
* @see #autoFocus(AutoFocusCallback)
*/
public void cancelAutoFocus() {
synchronized (cameraLock) {
if (camera != null) {
camera.cancelAutoFocus();
}
}
}
代码示例来源:origin: googlesamples/android-vision
/**
* Cancels any auto-focus function in progress.
* Whether or not auto-focus is currently in progress,
* this function will return the focus position to the default.
* If the camera does not support auto-focus, this is a no-op.
*
* @see #autoFocus(AutoFocusCallback)
*/
public void cancelAutoFocus() {
synchronized (mCameraLock) {
if (mCamera != null) {
mCamera.cancelAutoFocus();
}
}
}
代码示例来源:origin: googlesamples/android-vision
/**
* Cancels any auto-focus function in progress.
* Whether or not auto-focus is currently in progress,
* this function will return the focus position to the default.
* If the camera does not support auto-focus, this is a no-op.
*
* @see #autoFocus(AutoFocusCallback)
*/
public void cancelAutoFocus() {
synchronized (mCameraLock) {
if (mCamera != null) {
mCamera.cancelAutoFocus();
}
}
}
代码示例来源:origin: rmtheis/android-ocr
synchronized void stop() {
if (useAutoFocus) {
camera.cancelAutoFocus();
}
if (outstandingTask != null) {
outstandingTask.cancel();
outstandingTask = null;
}
active = false;
manual = false;
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
synchronized void stop() {
stopped = true;
if (useAutoFocus) {
cancelOutstandingTask();
// Doesn't hurt to call this even if not focusing
try {
camera.cancelAutoFocus();
} catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue?
Log.w(TAG, "Unexpected exception while cancelling focusing", re);
}
}
}
代码示例来源:origin: journeyapps/zxing-android-embedded
/**
* Stop auto-focus.
*/
public void stop() {
stopped = true;
focusing = false;
cancelOutstandingTask();
if (useAutoFocus) {
// Doesn't hurt to call this even if not focusing
try {
camera.cancelAutoFocus();
} catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+; continue?
Log.w(TAG, "Unexpected exception while cancelling focusing", re);
}
}
}
}
代码示例来源:origin: dm77/barcodescanner
public void stopCameraPreview() {
if(mCameraWrapper != null) {
try {
mPreviewing = false;
getHolder().removeCallback(this);
mCameraWrapper.mCamera.cancelAutoFocus();
mCameraWrapper.mCamera.setOneShotPreviewCallback(null);
mCameraWrapper.mCamera.stopPreview();
} catch(Exception e) {
Log.e(TAG, e.toString(), e);
}
}
}
代码示例来源:origin: dm77/barcodescanner
public void setAutoFocus(boolean state) {
if(mCameraWrapper != null && mPreviewing) {
if(state == mAutoFocus) {
return;
}
mAutoFocus = state;
if(mAutoFocus) {
if (mSurfaceCreated) { // check if surface created before using autofocus
Log.v(TAG, "Starting autofocus");
safeAutoFocus();
} else {
scheduleAutoFocus(); // wait 1 sec and then do check again
}
} else {
Log.v(TAG, "Cancelling autofocus");
mCameraWrapper.mCamera.cancelAutoFocus();
}
}
}
代码示例来源:origin: vondear/RxTool
@Override
void takePicture() {
if (!isCameraOpened()) {
throw new IllegalStateException(
"Camera is not ready. Call start() before takePicture().");
}
if (getAutoFocus()) {
mCamera.cancelAutoFocus();
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
takePictureInternal();
}
});
} else {
takePictureInternal();
}
}
代码示例来源:origin: vondear/RxTool
Rect meteringRect = calculateTapArea(event.getX(), event.getY(), 1.5f, previewSize);
camera.cancelAutoFocus();
代码示例来源:origin: google/cameraview
@Override
void takePicture() {
if (!isCameraOpened()) {
throw new IllegalStateException(
"Camera is not ready. Call start() before takePicture().");
}
if (getAutoFocus()) {
mCamera.cancelAutoFocus();
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
takePictureInternal();
}
});
} else {
takePictureInternal();
}
}
代码示例来源:origin: LaiFeng-Android/SopCastComponent
public boolean doAutofocus(Camera.AutoFocusCallback focusCallback) {
if(mState != State.PREVIEW || mCameraDevice == null) {
return false;
}
// Make sure our auto settings aren't locked
Camera.Parameters params = mCameraDevice.getParameters();
if (params.isAutoExposureLockSupported()) {
params.setAutoExposureLock(false);
}
if (params.isAutoWhiteBalanceLockSupported()) {
params.setAutoWhiteBalanceLock(false);
}
mCameraDevice.setParameters(params);
mCameraDevice.cancelAutoFocus();
mCameraDevice.autoFocus(focusCallback);
return true;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testCancelAutoFocus() {
assertThat(shadowCamera.hasRequestedAutoFocus()).isFalse();
camera.autoFocus(null);
assertThat(shadowCamera.hasRequestedAutoFocus()).isTrue();
camera.cancelAutoFocus();
assertThat(shadowCamera.hasRequestedAutoFocus()).isFalse();
}
代码示例来源:origin: zcolin/ZEasyPR
@Override
public void onAutoFocus(boolean success, Camera arg1) {
if (success) {
reStartPreView();
mCamera.cancelAutoFocus();// 只有加上了这一句,才会自动对焦。
}
}
});
代码示例来源:origin: blockchain/Android-Merchant-App
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return, so stop the preview.
if (mCamera != null) {
mCamera.cancelAutoFocus();
mCamera.stopPreview();
}
}
代码示例来源:origin: runner365/android_rtmppush_sdk
@Override
public void onAutoFocus(boolean success, Camera camera) {
if (success) {
InitCamera();
camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。
}
}
});
代码示例来源:origin: Yuphee/RecordVideo
/**
* 自动对焦
*/
public void autoFocus() {
mCamera.cancelAutoFocus();
mCamera.autoFocus(null);
}
代码示例来源:origin: FacePlusPlus/MegviiFacepp-Android-SDK
private void autoFocus() {
if (mCamera != null && isBackCamera) {
mCamera.cancelAutoFocus();
Parameters parameters = mCamera.getParameters();
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
mCamera.setParameters(parameters);
mCamera.autoFocus(null);
}
}
代码示例来源:origin: zxfnicholas/CameraSDK
private void pointFocus(int x, int y) {
cameraInst.cancelAutoFocus();
parameters = cameraInst.getParameters();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
showPoint(x, y);
}
cameraInst.setParameters(parameters);
autoFocus();
}
代码示例来源:origin: sxpl/FaceAC
public void pointFocus(MotionEvent event) {
mCamera.cancelAutoFocus();
parameters = mCamera.getParameters();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
//showPoint(x, y);
focusOnTouch(event);
}
mCamera.setParameters(parameters);
autoFocus();
}
内容来源于网络,如有侵权,请联系作者删除!