本文整理汇总了Java中android.hardware.Camera.Parameters方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.Parameters方法的具体用法?Java Camera.Parameters怎么用?Java Camera.Parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.Parameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openCamera
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void openCamera() {
Camera.CameraInfo info = new Camera.CameraInfo();
// Try to find a front-facing camera (e.g. for videoconferencing).
int numCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numCameras; i++) {
Camera.getCameraInfo(i, info);
if (info.facing == currentCamera) {
camera = Camera.open(i);
break;
}
}
if (camera == null) {
camera = Camera.open();
}
Camera.Parameters parms = camera.getParameters();
CameraUtils.choosePreviewSize(parms, previewWidth, previewHeight);
isOpened = true;
}
示例2: initFromCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
public void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point theScreenResolution = new Point();
theScreenResolution = getDisplaySize(display);
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
/** 因为换成了竖屏显示,所以不替换屏幕宽高得出的预览图是变形的 */
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
cameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera);
Log.i(TAG, "Camera resolution x: " + cameraResolution.x);
Log.i(TAG, "Camera resolution y: " + cameraResolution.y);
}
示例3: resetCam
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Resets camera parameters and starts camera preview.
*/
private void resetCam() {
try {
Camera.Parameters parameters = mCamera.getParameters();
logi("Set Flash mode ON");
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
mCamera.setParameters(parameters);
mCamera.startPreview();
mCamera.autoFocus(new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
//TODO: add implementation or leave a comment if it's nothing to do here
}
});
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(parameters);
} catch(RuntimeException e) {
Log.e(TAG, e.toString());
}
}
示例4: setZoom
import android.hardware.Camera; //导入方法依赖的package包/类
public static void setZoom(Camera.Parameters parameters, double targetZoomRatio) {
if (parameters.isZoomSupported()) {
Integer zoom = indexOfClosestZoom(parameters, targetZoomRatio);
if (zoom == null) {
return;
}
if (parameters.getZoom() == zoom) {
Log.i(TAG, "Zoom is already set to " + zoom);
} else {
Log.i(TAG, "Setting zoom to " + zoom);
parameters.setZoom(zoom);
}
} else {
Log.i(TAG, "Zoom is not supported");
}
}
示例5: turnOffFlashLight
import android.hardware.Camera; //导入方法依赖的package包/类
public boolean turnOffFlashLight() {
if (camera != null) {
handler.removeCallbacksAndMessages(null);
Camera.Parameters parameter = camera.getParameters();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
parameter.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
} else {
parameter.set("flash-mode", "off");
}
camera.setParameters(parameter);
camera.stopPreview();
camera.release();
camera = null;
}
return true;
}
示例6: initFromCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
public void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point theScreenResolution = new Point();
theScreenResolution = getDisplaySize(display);
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
/** 因为换成了竖屏显示,所以不替换屏幕宽高得出的预览图是变形的 */
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
cameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera);
Log.i(TAG, "Camera resolution x: " + cameraResolution.x);
Log.i(TAG, "Camera resolution y: " + cameraResolution.y);
}
示例7: setFlash
import android.hardware.Camera; //导入方法依赖的package包/类
private void setFlash(Camera.Parameters parameters) {
// FIXME: This is getUrl hack to turn the flash off on the Samsung Galaxy.
// And this is getUrl hack-hack to work around getUrl different value on the Behold II
// Restrict Behold II check to Cupcake, per Samsung's advice
//if (Build.MODEL.contains("Behold II") &&
// CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
parameters.set("flash-value", 1);
} else {
parameters.set("flash-value", 2);
}
// This is the standard setting to turn the flash off that all devices should honor.
parameters.set("flash-mode", "off");
}
示例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;
}
}
}
示例9: initFromCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Reads, one time, values from the camera that are needed by the app.
*/
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format");
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenResolution = new Point(display.getWidth(), display.getHeight());
Log.d(TAG, "Screen resolution: " + screenResolution);
// //Lemon add 扫描框修改,解决拉伸但导致成像模糊识别率很低。<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Point screenResolutionForCamera = new Point();
// screenResolutionForCamera.x = screenResolution.x;
// screenResolutionForCamera.y = screenResolution.y;
// // preview size is always something like 480*320, other 320*480
// if (screenResolution.x < screenResolution.y) {
// screenResolutionForCamera.x = screenResolution.y;
// screenResolutionForCamera.y = screenResolution.x;
// }
//Lemon add 扫描框修改,解决拉伸>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//Lemon 扫描框修改,解决拉伸但导致成像模糊识别率很低 screenResolution改为screenResolutionForCamera);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
cameraResolution = getCameraResolution(parameters, screenResolution);
Log.d(TAG, "Camera resolution: " + screenResolution);
//Lemon 扫描框修改,解决拉伸但导致成像模糊识别率很低 screenResolution改为screenResolutionForCamera);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
}
示例10: setBarcodeSceneMode
import android.hardware.Camera; //导入方法依赖的package包/类
public static void setBarcodeSceneMode(Camera.Parameters parameters) {
if (Camera.Parameters.SCENE_MODE_BARCODE.equals(parameters.getSceneMode())) {
Log.i(TAG, "Barcode scene mode already set");
return;
}
String sceneMode = findSettableValue("scene mode",
parameters.getSupportedSceneModes(),
Camera.Parameters.SCENE_MODE_BARCODE);
if (sceneMode != null) {
parameters.setSceneMode(sceneMode);
}
}
示例11: setCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
public void setCameraParameters(Camera.Parameters params) {
cameraParameters = params;
if (mCamera != null && cameraParameters != null) {
mCamera.setParameters(cameraParameters);
}
}
示例12: getTorchState
import android.hardware.Camera; //导入方法依赖的package包/类
boolean getTorchState(Camera camera) {
if (camera != null) {
Camera.Parameters parameters = camera.getParameters();
if (parameters != null) {
String flashMode = parameters.getFlashMode();
return flashMode != null &&
(Camera.Parameters.FLASH_MODE_ON.equals(flashMode) ||
Camera.Parameters.FLASH_MODE_TORCH.equals(flashMode));
}
}
return false;
}
示例13: refreshCamera
import android.hardware.Camera; //导入方法依赖的package包/类
public void refreshCamera() {
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
camera.setParameters(parameters);
try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
} catch (IOException e) {
Log.e(TAG, "Error starting camera preview: " + e.getMessage());
}
}
示例14: setDesiredCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
public void setDesiredCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
setZoom(parameters);
camera.setDisplayOrientation(getDisplayOrientation());
camera.setParameters(parameters);
}
示例15: setDefaultCameraParameters
import android.hardware.Camera; //导入方法依赖的package包/类
public void setDefaultCameraParameters(Camera camera, Camera.CameraInfo cameraInfo) {
Camera.Parameters parameters = camera.getParameters();
parameters.setPictureFormat(ImageFormat.JPEG);
List<Camera.Size> supportedSizes = parameters.getSupportedPictureSizes();
Camera.Size pictureSize = getBestSize(supportedSizes, 0);
parameters.setPictureSize(pictureSize.width, pictureSize.height);
float whRatio = (float) pictureSize.width / pictureSize.height;
List<Camera.Size> previewSupportedSizes = parameters.getSupportedPreviewSizes();
Camera.Size previewSize = getBestSize(previewSupportedSizes, whRatio);
parameters.setPreviewSize(previewSize.width, previewSize.height);
List<String> supportedFocusModes = camera.getParameters().getSupportedFocusModes();
boolean hasAutoFocus = supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO);
if(hasAutoFocus) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
if(cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
}
List<String> supportedScreenModes = camera.getParameters().getSupportedSceneModes();
boolean hasAutoScene = supportedScreenModes != null && supportedFocusModes.contains(Camera.Parameters.SCENE_MODE_AUTO);
if(hasAutoScene) {
parameters.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
}
parameters.setColorEffect(Camera.Parameters.EFFECT_NONE);
int orientation = cameraInfo.orientation;
parameters.setRotation(orientation);
camera.setParameters(parameters);
}