diff options
Diffstat (limited to 'src/com/android/camera/VideoModule.java')
-rw-r--r-- | src/com/android/camera/VideoModule.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index fc7548790..b8537c2b5 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -217,6 +217,9 @@ public class VideoModule implements CameraModule, // The preview window is on focus private boolean mPreviewFocused = false; + private boolean mFaceDetectionEnabled = false; + private boolean mFaceDetectionStarted = false; + private final MediaSaveService.OnMediaSavedListener mOnVideoSavedListener = new MediaSaveService.OnMediaSavedListener() { @Override @@ -1293,6 +1296,7 @@ public class VideoModule implements CameraModule, private void onPreviewStarted() { mUI.enableShutter(true); + startFaceDetection(); } @Override @@ -1309,6 +1313,7 @@ public class VideoModule implements CameraModule, mPreviewing = false; mStopPrevPending = false; mUI.enableShutter(false); + stopFaceDetection(); } private void closeCamera() { @@ -1319,12 +1324,14 @@ public class VideoModule implements CameraModule, } mCameraDevice.setZoomChangeListener(null); mCameraDevice.setErrorCallback(null); + mCameraDevice.setFaceDetectionCallback(null, null); CameraHolder.instance().release(); mCameraDevice = null; mPreviewing = false; mSnapshotInProgress = false; mFocusManager.onCameraReleased(); mPreviewFocused = false; + mFaceDetectionStarted = false; } private void releasePreviewResources() { @@ -2643,6 +2650,23 @@ public class VideoModule implements CameraModule, mFocusManager.setFocusTime(Integer.decode( mPreferences.getString(CameraSettings.KEY_VIDEOCAMERA_FOCUS_TIME, mActivity.getString(R.string.pref_camera_video_focustime_default)))); + + // Set face detetction parameter. + String faceDetection = mPreferences.getString( + CameraSettings.KEY_FACE_DETECTION, + mActivity.getString(R.string.pref_camera_facedetection_default)); + + if (CameraUtil.isSupported(faceDetection, mParameters.getSupportedFaceDetectionModes())) { + Log.d(TAG, "setFaceDetectionMode "+faceDetection); + mParameters.setFaceDetectionMode(faceDetection); + if(faceDetection.equals("on") && mFaceDetectionEnabled == false) { + mFaceDetectionEnabled = true; + startFaceDetection(); + } else if(faceDetection.equals("off") && mFaceDetectionEnabled == true) { + stopFaceDetection(); + mFaceDetectionEnabled = false; + } + } } @SuppressWarnings("deprecation") @@ -3084,5 +3108,33 @@ public class VideoModule implements CameraModule, enableRecordingLocation(false); } + + public void startFaceDetection() { + if (mCameraDevice == null) return; + + if (mFaceDetectionEnabled == false + || mFaceDetectionStarted) return; + if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = true; + CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId]; + mUI.onStartFaceDetection(mCameraDisplayOrientation, + (info.facing == CameraInfo.CAMERA_FACING_FRONT)); + mCameraDevice.setFaceDetectionCallback(mHandler, mUI); + Log.d(TAG, "start face detection Video "+mParameters.getMaxNumDetectedFaces()); + mCameraDevice.startFaceDetection(); + } + } + + public void stopFaceDetection() { + Log.d(TAG, "stop face detection"); + if (mFaceDetectionEnabled == false || !mFaceDetectionStarted) return; + if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = false; + mCameraDevice.setFaceDetectionCallback(null, null); + mUI.pauseFaceDetection(); + mCameraDevice.stopFaceDetection(); + mUI.onStopFaceDetection(); + } + } } |