summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/FaceView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ui/FaceView.java')
-rwxr-xr-xsrc/com/android/camera/ui/FaceView.java139
1 files changed, 69 insertions, 70 deletions
diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java
index db37dbcb3..b617891e5 100755
--- a/src/com/android/camera/ui/FaceView.java
+++ b/src/com/android/camera/ui/FaceView.java
@@ -234,112 +234,111 @@ public class FaceView extends View
canvas.drawOval(mRect, mPaint);
if (ExtendedFaceWrapper.isExtendedFaceInstance(mFaces[i])) {
- ExtendedFaceWrapper wrapper = new ExtendedFaceWrapper(mFaces[i]);
float[] point = new float[4];
int delta_x = mFaces[i].rect.width() / 12;
int delta_y = mFaces[i].rect.height() / 12;
- Log.e(TAG, "blink: (" + wrapper.getLeftEyeBlinkDegree()+ ", " +
- wrapper.getRightEyeBlinkDegree() + ")");
- if (wrapper.mFace.leftEye != null) {
+ Log.e(TAG, "blink: (" + ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i])+ ", " +
+ ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) + ")");
+ if (mFaces[i].leftEye != null) {
if ((mDisplayRotation == 0) ||
(mDisplayRotation == 180)) {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y - delta_y / 2;
- point[2] = wrapper.mFace.leftEye.x;
- point[3] = wrapper.mFace.leftEye.y + delta_y / 2;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y - delta_y / 2;
+ point[2] = mFaces[i].leftEye.x;
+ point[3] = mFaces[i].leftEye.y + delta_y / 2;
} else {
- point[0] = wrapper.mFace.leftEye.x - delta_x / 2;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + delta_x / 2;
- point[3] = wrapper.mFace.leftEye.y;
+ point[0] = mFaces[i].leftEye.x - delta_x / 2;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + delta_x / 2;
+ point[3] = mFaces[i].leftEye.y;
}
mMatrix.mapPoints (point);
- if (wrapper.getLeftEyeBlinkDegree() >= blink_threshold) {
+ if (ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i]) >= blink_threshold) {
canvas.drawLine(point[0]+ dx, point[1]+ dy,
point[2]+ dx, point[3]+ dy, mPaint);
}
}
- if (wrapper.mFace.rightEye != null) {
+ if (mFaces[i].rightEye != null) {
if ((mDisplayRotation == 0) ||
(mDisplayRotation == 180)) {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y - delta_y / 2;
- point[2] = wrapper.mFace.rightEye.x;
- point[3] = wrapper.mFace.rightEye.y + delta_y / 2;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y - delta_y / 2;
+ point[2] = mFaces[i].rightEye.x;
+ point[3] = mFaces[i].rightEye.y + delta_y / 2;
} else {
- point[0] = wrapper.mFace.rightEye.x - delta_x / 2;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + delta_x / 2;
- point[3] = wrapper.mFace.rightEye.y;
+ point[0] = mFaces[i].rightEye.x - delta_x / 2;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + delta_x / 2;
+ point[3] = mFaces[i].rightEye.y;
}
mMatrix.mapPoints (point);
- if (wrapper.getRightEyeBlinkDegree() >= blink_threshold) {
+ if (ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) >= blink_threshold) {
//Add offset to the points if the rect has an offset
canvas.drawLine(point[0] + dx, point[1] + dy,
point[2] +dx, point[3] +dy, mPaint);
}
}
- if (wrapper.getLeftRightGazeDegree() != 0
- || wrapper.getTopBottomGazeDegree() != 0 ) {
+ if (ExtendedFaceWrapper.getLeftRightGazeDegree(mFaces[i]) != 0
+ || ExtendedFaceWrapper.getTopBottomGazeDegree(mFaces[i]) != 0 ) {
double length =
- Math.sqrt((wrapper.mFace.leftEye.x - wrapper.mFace.rightEye.x) *
- (wrapper.mFace.leftEye.x - wrapper.mFace.rightEye.x) +
- (wrapper.mFace.leftEye.y - wrapper.mFace.rightEye.y) *
- (wrapper.mFace.leftEye.y - wrapper.mFace.rightEye.y)) / 2.0;
- double nGazeYaw = -wrapper.getLeftRightGazeDegree();
- double nGazePitch = -wrapper.getTopBottomGazeDegree();
+ Math.sqrt((mFaces[i].leftEye.x - mFaces[i].rightEye.x) *
+ (mFaces[i].leftEye.x - mFaces[i].rightEye.x) +
+ (mFaces[i].leftEye.y - mFaces[i].rightEye.y) *
+ (mFaces[i].leftEye.y - mFaces[i].rightEye.y)) / 2.0;
+ double nGazeYaw = -ExtendedFaceWrapper.getLeftRightGazeDegree(mFaces[i]);
+ double nGazePitch = -ExtendedFaceWrapper.getTopBottomGazeDegree(mFaces[i]);
float gazeRollX =
(float)((-Math.sin(nGazeYaw/180.0*Math.PI) *
- Math.cos(-wrapper.getRollDirection()/
+ Math.cos(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI) +
Math.sin(nGazePitch/180.0*Math.PI) *
Math.cos(nGazeYaw/180.0*Math.PI) *
- Math.sin(-wrapper.getRollDirection()/
+ Math.sin(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)) *
(-length) + 0.5);
float gazeRollY =
(float)((Math.sin(-nGazeYaw/180.0*Math.PI) *
- Math.sin(-wrapper.getRollDirection()/
+ Math.sin(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)-
Math.sin(nGazePitch/180.0*Math.PI) *
Math.cos(nGazeYaw/180.0*Math.PI) *
- Math.cos(-wrapper.getRollDirection()/
+ Math.cos(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)) *
(-length) + 0.5);
- if (wrapper.getLeftEyeBlinkDegree() < blink_threshold) {
+ if (ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i]) < blink_threshold) {
if ((mDisplayRotation == 90) ||
(mDisplayRotation == 270)) {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + gazeRollX;
- point[3] = wrapper.mFace.leftEye.y + gazeRollY;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + gazeRollX;
+ point[3] = mFaces[i].leftEye.y + gazeRollY;
} else {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + gazeRollY;
- point[3] = wrapper.mFace.leftEye.y + gazeRollX;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + gazeRollY;
+ point[3] = mFaces[i].leftEye.y + gazeRollX;
}
mMatrix.mapPoints (point);
canvas.drawLine(point[0] +dx, point[1] + dy,
point[2] + dx, point[3] +dy, mPaint);
}
- if (wrapper.getRightEyeBlinkDegree() < blink_threshold) {
+ if (ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) < blink_threshold) {
if ((mDisplayRotation == 90) ||
(mDisplayRotation == 270)) {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + gazeRollX;
- point[3] = wrapper.mFace.rightEye.y + gazeRollY;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + gazeRollX;
+ point[3] = mFaces[i].rightEye.y + gazeRollY;
} else {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + gazeRollY;
- point[3] = wrapper.mFace.rightEye.y + gazeRollX;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + gazeRollY;
+ point[3] = mFaces[i].rightEye.y + gazeRollX;
}
mMatrix.mapPoints (point);
@@ -348,35 +347,35 @@ public class FaceView extends View
}
}
- if (wrapper.mFace.mouth != null) {
- Log.e(TAG, "smile: " + wrapper.getSmileDegree() + "," +
- wrapper.getSmileScore());
- if (wrapper.getSmileDegree() < smile_threashold_no_smile) {
- point[0] = wrapper.mFace.mouth.x + dx - delta_x;
- point[1] = wrapper.mFace.mouth.y;
- point[2] = wrapper.mFace.mouth.x + dx + delta_x;
- point[3] = wrapper.mFace.mouth.y;
+ if (mFaces[i].mouth != null) {
+ Log.e(TAG, "smile: " + ExtendedFaceWrapper.getSmileDegree(mFaces[i]) + "," +
+ ExtendedFaceWrapper.getSmileScore(mFaces[i]));
+ if (ExtendedFaceWrapper.getSmileDegree(mFaces[i]) < smile_threashold_no_smile) {
+ point[0] = mFaces[i].mouth.x + dx - delta_x;
+ point[1] = mFaces[i].mouth.y;
+ point[2] = mFaces[i].mouth.x + dx + delta_x;
+ point[3] = mFaces[i].mouth.y;
Matrix faceMatrix = new Matrix(mMatrix);
- faceMatrix.preRotate(wrapper.getRollDirection(),
- wrapper.mFace.mouth.x, wrapper.mFace.mouth.y);
+ faceMatrix.preRotate(ExtendedFaceWrapper.getRollDirection(mFaces[i]),
+ mFaces[i].mouth.x, mFaces[i].mouth.y);
faceMatrix.mapPoints(point);
canvas.drawLine(point[0] + dx, point[1] + dy,
point[2] + dx, point[3] + dy, mPaint);
- } else if (wrapper.getSmileDegree() <
+ } else if (ExtendedFaceWrapper.getSmileDegree(mFaces[i]) <
smile_threashold_small_smile) {
int rotation_mouth = 360 - mDisplayRotation;
- mRect.set(wrapper.mFace.mouth.x-delta_x,
- wrapper.mFace.mouth.y-delta_y, wrapper.mFace.mouth.x+delta_x,
- wrapper.mFace.mouth.y+delta_y);
+ mRect.set(mFaces[i].mouth.x-delta_x,
+ mFaces[i].mouth.y-delta_y, mFaces[i].mouth.x+delta_x,
+ mFaces[i].mouth.y+delta_y);
mMatrix.mapRect(mRect);
mRect.offset(dx, dy);
canvas.drawArc(mRect, rotation_mouth,
180, true, mPaint);
} else {
- mRect.set(wrapper.mFace.mouth.x-delta_x,
- wrapper.mFace.mouth.y-delta_y, wrapper.mFace.mouth.x+delta_x,
- wrapper.mFace.mouth.y+delta_y);
+ mRect.set(mFaces[i].mouth.x-delta_x,
+ mFaces[i].mouth.y-delta_y, mFaces[i].mouth.x+delta_x,
+ mFaces[i].mouth.y+delta_y);
mMatrix.mapRect(mRect);
mRect.offset(dx, dy);
canvas.drawOval(mRect, mPaint);