diff options
author | junjiez <junjiez@codeaurora.org> | 2017-02-07 10:13:36 +0800 |
---|---|---|
committer | junjiez <junjiez@codeaurora.org> | 2017-03-14 15:42:54 +0800 |
commit | 271a754c8ea933f981e2d9145647c6205bd56bbe (patch) | |
tree | 4c4bae1ef575b79f37ffbf066e768edd3566dc43 /src/com/android/camera/CaptureModule.java | |
parent | a68765fb88ee78d86490f8987f3f46ff4bb4a266 (diff) | |
download | android_packages_apps_Snap-271a754c8ea933f981e2d9145647c6205bd56bbe.tar.gz android_packages_apps_Snap-271a754c8ea933f981e2d9145647c6205bd56bbe.tar.bz2 android_packages_apps_Snap-271a754c8ea933f981e2d9145647c6205bd56bbe.zip |
SnapdragonCamera: Smile/blink/gaze detection
Implement Smile/blink/gaze detection feature and
add option to enable it in develop options.
CRs-Fixed: 1087487
Change-Id: I3005ca9767fbe38323e86255238cd4f96f34fbe5
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 7c3e9b418..57c77419e 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 @@ -241,6 +241,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; @@ -318,6 +338,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; @@ -547,7 +569,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); + } } } @@ -559,7 +585,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); @@ -799,6 +829,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; @@ -2732,16 +2768,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); } }); } |