summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CaptureModule.java
diff options
context:
space:
mode:
authorCamera Software Integration <camswint@localhost>2017-03-17 22:05:21 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-03-17 22:05:21 -0700
commitf8bced500c0f6023cfd36666a1412f03f4e39194 (patch)
tree06b45895f3fc96a3b2bab372b7dc0be338dfa488 /src/com/android/camera/CaptureModule.java
parent3f0720bf770b55231b93cb1e1c39e28e0f2c219b (diff)
parent271a754c8ea933f981e2d9145647c6205bd56bbe (diff)
downloadandroid_packages_apps_Snap-f8bced500c0f6023cfd36666a1412f03f4e39194.tar.gz
android_packages_apps_Snap-f8bced500c0f6023cfd36666a1412f03f4e39194.tar.bz2
android_packages_apps_Snap-f8bced500c0f6023cfd36666a1412f03f4e39194.zip
Merge "SnapdragonCamera: Smile/blink/gaze detection" into camera.lnx.1.0-dev.1.0
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r--src/com/android/camera/CaptureModule.java69
1 files changed, 64 insertions, 5 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 88037b829..cf26a761b 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2012 The Android Open Source Project
@@ -245,6 +245,26 @@ public class CaptureModule implements CameraModule, PhotoController,
new CaptureResult.Key<>("org.codeaurora.qcamera3.histogram.stats", int[].class);
public static CameraCharacteristics.Key<Integer> isHdrScene =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.stats.is_hdr_scene", Integer.class);
+
+ public static CameraCharacteristics.Key<Byte> bsgcAvailable =
+ new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.stats.bsgc_available", Byte.class);
+ public static CaptureResult.Key<byte[]> blinkDetected =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.blink_detected", byte[].class);
+ public static CaptureResult.Key<byte[]> blinkDegree =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.blink_degree", byte[].class);
+ public static CaptureResult.Key<byte[]> smileDegree =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.smile_degree", byte[].class);
+ public static CaptureResult.Key<byte[]> smileConfidence =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.smile_confidence", byte[].class);
+ public static CaptureResult.Key<byte[]> gazeAngle =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.gaze_angle", byte[].class);
+ public static CaptureResult.Key<int[]> gazeDirection =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.gaze_direction",
+ int[].class);
+ public static CaptureResult.Key<byte[]> gazeDegree =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.gaze_degree",
+ byte[].class);
+
private boolean[] mTakingPicture = new boolean[MAX_NUM_CAM];
private int mControlAFMode = CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
private int mLastResultAFState = -1;
@@ -322,6 +342,8 @@ public class CaptureModule implements CameraModule, PhotoController,
private CaptureResult mPreviewCaptureResult;
private Face[] mPreviewFaces = null;
private Face[] mStickyFaces = null;
+ private ExtendedFace[] mExFaces = null;
+ private ExtendedFace[] mStickyExFaces = null;
private Rect mBayerCameraRegion;
private Handler mCameraHandler;
private Handler mImageAvailableHandler;
@@ -551,7 +573,11 @@ public class CaptureModule implements CameraModule, PhotoController,
if (id == getMainCameraId()) {
updateFocusStateChange(partialResult);
Face[] faces = partialResult.get(CaptureResult.STATISTICS_FACES);
- updateFaceView(faces);
+ if (faces != null && isBsgcDetecionOn()) {
+ updateFaceView(faces, getBsgcInfo(partialResult, faces.length));
+ } else {
+ updateFaceView(faces, null);
+ }
}
}
@@ -563,7 +589,11 @@ public class CaptureModule implements CameraModule, PhotoController,
if (id == getMainCameraId()) {
updateFocusStateChange(result);
Face[] faces = result.get(CaptureResult.STATISTICS_FACES);
- updateFaceView(faces);
+ if (faces != null && isBsgcDetecionOn()) {
+ updateFaceView(faces, getBsgcInfo(result, faces.length));
+ } else {
+ updateFaceView(faces, null);
+ }
}
if (SettingsManager.getInstance().isHistogramSupport()) {
int[] histogramStats = result.get(CaptureModule.histogramStats);
@@ -803,6 +833,12 @@ public class CaptureModule implements CameraModule, PhotoController,
return isBackCamera() && getCameraMode() == DUAL_MODE && value.equals("on");
}
+ private boolean isBsgcDetecionOn() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_BSGC_DETECTION);
+ if (value == null) return false;
+ return value.equals("enable");
+ }
+
private boolean isRawCaptureOn() {
String value = mSettingsManager.getValue(SettingsManager.KEY_SAVERAW);
if (value == null) return false;
@@ -2743,16 +2779,39 @@ public class CaptureModule implements CameraModule, PhotoController,
return false;
}
- private void updateFaceView(final Face[] faces) {
+ private ExtendedFace[] getBsgcInfo(CaptureResult captureResult, int size) {
+ ExtendedFace []extendedFaces = new ExtendedFace[size];
+ byte[] blinkDetectedArray = captureResult.get(blinkDetected);
+ byte[] blinkDegreesArray = captureResult.get(blinkDegree);
+ int[] gazeDirectionArray = captureResult.get(gazeDirection);
+ byte[] gazeAngleArray = captureResult.get(gazeAngle);
+ byte[] smileDegreeArray = captureResult.get(smileDegree);
+ byte[] smileConfidenceArray = captureResult.get(smileConfidence);
+ for(int i=0;i<size;i++) {
+ ExtendedFace tmp = new ExtendedFace(i);
+ tmp.setBlinkDetected(blinkDetectedArray[i]);
+ tmp.setBlinkDegree(blinkDegreesArray[2*i], blinkDegreesArray[2*i+1]);
+ tmp.setGazeDirection(gazeDirectionArray[3*i], gazeDirectionArray[3*i+1], gazeDirectionArray[3*i+2]);
+ tmp.setGazeAngle(gazeAngleArray[i]);
+ tmp.setSmileDegree(smileDegreeArray[i]);
+ tmp.setSmileConfidence(smileConfidenceArray[i]);
+ extendedFaces[i] = tmp;
+ }
+ return extendedFaces;
+ }
+
+ private void updateFaceView(final Face[] faces, final ExtendedFace[] extendedFaces) {
mPreviewFaces = faces;
+ mExFaces = extendedFaces;
if (faces != null) {
if (faces.length != 0) {
mStickyFaces = faces;
+ mStickyExFaces = extendedFaces;
}
mHandler.post(new Runnable() {
@Override
public void run() {
- mUI.onFaceDetection(faces);
+ mUI.onFaceDetection(faces, extendedFaces);
}
});
}