本文整理匯總了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);
}