Skip to content

Commit 1d3ef76

Browse files
committed
added more comments for the isOperational case
Change-Id: Id7a05beffebeba6d707a349862f0807768613cca
1 parent 8973ad2 commit 1d3ef76

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

face/photo-demo/app/src/main/java/com/google/android/gms/samples/vision/face/photo/PhotoViewerActivity.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.graphics.Bitmap;
2020
import android.graphics.BitmapFactory;
2121
import android.os.Bundle;
22+
import android.util.Log;
2223
import android.util.SparseArray;
2324

2425
import com.google.android.gms.vision.Frame;
@@ -32,6 +33,8 @@
3233
* photo and displaying the photo with associated landmarks in the UI.
3334
*/
3435
public class PhotoViewerActivity extends Activity {
36+
private static final String TAG = "PhotoViewerActivity";
37+
3538
@Override
3639
protected void onCreate(Bundle savedInstanceState) {
3740
super.onCreate(savedInstanceState);
@@ -45,7 +48,8 @@ protected void onCreate(Bundle savedInstanceState) {
4548
// Setting "tracking enabled" to false is recommended for detection with unrelated
4649
// individual images (as opposed to video or a series of consecutively captured still
4750
// images). For detection on unrelated individual images, this will give a more accurate
48-
// result.
51+
// result. For detection on consecutive images (e.g., live video), tracking gives a more
52+
// accurate (and faster) result.
4953
//
5054
// By default, landmark detection is not enabled since it increases detection time. We
5155
// enable it here in order to visualize detected landmarks.
@@ -54,15 +58,21 @@ protected void onCreate(Bundle savedInstanceState) {
5458
.setLandmarkType(FaceDetector.ALL_LANDMARKS)
5559
.build();
5660

57-
// Run face detection on the bitmap.
61+
// Create a frame from the bitmap and run face detection on the frame.
5862
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
5963
SparseArray<Face> faces = detector.detect(frame);
6064

61-
// Note: The first time that an app using face API is installed on a device, GMS will
62-
// download a native library to the device in order to do detection. Usually this
63-
// completes before the app is run for the first time. But if that download has not yet
64-
// completed, then the above call will not detect any faces. The detector.isOperational()
65-
// method can be used to check if the required native library is currently available.
65+
if (!detector.isOperational()) {
66+
// Note: The first time that an app using face API is installed on a device, GMS will
67+
// download a native library to the device in order to do detection. Usually this
68+
// completes before the app is run for the first time. But if that download has not yet
69+
// completed, then the above call will not detect any faces.
70+
//
71+
// isOperational() can be used to check if the required native library is currently
72+
// available. The detector will automatically become operational once the library
73+
// download completes on device.
74+
Log.w(TAG, "Face detector dependencies are not yet available.");
75+
}
6676

6777
FaceView overlay = (FaceView) findViewById(R.id.faceView);
6878
overlay.setContent(bitmap, faces);

0 commit comments

Comments
 (0)