Skip to content

Commit 6325ca8

Browse files
committed
Manual merge of github pull requests.
Merge pull request #1 from gonzapico/master Added another fields from face object to be shown (happiness level, l… Merge pull request #3 from incon/master Correct SDK level Change-Id: Icf8fdbb151125dd47a60b2c210278b3c24960eee
1 parent c56f789 commit 6325ca8

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Introduction
88

99
Pre-requisites
1010
--------------
11-
Android Play Services SDK level 25 or greater.
11+
Android Play Services SDK level 26 or greater.
1212

1313
Getting Started
1414
---------------

face/FaceTracker/app/src/main/java/com/google/android/gms/samples/vision/face/facetracker/FaceGraphic.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import android.graphics.Color;
2020
import android.graphics.Paint;
2121

22-
import com.google.android.gms.vision.face.Face;
2322
import com.google.android.gms.samples.vision.face.facetracker.ui.camera.GraphicOverlay;
23+
import com.google.android.gms.vision.face.Face;
2424

2525
/**
2626
* Graphic instance for rendering face position, orientation, and landmarks within an associated
@@ -50,6 +50,7 @@ class FaceGraphic extends GraphicOverlay.Graphic {
5050

5151
private volatile Face mFace;
5252
private int mFaceId;
53+
private float mFaceHappiness;
5354

5455
FaceGraphic(GraphicOverlay overlay) {
5556
super(overlay);
@@ -74,6 +75,7 @@ void setId(int id) {
7475
mFaceId = id;
7576
}
7677

78+
7779
/**
7880
* Updates the face instance from the detection of the most recent frame. Invalidates the
7981
* relevant portions of the overlay to trigger a redraw.
@@ -98,6 +100,9 @@ public void draw(Canvas canvas) {
98100
float y = translateY(face.getPosition().y + face.getHeight() / 2);
99101
canvas.drawCircle(x, y, FACE_POSITION_RADIUS, mFacePositionPaint);
100102
canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint);
103+
canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint);
104+
canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint);
105+
canvas.drawText("left eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint);
101106

102107
// Draws a bounding box around the face.
103108
float xOffset = scaleX(face.getWidth() / 2.0f);

face/FaceTracker/app/src/main/java/com/google/android/gms/samples/vision/face/facetracker/FaceTrackerActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public void onCreate(Bundle icicle) {
5757
mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);
5858

5959
Context context = getApplicationContext();
60-
FaceDetector detector = new FaceDetector.Builder(context).build();
60+
FaceDetector.Builder detectorBuilder = new FaceDetector.Builder(context);
61+
detectorBuilder.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS);
62+
FaceDetector detector = detectorBuilder.build();
6163
detector.setProcessor(
6264
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());
6365

0 commit comments

Comments
 (0)