当前位置: 首页>>代码示例>>Java>>正文


Java Camera.Parameters方法代码示例

本文整理汇总了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;
}
 
开发者ID:ChillingVan,项目名称:AndroidInstantVideo,代码行数:23,代码来源:InstantVideoCamera.java

示例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);
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:25,代码来源:CameraConfigurationManager.java

示例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());
    }
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:22,代码来源:CameraActivity_OldAPI.java

示例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");
    }
}
 
开发者ID:MRYangY,项目名称:YZxing,代码行数:17,代码来源:CameraConfigurationUtils.java

示例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;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:17,代码来源:FlashLight.java

示例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);
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:25,代码来源:CameraConfigurationManager.java

示例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");
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:15,代码来源:CameraConfigurationManager.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: 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);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:CameraConfigurationManager.java

示例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);
    }
}
 
开发者ID:Zmingxu,项目名称:ZxingScanner,代码行数:13,代码来源:CameraConfigurationUtils.java

示例11: setCameraParameters

import android.hardware.Camera; //导入方法依赖的package包/类
public void setCameraParameters(Camera.Parameters params) {
  cameraParameters = params;

  if (mCamera != null && cameraParameters != null) {
    mCamera.setParameters(cameraParameters);
  }
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:8,代码来源:CameraActivity.java

示例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;
}
 
开发者ID:MRYangY,项目名称:YZxing,代码行数:13,代码来源:CameraConfigurationManager.java

示例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());
    }
}
 
开发者ID:marcplouhinec,项目名称:speaking-glasses,代码行数:13,代码来源:CameraPreview.java

示例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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:9,代码来源:RCameraPreview.java

示例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);
}
 
开发者ID:cuonghuynhvan,项目名称:react-native-camera-android-simple,代码行数:40,代码来源:CameraManager.java


注:本文中的android.hardware.Camera.Parameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。