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


Java Camera.Area方法代碼示例

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


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

示例1: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setFocusArea(Camera.Parameters parameters) {
  if (parameters.getMaxNumFocusAreas() > 0) {
    Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
    List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
    Log.i(TAG, "Setting focus area to : " + toString(middleArea));
    parameters.setFocusAreas(middleArea);
  } else {
    Log.i(TAG, "Device does not support focus areas");
  }
}
 
開發者ID:kkyflying,項目名稱:CodeScaner,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例2: toString

import android.hardware.Camera; //導入方法依賴的package包/類
private static String toString(Iterable<Camera.Area> areas) {
  if (areas == null) {
    return null;
  }
  StringBuilder result = new StringBuilder();
  for (Camera.Area area : areas) {
    result.append(area.rect).append(':').append(area.weight).append(' ');
  }
  return result.toString();
}
 
開發者ID:kkyflying,項目名稱:CodeScaner,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例3: setMetering

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setMetering(Camera.Parameters parameters) {
	if (parameters.getMaxNumMeteringAreas() > 0) {
		Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
		List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
		Log.i(TAG, "Setting metering area to : " + toString(middleArea));
		parameters.setMeteringAreas(middleArea);
	} else {
		Log.i(TAG, "Device does not support metering areas");
	}
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例4: setMetering

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setMetering(Camera.Parameters parameters) {
    if (parameters.getMaxNumMeteringAreas() > 0) {
        LogEx.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        LogEx.i(TAG, "Setting metering area to : " + toString(middleArea));
        parameters.setMeteringAreas(middleArea);
    } else {
        LogEx.i(TAG, "Device does not support metering areas");
    }
}
 
開發者ID:CoderChoy,項目名稱:BarcodeReaderView,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例5: setMetering

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setMetering(Camera.Parameters parameters) {
    if (parameters.getMaxNumMeteringAreas() > 0) {
        Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        Log.i(TAG, "Setting metering area to : " + toString(middleArea));
        parameters.setMeteringAreas(middleArea);
    } else {
        Log.i(TAG, "Device does not support metering areas");
    }
}
 
開發者ID:Zmingxu,項目名稱:ZxingScanner,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例6: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setFocusArea(Camera.Parameters parameters) {
    if (parameters.getMaxNumFocusAreas() > 0) {
        LogEx.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        LogEx.i(TAG, "Setting focus area to : " + toString(middleArea));
        parameters.setFocusAreas(middleArea);
    } else {
        LogEx.i(TAG, "Device does not support focus areas");
    }
}
 
開發者ID:CoderChoy,項目名稱:BarcodeReaderView,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例7: setMetering

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setMetering(Camera.Parameters parameters) {
  if (parameters.getMaxNumMeteringAreas() > 0) {
    Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
    List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
    Log.i(TAG, "Setting metering area to : " + toString(middleArea));
    parameters.setMeteringAreas(middleArea);
  } else {
    Log.i(TAG, "Device does not support metering areas");
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例8: startTouchAutoFocus

import android.hardware.Camera; //導入方法依賴的package包/類
public void startTouchAutoFocus(View v, MotionEvent event) {
    if ((mIsSupportAutoFocus || mIsSupportAutoFocusContinuousPicture)
            && mCamera != null
            && !mAutoFocusLocked) {
        try {
            mAutoFocusLocked = true;

            Camera.Parameters parameters = getCameraParameters();
            parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
            if (parameters.getMaxNumFocusAreas() > 0) {
                Rect focusRect =
                        CameraHelper.calculateTapArea(v, event.getX(), event.getY(), 1f);
                List<Camera.Area> focusAreas = new ArrayList<Camera.Area>();
                focusAreas.add(new Camera.Area(focusRect, 1000));
                parameters.setFocusAreas(focusAreas);
            }

            if (parameters.getMaxNumMeteringAreas() > 0) {
                Rect meteringRect =
                        CameraHelper.calculateTapArea(v, event.getX(), event.getY(), 1.5f);
                List<Camera.Area> meteringAreas = new ArrayList<Camera.Area>();
                meteringAreas.add(new Camera.Area(meteringRect, 1000));
                parameters.setMeteringAreas(meteringAreas);
            }

            mCamera.setParameters(parameters);
            mCamera.autoFocus(this);
        } catch (Exception e) {
            e.printStackTrace();
            mAutoFocusLocked = false;
        }
    }
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:34,代碼來源:CameraController.java

示例9: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
public static void setFocusArea(Camera.Parameters parameters) {
    if (parameters.getMaxNumFocusAreas() > 0) {
        Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        Log.i(TAG, "Setting focus area to : " + toString(middleArea));
        parameters.setFocusAreas(middleArea);
    } else {
        Log.i(TAG, "Device does not support focus areas");
    }
}
 
開發者ID:yinhaojun,項目名稱:ZxingForAndroid,代碼行數:12,代碼來源:CameraConfigurationUtils.java

示例10: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setFocusArea(Camera.Parameters parameters) {
	if (parameters.getMaxNumFocusAreas() > 0) {
		Log.i(TAG,
				"Old focus areas: " + toString(parameters.getFocusAreas()));
		List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
		Log.i(TAG, "Setting focus area to : " + toString(middleArea));
		parameters.setFocusAreas(middleArea);
	} else {
		Log.i(TAG, "Device does not support focus areas");
	}
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:12,代碼來源:CameraConfigurationUtils.java

示例11: setFocusArea

import android.hardware.Camera; //導入方法依賴的package包/類
public static void setFocusArea(Camera.Parameters parameters) {
    if (parameters.getMaxNumFocusAreas() > 0) {
        Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        Log.i(TAG, "Setting focus area to : " + toString(middleArea));
        parameters.setFocusAreas(middleArea);
    } else {
        Log.i(TAG, "Device does not support focus areas");
    }
}
 
開發者ID:MRYangY,項目名稱:YZxing,代碼行數:11,代碼來源:CameraConfigurationUtils.java

示例12: toString

import android.hardware.Camera; //導入方法依賴的package包/類
private static String toString(Iterable<Camera.Area> areas) {
	if (areas == null) {
		return null;
	}
	StringBuilder result = new StringBuilder();
	for (Camera.Area area : areas) {
		result.append(area.rect).append(':').append(area.weight)
				.append(' ');
	}
	return result.toString();
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:12,代碼來源:CameraConfigurationUtils.java

示例13: buildMiddleArea

import android.hardware.Camera; //導入方法依賴的package包/類
private static List<Camera.Area> buildMiddleArea(int areaPer1000) {
  return Collections.singletonList(
      new Camera.Area(new Rect(-areaPer1000, -areaPer1000, areaPer1000, areaPer1000), 1));
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:5,代碼來源:CameraConfigurationUtils.java

示例14: computeFocusAreaFromMotionEvent

import android.hardware.Camera; //導入方法依賴的package包/類
/**
 * Computes a Camera.Area corresponding to the new focus area to focus the camera on. This is
 * done by deriving a square around the center of a MotionEvent pointer (with side length equal
 * to FOCUS_AREA_MOTION_EVENT_EDGE_LENGTH), then transforming this rectangle's/square's
 * coordinates into the (-1000, 1000) coordinate system used for camera focus areas.
 *
 * Also note that we operate on RectF instances for the most part, to avoid any integer
 * division rounding errors going forward. We only round at the very end for playing into
 * the final focus areas list.
 *
 * @throws RuntimeException if unable to compute valid intersection between MotionEvent region
 * and SurfaceTexture region.
 */
protected static Camera.Area computeFocusAreaFromMotionEvent(final MotionEvent event, final int surfaceTextureWidth, final int surfaceTextureHeight) {
    // Get position of first touch pointer.
    final int pointerId = event.getPointerId(0);
    final int pointerIndex = event.findPointerIndex(pointerId);
    final float centerX = event.getX(pointerIndex);
    final float centerY = event.getY(pointerIndex);

    // Build event rect. Note that coordinates increase right and down, such that left <= right
    // and top <= bottom.
    final RectF eventRect = new RectF(
            centerX - FOCUS_AREA_MOTION_EVENT_EDGE_LENGTH, // left
            centerY - FOCUS_AREA_MOTION_EVENT_EDGE_LENGTH, // top
            centerX + FOCUS_AREA_MOTION_EVENT_EDGE_LENGTH, // right
            centerY + FOCUS_AREA_MOTION_EVENT_EDGE_LENGTH // bottom
    );

    // Intersect this rect with the rect corresponding to the full area of the parent surface
    // texture, making sure we are not placing any amount of the eventRect outside the parent
    // surface's area.
    final RectF surfaceTextureRect = new RectF(
            (float) 0, // left
            (float) 0, // top
            (float) surfaceTextureWidth, // right
            (float) surfaceTextureHeight // bottom
    );
    final boolean intersectSuccess = eventRect.intersect(surfaceTextureRect);
    if (!intersectSuccess) {
        throw new RuntimeException(
                "MotionEvent rect does not intersect with SurfaceTexture rect; unable to " +
                        "compute focus area"
        );
    }

    // Transform into (-1000, 1000) focus area coordinate system. See
    // https://developer.android.com/reference/android/hardware/Camera.Area.html.
    // Note that if this is ever changed to a Rect instead of RectF, be cautious of integer
    // division rounding!
    final RectF focusAreaRect = new RectF(
            (eventRect.left / surfaceTextureWidth) * 2000 - 1000, // left
            (eventRect.top / surfaceTextureHeight) * 2000 - 1000, // top
            (eventRect.right / surfaceTextureWidth) * 2000 - 1000, // right
            (eventRect.bottom / surfaceTextureHeight) * 2000 - 1000 // bottom
    );
    Rect focusAreaRectRounded = new Rect();
    focusAreaRect.round(focusAreaRectRounded);
    return new Camera.Area(focusAreaRectRounded, FOCUS_AREA_WEIGHT);
}
 
開發者ID:entria,項目名稱:react-native-camera-face-detector,代碼行數:61,代碼來源:RCTCameraUtils.java

示例15: buildMiddleArea

import android.hardware.Camera; //導入方法依賴的package包/類
private static List<Camera.Area> buildMiddleArea(int areaPer1000) {
    return Collections.singletonList(
            new Camera.Area(new Rect(-areaPer1000, -areaPer1000, areaPer1000, areaPer1000), 1));
}
 
開發者ID:MRYangY,項目名稱:YZxing,代碼行數:5,代碼來源:CameraConfigurationUtils.java


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