1bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde/*
2bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * Copyright (C) 2015 The Android Open Source Project
3bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde *
4bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * Licensed under the Apache License, Version 2.0 (the "License");
5bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * you may not use this file except in compliance with the License.
6bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * You may obtain a copy of the License at
7bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde *
8bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde *      http://www.apache.org/licenses/LICENSE-2.0
9bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde *
10bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * Unless required by applicable law or agreed to in writing, software
11bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * distributed under the License is distributed on an "AS IS" BASIS,
12bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * See the License for the specific language governing permissions and
14bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde * limitations under the License.
15bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde */
16bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
17bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohdepackage com.android.camera.one.v2.common;
18bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
19b10d44a37d33f6964a068adce135bfa57c4f0bb9Paul Rohdeimport android.hardware.camera2.CameraMetadata;
20b10d44a37d33f6964a068adce135bfa57c4f0bb9Paul Rohde
21bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohdeimport com.android.camera.one.OneCameraCharacteristics.FaceDetectMode;
22bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohdeimport com.google.common.base.Supplier;
23bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
24bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde/**
25b10d44a37d33f6964a068adce135bfa57c4f0bb9Paul Rohde * Supply the face detection mode based on the OneCamera face detect
26b10d44a37d33f6964a068adce135bfa57c4f0bb9Paul Rohde * mode.
27bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde */
28bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohdepublic class StatisticsFaceDetectMode implements Supplier<Integer> {
29bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    private final Supplier<FaceDetectMode> mFaceDetectMode;
30bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
31bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    public StatisticsFaceDetectMode(Supplier<FaceDetectMode> faceDetectMode) {
32bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        mFaceDetectMode = faceDetectMode;
33bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    }
34bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
35bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    @Override
36bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    public Integer get() {
37bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        if (mFaceDetectMode.get() == FaceDetectMode.FULL) {
38bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde            return CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL;
39bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        }
40bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
41bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        if (mFaceDetectMode.get() == FaceDetectMode.SIMPLE) {
42bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde            return CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE;
43bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        }
44bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde
45bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde        return CameraMetadata.STATISTICS_FACE_DETECT_MODE_OFF;
46bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde    }
47bb27cc628ee84737c72b0368b8b27a5bf8609b56Paul Rohde}
48