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


Java Camera.getParameters方法代码示例

本文整理汇总了Java中android.hardware.Camera.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.getParameters方法的具体用法?Java Camera.getParameters怎么用?Java Camera.getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera的用法示例。


在下文中一共展示了Camera.getParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFlashMode

import android.hardware.Camera; //导入方法依赖的package包/类
private boolean getFlashMode(CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  String flashMode = params.getFlashMode();

  if (flashMode != null ) {
    callbackContext.success(flashMode);
  } else {
    callbackContext.error("FlashMode not supported");
  }
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:18,代码来源:CameraPreview.java

示例2: setTorchMode

import android.hardware.Camera; //导入方法依赖的package包/类
public void setTorchMode(int cameraType, int torchMode) {
    Camera camera = this.acquireCameraInstance(cameraType);
    if (null == camera) {
        return;
    }

    Camera.Parameters parameters = camera.getParameters();
    String value = parameters.getFlashMode();
    switch (torchMode) {
        case RCTCameraModule.RCT_CAMERA_TORCH_MODE_ON:
            value = Camera.Parameters.FLASH_MODE_TORCH;
            break;
        case RCTCameraModule.RCT_CAMERA_TORCH_MODE_OFF:
            value = Camera.Parameters.FLASH_MODE_OFF;
            break;
    }

    List<String> flashModes = parameters.getSupportedFlashModes();
    if (flashModes != null && flashModes.contains(value)) {
        parameters.setFlashMode(value);
        camera.setParameters(parameters);
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:24,代码来源:RCTCamera.java

示例3: getMaxZoom

import android.hardware.Camera; //导入方法依赖的package包/类
private boolean getMaxZoom(CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  if (camera.getParameters().isZoomSupported()) {
    int maxZoom = camera.getParameters().getMaxZoom();
    callbackContext.success(maxZoom);
  } else {
    callbackContext.error("Zoom not supported");
  }
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:17,代码来源:CameraPreview.java

示例4: setDesiredCameraParameters

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Sets the camera up to take preview images which are used for both preview and decoding.
 * We detect the preview format here so that buildLuminanceSource() can build an appropriate
 * LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
 * and the planar Y can be used for barcode scanning without a copy in some cases.
 */
void setDesiredCameraParameters(Camera camera) {
	Camera.Parameters parameters = camera.getParameters();
	Log.d(TAG, "Setting preview size: " + cameraResolution);
	parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
	setFlash(parameters);
	setZoom(parameters);
	//setSharpness(parameters);
	//modify here
	camera.setDisplayOrientation(90);
	camera.setParameters(parameters);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:CameraConfigurationManager.java

示例5: setAutoFocusEnabledInternal

import android.hardware.Camera; //导入方法依赖的package包/类
private void setAutoFocusEnabledInternal(boolean autoFocusEnabled) {
    try {
        Camera camera = mDecoderWrapper.getCamera();
        Camera.Parameters parameters = camera.getParameters();
        if (parameters == null) {
            return;
        }
        boolean changed;
        AutoFocusMode autoFocusMode = mAutoFocusMode;
        if (autoFocusEnabled) {
            changed = Utils.setAutoFocusMode(parameters, autoFocusMode);
        } else {
            camera.cancelAutoFocus();
            changed = Utils.disableAutoFocus(parameters);
        }
        if (changed) {
            camera.setParameters(parameters);
        }
        if (autoFocusEnabled) {
            mSafeAutoFocusAttemptsCount = 0;
            mSafeAutoFocusing = false;
            if (autoFocusMode == AutoFocusMode.SAFE) {
                scheduleSafeAutoFocusTask();
            }
        }
    } catch (Exception ignored) {
    }
}
 
开发者ID:yuriy-budiyev,项目名称:code-scanner,代码行数:29,代码来源:CodeScanner.java

示例6: initCameraParams

import android.hardware.Camera; //导入方法依赖的package包/类
public static void initCameraParams(Camera camera, CameraMessage cameraData, boolean isTouchMode)
        throws CameraNotSupportException {
    boolean isLandscape = (Options.getInstance().camera.orientation != Options.Orientation.PORTRAIT);
    int cameraWidth = Math.max(Options.getInstance().camera.height, Options.getInstance().camera.width);
    int cameraHeight = Math.min(Options.getInstance().camera.height, Options.getInstance().camera.width);
    Camera.Parameters parameters = camera.getParameters();
    setPreviewFormat(camera, parameters);
    setPreviewFps(camera, Options.getInstance().camera.fps, parameters);
    setPreviewSize(camera, cameraData, cameraWidth, cameraHeight, parameters);
    cameraData.hasLight = supportFlash(camera);
    setOrientation(cameraData, isLandscape, camera);
    setFocusMode(camera, cameraData, isTouchMode);
}
 
开发者ID:wuyisheng,项目名称:libRtmp,代码行数:14,代码来源:AndroidUntil.java

示例7: setDesiredCameraParameters

import android.hardware.Camera; //导入方法依赖的package包/类
public void setDesiredCameraParameters(Camera camera, boolean safeMode) {
	Camera.Parameters parameters = camera.getParameters();

	if (parameters == null) {
		Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
		return;
	}

	Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

	if (safeMode) {
		Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
	}

	parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
	camera.setParameters(parameters);

	Camera.Parameters afterParameters = camera.getParameters();
	Camera.Size afterSize = afterParameters.getPreviewSize();
	if (afterSize != null && (cameraResolution.x != afterSize.width || cameraResolution.y != afterSize.height)) {
		Log.w(TAG, "Camera said it supported preview size " + cameraResolution.x + 'x' + cameraResolution.y + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
		cameraResolution.x = afterSize.width;
		cameraResolution.y = afterSize.height;
	}

	/** 设置相机预览为竖屏 */
	camera.setDisplayOrientation(90);
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:29,代码来源:CameraConfigurationManager.java

示例8: safeSetPreviewFrameRate

import android.hardware.Camera; //导入方法依赖的package包/类
void safeSetPreviewFrameRate(Camera camera) {
    Camera.Parameters params = camera.getParameters();
    int fitRate = -1;

    @SuppressWarnings("deprecation")
    List<Integer> rateList = params.getSupportedPreviewFrameRates();
    if (null == rateList || 0 == rateList.size()) {
        log.error("getSupportedPrviewFrameRates failed");
        return;
    }

    for (Integer rate : rateList) {
        log.error("supportPriviewFrameRate, rate: " + rate);
        if (rate <= MAX_FRAME_RATE && (-1 == fitRate || rate > fitRate)) {
            fitRate = rate;
        }
    }

    if (-1 == fitRate) {
        log.error("can't find fit rate, use camera default value");
        return;
    }

    try {
        log.error("setPreviewFrameRate, fitRate: " + fitRate);
        //noinspection deprecation
        params.setPreviewFrameRate(fitRate);
        camera.setParameters(params);
    } catch (Exception e) {
        log.error("setPreviewFrameRate failed, " + e.getMessage());
    }
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:33,代码来源:CameraLoader.java

示例9: 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:kkyflying,项目名称:CodeScaner,代码行数:13,代码来源:CameraConfigurationManager.java

示例10: setDesiredCameraParameters

import android.hardware.Camera; //导入方法依赖的package包/类
void setDesiredCameraParameters(Camera camera) {
    Camera.Parameters parameters = camera.getParameters();

    if (parameters == null) {
        Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
        return;
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    initializeTorch(parameters, prefs);
    String focusMode = null;
    if (prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true)) {
        if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, false)) {
            focusMode = findSettableValue(parameters.getSupportedFocusModes(),
                    Camera.Parameters.FOCUS_MODE_AUTO);
        } else {
            focusMode = findSettableValue(parameters.getSupportedFocusModes(),
                    "continuous-video", // Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO in 4.0+
                    "continuous-picture", // Camera.Paramters.FOCUS_MODE_CONTINUOUS_PICTURE in 4.0+
                    Camera.Parameters.FOCUS_MODE_AUTO);
        }
    }
    // Maybe selected auto-focus but not available, so fall through here:
    if (focusMode == null) {
        focusMode = findSettableValue(parameters.getSupportedFocusModes(),
                Camera.Parameters.FOCUS_MODE_MACRO,
                "edof"); // Camera.Parameters.FOCUS_MODE_EDOF in 2.2+
    }
    if (focusMode != null) {
        parameters.setFocusMode(focusMode);
    }

    parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
    camera.setParameters(parameters);
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:37,代码来源:CameraConfigurationManager.java

示例11: getTorchEnabled

import android.hardware.Camera; //导入方法依赖的package包/类
private static boolean getTorchEnabled(final Camera camera) {
    final Camera.Parameters parameters = camera.getParameters();
    if (parameters != null) {
        final String flashMode = camera.getParameters().getFlashMode();
        return flashMode != null && (Camera.Parameters.FLASH_MODE_ON.equals(flashMode)
                || Camera.Parameters.FLASH_MODE_TORCH.equals(flashMode));
    }

    return false;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:11,代码来源:CameraManager.java

示例12: openDriver

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera, view.getWidth(), view.getHeight());
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight, requestedFramingRectTopOffset);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false, mUseAutoFocus);
    } catch (RuntimeException re) {
        // Driver failed
        LogEx.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        LogEx.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true, mUseAutoFocus);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                LogEx.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
 
开发者ID:CoderChoy,项目名称:BarcodeReaderView,代码行数:52,代码来源:CameraManager.java

示例13: openDriver

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    Camera theCamera = camera;
    if (theCamera == null) {

        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException();
        }
        camera = theCamera;
    }
    theCamera.setPreviewDisplay(holder);

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera.Parameters parameters = theCamera.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = theCamera.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                theCamera.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }

}
 
开发者ID:crisfg86,项目名称:Zxing-Custom,代码行数:52,代码来源:CameraManager.java

示例14: setTorch

import android.hardware.Camera; //导入方法依赖的package包/类
void setTorch(Camera camera, boolean newSetting) {
    Camera.Parameters parameters = camera.getParameters();
    doSetTorch(parameters, newSetting, false);
    camera.setParameters(parameters);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:CameraConfigurationManager.java

示例15: openDriver

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 * 
 * @param holder
 *            The surface object which the camera will draw preview frames
 *            into.
 * @throws IOException
 *             Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder)
		throws IOException {
	Camera theCamera = camera;
	if (theCamera == null) {
		theCamera = new OpenCameraManager().build().open();
		if (theCamera == null) {
			throw new IOException();
		}
		camera = theCamera;
	}
	theCamera.setPreviewDisplay(holder);

	if (!initialized) {
		initialized = true;
		configManager.initFromCameraParameters(theCamera);
		if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
			setManualFramingRect(requestedFramingRectWidth,
					requestedFramingRectHeight);
			requestedFramingRectWidth = 0;
			requestedFramingRectHeight = 0;
		}
	}

	Camera.Parameters parameters = theCamera.getParameters();
	String parametersFlattened = parameters == null ? null : parameters
			.flatten(); // Save these, temporarily
	try {
		configManager.setDesiredCameraParameters(theCamera, false);
	} catch (RuntimeException re) {
		// Driver failed
		Log.w(TAG,
				"Camera rejected parameters. Setting only minimal safe-mode parameters");
		Log.i(TAG, "Resetting to saved camera params: "
				+ parametersFlattened);
		// Reset:
		if (parametersFlattened != null) {
			parameters = theCamera.getParameters();
			parameters.unflatten(parametersFlattened);
			try {
				theCamera.setParameters(parameters);
				configManager.setDesiredCameraParameters(theCamera, true);
			} catch (RuntimeException re2) {
				// Well, darn. Give up
				Log.w(TAG,
						"Camera rejected even safe-mode parameters! No configuration");
			}
		}
	}

}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:60,代码来源:CameraManager.java


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