]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - BarCodeScanner/glass/src/main/java/cz/cvut/fel/dce/barcodescanner/CameraConfigurationManager.java
Initial commit
[hornmich/skoda-qr-demo.git] / BarCodeScanner / glass / src / main / java / cz / cvut / fel / dce / barcodescanner / CameraConfigurationManager.java
1 /*
2  * Copyright (C) 2014 ZXing authors
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package cz.cvut.fel.dce.barcodescanner;
18
19 import android.hardware.Camera;
20 import android.util.Log;
21
22 import com.google.zxing.client.android.camera.CameraConfigurationUtils;
23
24 /**
25  * @author Sean Owen
26  */
27 final class CameraConfigurationManager {
28
29   private static final String TAG = "CameraConfiguration";
30
31   static final int ZOOM = 2;
32
33   private CameraConfigurationManager() {
34   }
35
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);
43   }
44
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);
51   }
52
53   private static void logAllParameters(Camera.Parameters parameters) {
54     if (Log.isLoggable(TAG, Log.INFO)) {
55       for (String line : CameraConfigurationUtils.collectStats(parameters).split("\n")) {
56         Log.i(TAG, line);
57       }
58     }
59   }
60
61 }