Skip to content

Commit 4afba92

Browse files
committed
added isOperational() check to demo tracker apps
Change-Id: I8133f947bfe35ee3253854781e82393fd92e894f
1 parent 6e1cfeb commit 4afba92

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ public void onCreate(Bundle icicle) {
6161
detector.setProcessor(
6262
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());
6363

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

6576
mCameraSource = new CameraSource.Builder(context, detector)
6677
.setRequestedPreviewSize(640, 480)
@@ -122,9 +133,8 @@ private void startCameraSource() {
122133
//==============================================================================================
123134

124135
/**
125-
* Factory for creating a face tracker to be associated with a new face. The distributing
126-
* detection processor uses this factory to create face trackers as needed -- one for each
127-
* individual.
136+
* Factory for creating a face tracker to be associated with a new face. The multiprocessor
137+
* uses this factory to create face trackers as needed -- one for each individual.
128138
*/
129139
private class GraphicFaceTrackerFactory implements MultiProcessor.Factory<Face> {
130140
@Override

face/multi-tracker/app/src/main/java/com/google/android/gms/samples/vision/face/multitracker/MultiTrackerActivity.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* barcode.
3737
*/
3838
public final class MultiTrackerActivity extends Activity {
39-
private static final String TAG = "FaceTracker";
39+
private static final String TAG = "MultiTracker";
4040

4141
private CameraSource mCameraSource;
4242
private CameraSourcePreview mPreview;
@@ -82,6 +82,19 @@ public void onCreate(Bundle icicle) {
8282
.add(barcodeDetector)
8383
.build();
8484

85+
if (!multiDetector.isOperational()) {
86+
// Note: The first time that an app using the barcode or face API is installed on a
87+
// device, GMS will download a native libraries to the device in order to do detection.
88+
// Usually this completes before the app is run for the first time. But if that
89+
// download has not yet completed, then the above call will not detect any barcodes
90+
// and/or faces.
91+
//
92+
// isOperational() can be used to check if the required native libraries are currently
93+
// available. The detectors will automatically become operational once the library
94+
// downloads complete on device.
95+
Log.w(TAG, "Detector dependencies are not yet available.");
96+
}
97+
8598
// Creates and starts the camera. Note that this will use a higher resolution by default
8699
// (1024x768) in comparison to other face detection examples, because the barcode detector
87100
// works better at higher resolutions.

0 commit comments

Comments
 (0)