Skip to content

Commit 9cc4323

Browse files
committed
Merge branch 'master' of sso://devrel/samples/android/vision into devrel_demos
2 parents 32edfbe + cae471f commit 9cc4323

File tree

37 files changed

+2833
-2
lines changed

37 files changed

+2833
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
*.iml
55
local.properties
66
.DS_Store
7+
captures/

visionSamples/FaceTracker/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ dependencies {
2424
compile 'com.android.support:support-v4:23+'
2525
compile 'com.google.android.gms:play-services:7.8.+'
2626
compile 'com.android.support:design:23.0.0'
27-
}
27+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void draw(Canvas canvas) {
102102
canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint);
103103
canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint);
104104
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);
105+
canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()), x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint);
106106

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

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
import android.app.Dialog;
2222
import android.content.Context;
2323
import android.content.DialogInterface;
24+
import android.content.Intent;
25+
import android.content.IntentFilter;
2426
import android.content.pm.PackageManager;
2527
import android.os.Bundle;
2628
import android.support.design.widget.Snackbar;
2729
import android.support.v4.app.ActivityCompat;
2830
import android.support.v7.app.AppCompatActivity;
2931
import android.util.Log;
3032
import android.view.View;
33+
import android.widget.Toast;
3134

3235
import com.google.android.gms.common.ConnectionResult;
3336
import com.google.android.gms.common.GoogleApiAvailability;
@@ -140,6 +143,17 @@ private void createCameraSource() {
140143
// available. The detector will automatically become operational once the library
141144
// download completes on device.
142145
Log.w(TAG, "Face detector dependencies are not yet available.");
146+
147+
// Check for low storage. If there is low storage, the native library will not be
148+
// downloaded, so detection will not become operational.
149+
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
150+
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
151+
152+
153+
if (hasLowStorage) {
154+
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
155+
Log.w(TAG, getString(R.string.low_storage_error));
156+
}
143157
}
144158

145159
mCameraSource = new CameraSource.Builder(context, detector)

visionSamples/FaceTracker/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<string name="ok">OK</string>
44
<string name="permission_camera_rationale">Access to the camera is needed for detection</string>
55
<string name="no_camera_permission">This application cannot run because it does not have the camera permission. The application will now exit.</string>
6+
<string name="low_storage_error">Face detector dependencies cannot be downloaded due to low device storage</string>
67
</resources>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.google.android.gms.samples.vision.barcodereader"
9+
minSdkVersion 9
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
compile 'com.android.support:support-v4:23.0.1'
25+
// Important - the CameraSource implementation in this project requires version 8.1 or higher.
26+
compile 'com.google.android.gms:play-services:8.1.0'
27+
compile 'com.android.support:design:23.0.1'
28+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/google/home/wilkinsonclay/android/adt-bundle-linux-x86_64-20140702/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.google.android.gms.samples.vision.barcodereader"
4+
android:installLocation="auto" >
5+
6+
<uses-feature android:name="android.hardware.camera" />
7+
8+
<uses-permission android:name="android.permission.CAMERA" />
9+
10+
<application
11+
android:allowBackup="true"
12+
android:fullBackupContent="false"
13+
android:hardwareAccelerated="true"
14+
android:icon="@drawable/icon"
15+
android:label="MultiTrackerApp"
16+
android:supportsRtl = "true"
17+
android:theme="@style/Theme.AppCompat" >
18+
<meta-data
19+
android:name="com.google.android.gms.version"
20+
android:value="@integer/google_play_services_version" />
21+
<meta-data
22+
android:name="com.google.android.gms.vision.DEPENDENCIES"
23+
android:value="barcode" />
24+
25+
<activity
26+
android:name=".MainActivity"
27+
android:label="@string/title_activity_main" >
28+
<intent-filter>
29+
<action android:name="android.intent.action.MAIN" />
30+
31+
<category android:name="android.intent.category.LAUNCHER" />
32+
</intent-filter>
33+
</activity>
34+
35+
<activity android:name=".BarcodeCaptureActivity"
36+
android:label="Read Barcode"/>
37+
</application>
38+
39+
</manifest>

0 commit comments

Comments
 (0)