Skip to content

Added another fields from face object to be shown (happiness level, l… #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import android.graphics.Color;
import android.graphics.Paint;

import com.google.android.gms.vision.face.Face;
import com.google.android.gms.samples.vision.face.facetracker.ui.camera.GraphicOverlay;
import com.google.android.gms.vision.face.Face;

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

private volatile Face mFace;
private int mFaceId;
private float mFaceHappiness;

FaceGraphic(GraphicOverlay overlay) {
super(overlay);
Expand All @@ -74,6 +75,7 @@ void setId(int id) {
mFaceId = id;
}


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

// Draws a bounding box around the face.
float xOffset = scaleX(face.getWidth() / 2.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public void onCreate(Bundle icicle) {
mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);

Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context).build();
FaceDetector.Builder detectorBuilder = new FaceDetector.Builder(context);
detectorBuilder.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS);
FaceDetector detector = detectorBuilder.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());

Expand Down