Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ dependencies {
compile 'com.google.android.gms:play-services-vision:10.2.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
// TODO (1): Add Timber dependency
compile 'com.jakewharton.timber:timber:4.5.0'
testCompile 'junit:junit:4.12'
}
18 changes: 9 additions & 9 deletions app/src/main/java/com/example/android/emojify/Emojifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.Log;
import android.util.SparseArray;
import android.widget.Toast;

import com.google.android.gms.vision.Frame;
import com.google.android.gms.vision.face.Face;
import com.google.android.gms.vision.face.FaceDetector;

import timber.log.Timber;

class Emojifier {

// TODO (3): Change all Log statements to Timber logs and remove the LOG_TAG variable
private static final String LOG_TAG = Emojifier.class.getSimpleName();

private static final float EMOJI_SCALE_FACTOR = .9f;
private static final double SMILING_PROB_THRESHOLD = .15;
Expand Down Expand Up @@ -59,7 +58,7 @@ static Bitmap detectFacesandOverlayEmoji(Context context, Bitmap picture) {
SparseArray<Face> faces = detector.detect(frame);

// Log the number of faces
Log.d(LOG_TAG, "detectFaces: number of faces = " + faces.size());
Timber.d("detectFaces: number of faces = " + faces.size());

// Initialize result bitmap to original picture
Bitmap resultBitmap = picture;
Expand Down Expand Up @@ -134,10 +133,10 @@ static Bitmap detectFacesandOverlayEmoji(Context context, Bitmap picture) {

private static Emoji whichEmoji(Face face) {
// Log all the probabilities
Log.d(LOG_TAG, "whichEmoji: smilingProb = " + face.getIsSmilingProbability());
Log.d(LOG_TAG, "whichEmoji: leftEyeOpenProb = "
Timber.d("whichEmoji: smilingProb = " + face.getIsSmilingProbability());
Timber.d("whichEmoji: leftEyeOpenProb = "
+ face.getIsLeftEyeOpenProbability());
Log.d(LOG_TAG, "whichEmoji: rightEyeOpenProb = "
Timber.d("whichEmoji: rightEyeOpenProb = "
+ face.getIsRightEyeOpenProbability());


Expand Down Expand Up @@ -173,8 +172,9 @@ private static Emoji whichEmoji(Face face) {


// Log the chosen Emoji
Log.d(LOG_TAG, "whichEmoji: " + emoji.name());

Timber.d("whichEmoji: " + emoji.name());

// return the chosen Emoji
return emoji;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -73,7 +74,8 @@ protected void onCreate(Bundle savedInstanceState) {
// Bind the views
ButterKnife.bind(this);

// TODO (2): Set up Timber
// Set up Timber
Timber.plant(new Timber.DebugTree());
}

/**
Expand Down Expand Up @@ -181,7 +183,7 @@ private void processAndSetImage() {

// Resample the saved image to fit the ImageView
mResultsBitmap = BitmapUtils.resamplePic(this, mTempPhotoPath);


// Detect the faces and overlay the appropriate emoji
mResultsBitmap = Emojifier.detectFacesandOverlayEmoji(this, mResultsBitmap);
Expand All @@ -191,7 +193,6 @@ private void processAndSetImage() {
}



/**
* OnClick method for the save button.
*/
Expand Down