本文整理汇总了Java中com.google.zxing.client.android.camera.CameraConfigurationUtils类的典型用法代码示例。如果您正苦于以下问题:Java CameraConfigurationUtils类的具体用法?Java CameraConfigurationUtils怎么用?Java CameraConfigurationUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CameraConfigurationUtils类属于com.google.zxing.client.android.camera包,在下文中一共展示了CameraConfigurationUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFlashEnabledInternal
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private void setFlashEnabledInternal(boolean flashEnabled) {
try {
DecoderWrapper decoderWrapper = mDecoderWrapper;
Camera camera = decoderWrapper.getCamera();
Camera.Parameters parameters = camera.getParameters();
if (parameters == null) {
return;
}
boolean changed;
if (flashEnabled) {
changed = Utils.setFlashMode(parameters, Camera.Parameters.FLASH_MODE_TORCH);
} else {
changed = Utils.setFlashMode(parameters, Camera.Parameters.FLASH_MODE_OFF);
}
if (changed) {
CameraConfigurationUtils.setBestExposure(parameters, flashEnabled);
camera.setParameters(parameters);
}
} catch (Exception ignored) {
}
}
示例2: doSetTorch
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
CameraConfigurationUtils.setTorch(parameters, newSetting);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
CameraConfigurationUtils.setBestExposure(parameters, newSetting);
}
}
示例3: initFromCameraParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
/**
* Reads, one time, values from the camera that are needed by the app.
*/
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 = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Camera resolution x: " + cameraResolution.x);
Log.i(TAG, "Camera resolution y: " + cameraResolution.y);
}
示例4: measureCameraPreviewSize
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
/**
* 计算屏幕的尺寸
*
* @param camera
*/
private void measureCameraPreviewSize(Camera camera, int width, int height, int rotation) {
Camera.Parameters parameters = camera.getParameters();
previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format");
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
screenResolution = DeviceUtils.getScreenSize(mContext);
Log.d(TAG, "Screen resolution: " + screenResolution);
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = width;
screenResolutionForCamera.y = height;
//根据view 的分辨率,计算出相机最适合的分辨率
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolutionForCamera);
Log.d(TAG, "Camera resolution: " + cameraResolution);
}
示例5: openCamera
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private Camera openCamera() {
Camera.CameraInfo info = new Camera.CameraInfo();
int id = chooseBackFacingCamera(info);
Camera camera = Camera.open(id);
Point screenResolution = new Point();
camera.setDisplayOrientation((info.orientation - getDisplayInfo(screenResolution) + 360) % 360);
Camera.Parameters parameters = camera.getParameters();
CameraConfigurationUtils.setFocus(parameters, true, true, false);
CameraConfigurationUtils.setBarcodeSceneMode(parameters);
CameraConfigurationUtils.setVideoStabilization(parameters);
CameraConfigurationUtils.setFocusArea(parameters);
CameraConfigurationUtils.setMetering(parameters);
mCaptureSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.d(TAG, "Screen resolution: " + screenResolution.x + "x" + screenResolution.y);
Log.d(TAG, "Preview size: " + mCaptureSize.x + "x" + mCaptureSize.y);
parameters.setPreviewSize(mCaptureSize.x, mCaptureSize.y);
camera.setParameters(parameters);
return camera;
}
示例6: initFromCameraParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
/**
* Reads, one time, values from the camera that are needed by the app.
*/
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();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
display.getSize(theScreenResolution);
} else {
theScreenResolution.set(display.getWidth(), display.getHeight());
}
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
cameraResolution = CameraConfigurationUtils
.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Camera resolution: " + cameraResolution);
}
示例7: setDesiredCameraParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
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;
}
initializeTorch(parameters, safeMode);
CameraConfigurationUtils.setFocus(
parameters,
true,
true,
safeMode);
if (!safeMode) {
CameraConfigurationUtils.setBarcodeSceneMode(parameters);
CameraConfigurationUtils.setVideoStabilization(parameters);
CameraConfigurationUtils.setFocusArea(parameters);
CameraConfigurationUtils.setMetering(parameters);
}
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
Log.i(TAG, "Final camera parameters: " + parameters.flatten());
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);
}
示例8: doSetTorch
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
CameraConfigurationUtils.setTorch(parameters, newSetting);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
CameraConfigurationUtils.setBestExposure(parameters, newSetting);
//}
}
示例9: initFromCameraParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
/**
* Reads, one time, values from the camera that are needed by the app.
*/
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();
display.getSize(theScreenResolution);
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Camera resolution: " + cameraResolution);
}
示例10: onResume
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
camera = Camera.open();
parameters = camera.getParameters();
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
if (metric.widthPixels < metric.heightPixels){
camera.setDisplayOrientation(90);
} else {
camera.setDisplayOrientation(0);
}
CameraConfigurationUtils.setBestPreviewFPS(parameters);
Log.d(null, "Display Metric:" + metric.widthPixels + "x" + metric.heightPixels);
Point p = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, new Point(metric.widthPixels, metric.heightPixels));
setBestPreviewSize(p, metric, parameters);
List<String> focusMode = parameters.getSupportedFocusModes();
// 自动对焦优先
if (focusMode.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (focusMode.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
} else if (focusMode.contains(Camera.Parameters.FOCUS_MODE_MACRO)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
} else {
isSupportAutoFocus = false;
}
if (isSupportAutoFocus) {
autoFocusCallback = new AutoFocusCallBack();
}
parameters.setPreviewFormat(ImageFormat.NV21);
camera.setParameters(parameters);
previewCallback = new PreviewCallBack();
camera.setPreviewCallback(previewCallback);
startPreview();
camera.startPreview();
}
示例11: doSetTorch
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
CameraConfigurationUtils.setTorch(parameters, newSetting);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
CameraConfigurationUtils.setBestExposure(parameters, newSetting);
}
}
示例12: configureAdvanced
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private static void configureAdvanced(Camera.Parameters parameters) {
CameraConfigurationUtils.setBestPreviewFPS(parameters);
CameraConfigurationUtils.setBarcodeSceneMode(parameters);
CameraConfigurationUtils.setVideoStabilization(parameters);
CameraConfigurationUtils.setMetering(parameters);
CameraConfigurationUtils.setZoom(parameters, ZOOM);
}
示例13: logAllParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
public static void logAllParameters(Camera.Parameters parameters) {
if (Log.isLoggable(TAG, Log.INFO)) {
for (String line : CameraConfigurationUtils.collectStats(parameters).split("\n")) {
Log.i(TAG, line);
}
}
}
示例14: initialize
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
private void initialize() {
Camera camera = null;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int cameraId = mCameraId;
if (cameraId == DEFAULT_CAMERA) {
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
camera = Camera.open(i);
mCameraId = i;
break;
}
}
} else {
camera = Camera.open(cameraId);
Camera.getCameraInfo(cameraId, cameraInfo);
}
if (camera == null) {
throw new CodeScannerException("Unable to access camera");
}
Camera.Parameters parameters = camera.getParameters();
if (parameters == null) {
throw new CodeScannerException("Unable to configure camera");
}
int orientation = Utils.getDisplayOrientation(mContext, cameraInfo);
boolean portrait = Utils.isPortrait(orientation);
Point imageSize =
Utils.findSuitableImageSize(parameters, portrait ? mHeight : mWidth, portrait ? mWidth : mHeight);
int imageWidth = imageSize.getX();
int imageHeight = imageSize.getY();
parameters.setPreviewSize(imageWidth, imageHeight);
Point previewSize =
Utils.getPreviewSize(portrait ? imageHeight : imageWidth, portrait ? imageWidth : imageHeight,
mWidth, mHeight);
List<String> focusModes = parameters.getSupportedFocusModes();
boolean autoFocusSupported = focusModes != null &&
(focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO) ||
focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE));
if (!autoFocusSupported) {
mAutoFocusEnabled = false;
}
if (autoFocusSupported && mAutoFocusEnabled) {
Utils.setAutoFocusMode(parameters, mAutoFocusMode);
}
List<String> flashModes = parameters.getSupportedFlashModes();
boolean flashSupported = flashModes != null && flashModes.contains(Camera.Parameters.FLASH_MODE_TORCH);
if (!flashSupported) {
mFlashEnabled = false;
}
Utils.optimizeParameters(parameters);
CameraConfigurationUtils.setBestExposure(parameters, mFlashEnabled);
camera.setParameters(parameters);
camera.setDisplayOrientation(orientation);
mInitializeLock.lock();
try {
Decoder decoder = new Decoder(mDecoderStateListener, mFormats, mDecodeCallback);
mDecoderWrapper = new DecoderWrapper(camera, cameraInfo, decoder, imageSize, previewSize,
new Point(mWidth, mHeight), orientation, autoFocusSupported, flashSupported);
decoder.start();
mInitialization = false;
mInitialized = true;
} finally {
mInitializeLock.unlock();
}
mMainThreadHandler.post(new FinishInitializationTask(previewSize));
}
示例15: optimizeParameters
import com.google.zxing.client.android.camera.CameraConfigurationUtils; //导入依赖的package包/类
public static void optimizeParameters(@NonNull Camera.Parameters parameters) {
CameraConfigurationUtils.setBestPreviewFPS(parameters);
CameraConfigurationUtils.setBarcodeSceneMode(parameters);
CameraConfigurationUtils.setVideoStabilization(parameters);
parameters.setPreviewFormat(ImageFormat.NV21);
}