當前位置: 首頁>>代碼示例>>Java>>正文


Java Camera.AutoFocusCallback方法代碼示例

本文整理匯總了Java中android.hardware.Camera.AutoFocusCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java Camera.AutoFocusCallback方法的具體用法?Java Camera.AutoFocusCallback怎麽用?Java Camera.AutoFocusCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.Camera的用法示例。


在下文中一共展示了Camera.AutoFocusCallback方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startAutoFocus

import android.hardware.Camera; //導入方法依賴的package包/類
public boolean startAutoFocus(Camera.AutoFocusCallback autoFocusCallback) {
    if ((mIsSupportAutoFocus || mIsSupportAutoFocusContinuousPicture) && mCamera != null) {
        try {

            String focusMode = getCameraParameters().getFocusMode();

            if (!TextUtils.isEmpty(focusMode) && focusMode.
                    equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {  // 如果是連續自動對焦, 來一次對焦處理
                mCamera.autoFocus(autoFocusCallback);
            } else {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    return false;
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:22,代碼來源:CameraController.java

示例2: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
public void setFocusArea(final int pointX, final int pointY, final Camera.AutoFocusCallback callback) {
  if (mCamera != null) {

    mCamera.cancelAutoFocus();

    Camera.Parameters parameters = mCamera.getParameters();

    Rect focusRect = calculateTapArea(pointX, pointY, 1f);
    parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    parameters.setFocusAreas(Arrays.asList(new Camera.Area(focusRect, 1000)));

    if (parameters.getMaxNumMeteringAreas() > 0) {
      Rect meteringRect = calculateTapArea(pointX, pointY, 1.5f);
      parameters.setMeteringAreas(Arrays.asList(new Camera.Area(meteringRect, 1000)));
    }

    try {
      setCameraParameters(parameters);
      mCamera.autoFocus(callback);
    } catch (Exception e) {
      Log.d(TAG, e.getMessage());
      callback.onAutoFocus(false, this.mCamera);
    }
  }
}
 
開發者ID:MrShakes,項目名稱:cameraPreviewStream,代碼行數:26,代碼來源:CameraActivity.java

示例3: focus

import android.hardware.Camera; //導入方法依賴的package包/類
/**
 * 自動對焦
 */
private boolean focus(Camera.AutoFocusCallback callback) {
    try {
        camera.autoFocus(callback);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
開發者ID:AndroidEngineerChenXiaoshuang,項目名稱:CSVideo,代碼行數:13,代碼來源:CsVideo.java

示例4: autoFocusAsync

import android.hardware.Camera; //導入方法依賴的package包/類
public static void autoFocusAsync(Camera.AutoFocusCallback autoFocusCallback)
{
    getInstance().mCamera.autoFocus(autoFocusCallback);
}
 
開發者ID:ravindu1024,項目名稱:android-imaging-utils,代碼行數:5,代碼來源:CameraController.java

示例5: autoFocus

import android.hardware.Camera; //導入方法依賴的package包/類
@Override
public void autoFocus(Camera.AutoFocusCallback cb) {
    camera.autoFocus(cb);
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:5,代碼來源:DefaultEasyCamera.java

示例6: autoFocus

import android.hardware.Camera; //導入方法依賴的package包/類
/**
* See <a href="http://developer.android.com/reference/android/hardware/Camera.html#autoFocus%28android.hardware.Camera.AutoFocusCallback%29">Camera.autoFocus(..)</a>
*/
  void autoFocus(Camera.AutoFocusCallback cb);
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:5,代碼來源:EasyCamera.java


注:本文中的android.hardware.Camera.AutoFocusCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。