2 * Copyright (C) 2014 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package cz.cvut.fel.dce.barcodescanner;
19 import android.hardware.Camera;
20 import android.util.Log;
22 import com.google.zxing.client.android.camera.CameraConfigurationUtils;
27 final class CameraConfigurationManager {
29 private static final String TAG = "CameraConfiguration";
31 static final int ZOOM = 2;
33 private CameraConfigurationManager() {
36 static void configure(Camera camera) {
37 Camera.Parameters parameters = camera.getParameters();
38 parameters.setPreviewSize(1280, 720);
39 //parameters.setPreviewSize(1920, 1080);
40 configureAdvanced(parameters);
41 camera.setParameters(parameters);
42 //logAllParameters(parameters);
45 private static void configureAdvanced(Camera.Parameters parameters) {
46 CameraConfigurationUtils.setBestPreviewFPS(parameters);
47 CameraConfigurationUtils.setBarcodeSceneMode(parameters);
48 CameraConfigurationUtils.setVideoStabilization(parameters);
49 CameraConfigurationUtils.setMetering(parameters);
50 CameraConfigurationUtils.setZoom(parameters, ZOOM);
53 private static void logAllParameters(Camera.Parameters parameters) {
54 if (Log.isLoggable(TAG, Log.INFO)) {
55 for (String line : CameraConfigurationUtils.collectStats(parameters).split("\n")) {