本文整理汇总了Java中android.hardware.Camera.Parameters.setFocusMode方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.setFocusMode方法的具体用法?Java Parameters.setFocusMode怎么用?Java Parameters.setFocusMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.setFocusMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFocusMode
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@UiThread
private void setFocusMode(Parameters params) {
List<String> focusModes = params.getSupportedFocusModes();
if (LOG.isLoggable(INFO)) LOG.info("Focus modes: " + focusModes);
if (focusModes.contains(FOCUS_MODE_CONTINUOUS_PICTURE)) {
params.setFocusMode(FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (focusModes.contains(FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(FOCUS_MODE_CONTINUOUS_VIDEO);
} else if (focusModes.contains(FOCUS_MODE_EDOF)) {
params.setFocusMode(FOCUS_MODE_EDOF);
} else if (focusModes.contains(FOCUS_MODE_MACRO)) {
params.setFocusMode(FOCUS_MODE_MACRO);
} else if (focusModes.contains(FOCUS_MODE_AUTO)) {
params.setFocusMode(FOCUS_MODE_AUTO);
} else if (focusModes.contains(FOCUS_MODE_FIXED)) {
params.setFocusMode(FOCUS_MODE_FIXED);
}
}
示例2: configFocusMode
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public BarcodeCameraConfig configFocusMode() {
try {
Parameters parameters = camera.getParameters();
String focusMode = findValue(parameters.getSupportedFocusModes(),
Parameters.FOCUS_MODE_AUTO,
Parameters.FOCUS_MODE_MACRO);
if (focusMode != null) {
parameters.setFocusMode(focusMode);
}
camera.setParameters(parameters);
} catch (Exception e) {
}
return this;
}
示例3: setUpCamera
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void setUpCamera(final int id) {
mCameraInstance = getCameraInstance(id);
Parameters parameters = mCameraInstance.getParameters();
// TODO adjust by getting supportedPreviewSizes and then choosing
// the best one for screen size (best fill screen)
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
mCameraInstance.setParameters(parameters);
int orientation = mCameraHelper.getCameraDisplayOrientation(
ActivityCamera.this, mCurrentCameraId);
CameraInfo2 cameraInfo = new CameraInfo2();
mCameraHelper.getCameraInfo(mCurrentCameraId, cameraInfo);
boolean flipHorizontal = cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT;
mGPUImage.setUpCamera(mCameraInstance, orientation, flipHorizontal, false);
}
示例4: setupCameraAndStartPreview
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void setupCameraAndStartPreview(SurfaceHolder sf, Size sz, int displayRotation) {
stopCameraPreview();
cameraRotationDegree = CameraHelper.setCameraDisplayOrientation(defaultCameraID, camera, displayRotation);
chooseCamcorderProfile(sz);
// tweak profile
profile.fileFormat = MediaRecorder.OutputFormat.THREE_GPP;
profile.audioSampleRate = 16000;
profile.audioChannels = 1;
profile.audioBitRate = 96000;
Parameters param = camera.getParameters();
param.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
param.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
if (Build.VERSION.SDK_INT >= 14)
param.setRecordingHint(true);
camera.setParameters(param);
if (setDisplay(sf)) {
startCameraPreview();
}
}
示例5: startPreview
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void startPreview(SurfaceHolder holder) {
try {
Parameters params = camera.getParameters();
if (params.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_AUTO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
List<Size> previewSizes = camera.getParameters().getSupportedPreviewSizes();
List<Size> pictureSizes = camera.getParameters().getSupportedPictureSizes();
params.setPreviewSize(previewSizes.get(previewSizes.size()-2).width,previewSizes.get(previewSizes.size()-2).height);
params.setPictureSize(pictureSizes.get(pictureSizes.size()-2).width,pictureSizes.get(pictureSizes.size()-2).height);
camera.setParameters(params);
camera.setPreviewDisplay(holder);
camera.startPreview();
previewConsumer.start(camera);
} catch(IOException e) {
Log.e(TAG, "Error starting camera preview", e);
}
}
示例6: onCameraReady
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@TargetApi(14)
private void onCameraReady(final @NonNull Camera camera) {
final Parameters parameters = camera.getParameters();
if (VERSION.SDK_INT >= 14) {
parameters.setRecordingHint(true);
final List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
}
displayOrientation = CameraUtils.getCameraDisplayOrientation(getActivity(), getCameraInfo());
camera.setDisplayOrientation(displayOrientation);
camera.setParameters(parameters);
enqueueTask(new PostInitializationTask<Void>() {
@Override
protected Void onRunBackground() {
try {
camera.setPreviewDisplay(surface.getHolder());
startPreview(parameters);
} catch (Exception e) {
Log.w(TAG, "couldn't set preview display", e);
}
return null;
}
});
}
示例7: setDefaultParameters
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private static void setDefaultParameters(){
Parameters parameters = mCamera.getParameters();
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
Size previewSize = getLargePreviewSize();
parameters.setPreviewSize(1280, 720);
Size pictureSize = getLargePictureSize();
parameters.setPictureSize(pictureSize.width, pictureSize.height);
mCamera.setParameters(parameters);
}
示例8: autoFocus
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void autoFocus() {
if (mCamera != null && isBackCamera) {
mCamera.cancelAutoFocus();
Parameters parameters = mCamera.getParameters();
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
mCamera.setParameters(parameters);
mCamera.autoFocus(null);
}
}
示例9: setCamera
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void setCamera(Camera camera) {
mCamera = camera;
if (mCamera != null) {
Parameters parameters = mCamera.getParameters();
mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
List<Integer> formatsList = parameters.getSupportedPreviewFormats(); //get supported preview formats
if(formatsList.contains(ImageFormat.NV21)) { // formatsList is always not null.
parameters.setPreviewFormat(ImageFormat.NV21); //set preview format is NV21,default is NV21 (yuv420sp)
}
// Set Focus mode depending on what is supported. MODE_AUTO is
// preferred mode.
// need not to test supported mode coz it has been tested in main activity.
if (msnFocusMode == 2) {
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_INFINITY );
} else if (msnFocusMode == 1) {
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_FIXED );
} else {
// set to auto focus by default
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_AUTO);
}
/*if ((parameters.getMaxExposureCompensation() != 0 || parameters.getMinExposureCompensation() != 0)
&& ActivitySettings.msnPhotoTakenFrom == 1) { // screen mode.
parameters.setExposureCompensation(parameters.getMaxExposureCompensation());
} */
parameters.setExposureCompensation(0); // exposure is not adjusted. Seems that screen mode does not bring much benefit.
List<String> scenesList = parameters.getSupportedSceneModes();
if (scenesList != null && scenesList.contains(Camera.Parameters.SCENE_MODE_STEADYPHOTO)) {
parameters.setSceneMode(Camera.Parameters.SCENE_MODE_STEADYPHOTO); // this may crash in some devices.
}
boolean bSuccessful = setCameraParams(mCamera, parameters);
requestLayout();
}
}
示例10: startPreview
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void startPreview(SurfaceHolder holder) {
try {
mCamera.setPreviewDisplay(holder);
mCamera.setDisplayOrientation(cameraDisplayOrientation);
Parameters parameters = mCamera.getParameters();
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
mCamera.setParameters(parameters);
mCamera.startPreview();
} catch (Exception e) {
}
}
示例11: setDefaultParameters
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private static void setDefaultParameters(){
Parameters parameters = camera.getParameters();
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
Size previewSize = CameraUtils.getLargePreviewSize(camera);
parameters.setPreviewSize(previewSize.width, previewSize.height);
Size pictureSize = CameraUtils.getLargePictureSize(camera);
parameters.setPictureSize(pictureSize.width, pictureSize.height);
parameters.setRotation(90);
camera.setParameters(parameters);
}
示例12: updateCamera
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
protected synchronized void updateCamera() throws RuntimeException {
// The camera is already correctly configured
if (mUpdated) return;
if (mPreviewStarted) {
mPreviewStarted = false;
mCamera.stopPreview();
}
Parameters parameters = mCamera.getParameters();
mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality);
int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters);
double ratio = (double)mQuality.resX/(double)mQuality.resY;
mSurfaceView.requestAspectRatio(ratio);
parameters.setPreviewFormat(mCameraImageFormat);
parameters.setPreviewSize(mQuality.resX, mQuality.resY);
//int cur_fr = mQuality.framerate * 1000;
//if(max[0] < cur_fr && cur_fr < max[1])
// max[0] = max[1] = cur_fr;
parameters.setPreviewFpsRange(max[0], max[1]);
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); //focus
try {
mCamera.setParameters(parameters);
mCamera.setDisplayOrientation(mOrientation);
mCamera.startPreview();
//mCamera.cancelAutoFocus();
mPreviewStarted = true;
mUpdated = true;
} catch (RuntimeException e) {
destroyCamera();
throw e;
}
}
示例13: setupCaptureParams
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void setupCaptureParams(Parameters parameters) {
List<Size> supportedSizes = parameters.getSupportedPreviewSizes();
if (!findBestPreviewSize(supportedSizes, true, true)) {
Log.w(TAG, "No 4:3 ratio preview size supported.");
if (!findBestPreviewSize(supportedSizes, false, true)) {
Log.w(TAG, "Can't find a supported preview size smaller than 960x720.");
findBestPreviewSize(supportedSizes, false, false);
}
}
Log.d(TAG, "camera preview h = "
+ mCameraPreviewHeight + " , w = " + mCameraPreviewWidth);
parameters.setPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
List<int[]> frameRates = parameters.getSupportedPreviewFpsRange();
int last = frameRates.size() - 1;
int minFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MIN_INDEX];
int maxFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MAX_INDEX];
parameters.setPreviewFpsRange(minFps, maxFps);
Log.d(TAG, "preview fps: " + minFps + ", " + maxFps);
List<String> supportedFocusModes = parameters.getSupportedFocusModes();
if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) {
parameters.setFocusMode(mTargetFocusMode);
} else {
// Use the default focus mode and log a message
Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode +
" becuase the mode is not supported.");
}
parameters.set(CameraUtil.RECORDING_HINT, CameraUtil.FALSE);
mHorizontalViewAngle = parameters.getHorizontalViewAngle();
mVerticalViewAngle = parameters.getVerticalViewAngle();
}
示例14: surfaceCreated
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@Override
@TargetApi(14)
public void surfaceCreated(SurfaceHolder holder) {
surfaceDestroyed(holder);
try {
// Open the camera
mCamera = Camera.open(mCameraId);
mCamera.setPreviewDisplay(holder);
mCamera.setPreviewCallback(mScanAsyncTask);
} catch (Exception e) {
e.printStackTrace();
surfaceDestroyed(holder);
// Show error message
findViewById(R.id.surfaceview).setVisibility(View.INVISIBLE);
findViewById(R.id.progress).setVisibility(View.INVISIBLE);
findViewById(R.id.window).setVisibility(View.INVISIBLE);
findViewById(R.id.textview).setVisibility(View.VISIBLE);
return;
}
// Set auto-focus mode
Parameters params = mCamera.getParameters();
List<String> modes = params.getSupportedFocusModes();
if (modes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
params.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
else if (modes.contains(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
params.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
else if (modes.contains(Parameters.FOCUS_MODE_AUTO)) {
params.setFocusMode(Parameters.FOCUS_MODE_AUTO);
mHandler = new AutoFocusHandler(mCamera);
}
mCamera.setParameters(params);
}
示例15: enableAutoFocus
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void enableAutoFocus() {
final Parameters params = mNativeCamera.getNativeCameraParameters();
params.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
mNativeCamera.updateNativeCameraParameters(params);
}