本文整理汇总了Java中android.hardware.Camera.cancelAutoFocus方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.cancelAutoFocus方法的具体用法?Java Camera.cancelAutoFocus怎么用?Java Camera.cancelAutoFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.cancelAutoFocus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: safeAutoFocusCamera
import android.hardware.Camera; //导入方法依赖的package包/类
private void safeAutoFocusCamera() {
if (!mInitialized || !mPreviewActive) {
return;
}
if (!mDecoderWrapper.isAutoFocusSupported() || !mAutoFocusEnabled) {
return;
}
if (mSafeAutoFocusing && mSafeAutoFocusAttemptsCount < SAFE_AUTO_FOCUS_ATTEMPTS_THRESHOLD) {
mSafeAutoFocusAttemptsCount++;
} else {
try {
Camera camera = mDecoderWrapper.getCamera();
camera.cancelAutoFocus();
camera.autoFocus(mSafeAutoFocusCallback);
mSafeAutoFocusAttemptsCount = 0;
mSafeAutoFocusing = true;
} catch (Exception e) {
mSafeAutoFocusing = false;
}
}
scheduleSafeAutoFocusTask();
}
示例2: setTorchEnabled
import android.hardware.Camera; //导入方法依赖的package包/类
private static void setTorchEnabled(final Camera camera, final boolean enabled) {
final Camera.Parameters parameters = camera.getParameters();
final List<String> supportedFlashModes = parameters.getSupportedFlashModes();
if (supportedFlashModes != null) {
final String flashMode;
if (enabled)
flashMode = findValue(supportedFlashModes, Camera.Parameters.FLASH_MODE_TORCH,
Camera.Parameters.FLASH_MODE_ON);
else
flashMode = findValue(supportedFlashModes, Camera.Parameters.FLASH_MODE_OFF);
if (flashMode != null) {
camera.cancelAutoFocus(); // autofocus can cause conflict
parameters.setFlashMode(flashMode);
camera.setParameters(parameters);
}
}
}
示例3: setAutoFocusEnabledInternal
import android.hardware.Camera; //导入方法依赖的package包/类
private void setAutoFocusEnabledInternal(boolean autoFocusEnabled) {
try {
Camera camera = mDecoderWrapper.getCamera();
Camera.Parameters parameters = camera.getParameters();
if (parameters == null) {
return;
}
boolean changed;
AutoFocusMode autoFocusMode = mAutoFocusMode;
if (autoFocusEnabled) {
changed = Utils.setAutoFocusMode(parameters, autoFocusMode);
} else {
camera.cancelAutoFocus();
changed = Utils.disableAutoFocus(parameters);
}
if (changed) {
camera.setParameters(parameters);
}
if (autoFocusEnabled) {
mSafeAutoFocusAttemptsCount = 0;
mSafeAutoFocusing = false;
if (autoFocusMode == AutoFocusMode.SAFE) {
scheduleSafeAutoFocusTask();
}
}
} catch (Exception ignored) {
}
}
示例4: setStartPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* 设置camera显示取景画面,并预览
*
* @param camera
*/
private void setStartPreview(Camera camera, SurfaceHolder holder) {
try {
if (null != camera) {
// 通过surfaceview显示取景画面
parameters = camera.getParameters(); // 获取各项参数
//矫正拍照之后图片的旋转的角度
if (!startFontCamera) {
parameters.setRotation(270);
} else {
parameters.setRotation(getPreviewDegree(CameraActivity.this));
}
// Size largestSize = getBestSupportedSize(parameters
// .getSupportedPreviewSizes());
// parameters.setPreviewSize(largestSize.width, largestSize.height);// 设置预览图片尺寸
Size largestSize = getBestSupportedSize(parameters
.getSupportedPictureSizes());// 设置捕捉图片尺寸
parameters.setPictureSize(largestSize.width, largestSize.height);
if (startFontCamera) {
//连续对焦
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
camera.setParameters(parameters);
camera.setPreviewDisplay(holder);
// 设置用于显示拍照影像的SurfaceHolder对象
camera.setDisplayOrientation(getPreviewDegree(CameraActivity.this));
camera.startPreview();
camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。
} else {
//
Toast.makeText(this, "无法打开摄像头,请检查是否给开启了相关权限", Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
}
}
示例5: setCameraParams
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* 在摄像头启动前设置参数
*
* @param camera
* @param width
* @param height
*/
private void setCameraParams(Camera camera, int width, int height) {
// 获取摄像头支持的pictureSize列表
Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> pictureSizeList = parameters.getSupportedPictureSizes();
// 从列表中选择合适的分辨率
Point pictureSize = FaceUtil.findBestResolution(pictureSizeList, new Point(width, height), true, 0.15f);
// 根据选出的PictureSize重新设置SurfaceView大小
parameters.setPictureSize(pictureSize.x, pictureSize.y);
// 获取摄像头支持的PreviewSize列表
List<Camera.Size> previewSizeList = parameters.getSupportedPreviewSizes();
Point preSize = FaceUtil.findBestResolution(previewSizeList, new Point(width, height), false, 0.15f);
parameters.setPreviewSize(preSize.x, preSize.y);
float w = preSize.x;
float h = preSize.y;
float scale = 1.0f;
int tempW = (int) (height * (h / w));
int tempH = (int) (width * (w / h));
if (tempW >= width) {
setLayoutParams(new FrameLayout.LayoutParams(tempW, height));
scale = tempW / h;
} else if (tempH >= height) {
setLayoutParams(new FrameLayout.LayoutParams(width, tempH));
scale = tempH / w;
} else {
setLayoutParams(new FrameLayout.LayoutParams(width, height));
}
if (mFaceDetector != null) {
mFaceDetector.setZoomRatio(5f * scale);
mFaceDetector.setPreviewWidth((int) w);
mFaceDetector.setPreviewHeight((int) h);
}
parameters.setJpegQuality(100);
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
// 连续对焦
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
camera.cancelAutoFocus();
setCameraDisplayOrientation();
camera.setParameters(parameters);
}