Skip to content

Commit 74b32d2

Browse files
committed
Polish sample
1 parent 97cdea7 commit 74b32d2

File tree

8 files changed

+21
-23
lines changed

8 files changed

+21
-23
lines changed

InkRecognition/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
services: cognitive-services, inkrecognition
3-
platforms: java
3+
platforms: java, android
44
---
55

66
# Ink Recognition SDK Sample ##
77

8-
Sample code for the Ink Recognizer Cognitive Service SDK which provides easy access to a cloud-based REST API to analyze and recognize digital ink content.
9-
- Recognizes text drawn
10-
- Shows how to set language on the request
11-
- Shows how to set the ink content type on request
8+
Sample app for the Ink Recognizer Cognitive Service SDK which provides easy access to a cloud-based REST API to analyze and recognize digital ink content.
9+
* Recognizes text and shapes drawn
10+
* Shows how to set language on the request
11+
* Shows how to set the ink content type on request
1212

1313
## Features
1414

@@ -25,12 +25,14 @@ This project framework provides examples for using the Ink Recognition SDK.
2525

2626
To get these samples running locally, simply get the pre-requisites above, then:
2727

28-
1. git clone https://github.com/Azure-Samples/cognitive-services-java-sdk-samples.git
29-
2. cd cognitive-services-java-sdk-samples/InkRecognition
28+
1. Run 'git clone https://github.com/Azure-Samples/cognitive-services-java-sdk-samples.git' in the terminal
29+
2. Run 'cd cognitive-services-java-sdk-samples/InkRecognition' in the terminal
3030
3. Set the key in the app/src/main/java/CognitiveServices/Ink/Recognition/NoteTaker.java
3131
4. Run 'gradlew build' in the terminal at the root of InkRecognition to build the project
3232
5. Run 'gradlew assemble' in the terminal at the root of InkRecognition for the release apk under InkRecognition/app/build/outputs/apk/release
3333
6. Deploy the APK to the phone or emulator using Android Developer Tools
34+
7. Write on your app screen
35+
8. View the results appear on the screen after 2 seconds of inactivity
3436

3537
---
3638

InkRecognition/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
33
android {
44
compileSdkVersion 28
55
defaultConfig {
6-
applicationId "CognitiveServices.Ink.Recognition"
6+
applicationId "com.azure.cognitiveservices.inkrecognitionsample"
77
minSdkVersion 26
88
targetSdkVersion 28
99
versionCode 1

InkRecognition/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="CognitiveServices.Ink.Recognition">
3+
package="com.azure.cognitiveservices.inkrecognitionsample">
44

55
<uses-permission android:name="android.permission.INTERNET" />
66

InkRecognition/app/src/main/java/CognitiveServices/Ink/Recognition/InkPointImplementor.java renamed to InkRecognition/app/src/main/java/com/azure/cognitiveservices/inkrecognitionsample/InkPointImplementor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package CognitiveServices.Ink.Recognition;
1+
package com.azure.cognitiveservices.inkrecognitionsample;
22

33
import com.azure.ai.inkrecognizer.InkPoint;
44

InkRecognition/app/src/main/java/CognitiveServices/Ink/Recognition/InkStrokeImplementor.java renamed to InkRecognition/app/src/main/java/com/azure/cognitiveservices/inkrecognitionsample/InkStrokeImplementor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package CognitiveServices.Ink.Recognition;
1+
package com.azure.cognitiveservices.inkrecognitionsample;
22

33
import com.azure.ai.inkrecognizer.*;
44

InkRecognition/app/src/main/java/CognitiveServices/Ink/Recognition/MainActivity.java renamed to InkRecognition/app/src/main/java/com/azure/cognitiveservices/inkrecognitionsample/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package CognitiveServices.Ink.Recognition;
1+
package com.azure.cognitiveservices.inkrecognitionsample;
22

33
import android.os.Bundle;
44
import android.support.v7.app.AppCompatActivity;

InkRecognition/app/src/main/java/CognitiveServices/Ink/Recognition/NoteTaker.java renamed to InkRecognition/app/src/main/java/com/azure/cognitiveservices/inkrecognitionsample/NoteTaker.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package CognitiveServices.Ink.Recognition;
1+
package com.azure.cognitiveservices.inkrecognitionsample;
22

33
import android.content.Context;
44
import android.graphics.Canvas;
@@ -7,7 +7,6 @@
77
import android.graphics.Path;
88
import android.os.AsyncTask;
99
import android.os.CountDownTimer;
10-
import android.util.DisplayMetrics;
1110
import android.view.MotionEvent;
1211
import android.view.View;
1312
import android.widget.Toast;
@@ -35,17 +34,13 @@ public NoteTaker(Context context) throws Exception {
3534
inkRecognizerAsyncClient = new InkRecognizerClientBuilder()
3635
.credentials(new InkRecognizerCredentials(appKey))
3736
.endpoint(destinationUrl)
38-
.retryCount(3)
39-
.retryTimeout(300)
40-
.applicationKind(ApplicationKind.WRITING)
37+
// You can also set this to ApplicationKind.WRITING or ApplicationKind.DRAWING
38+
// if you know the expected type of ink content
39+
.applicationKind(ApplicationKind.MIXED)
40+
// You can set the language here if you know the expected language
4141
.language("en-US")
42-
.unit(InkPointUnit.PIXEL)
43-
.unitMultiple(1)
44-
.serviceVersion(ServiceVersion.PREVIEW_1_0_0)
4542
.displayMetrics(getResources().getDisplayMetrics())
4643
.buildAsyncClient();
47-
DisplayMetrics metrics = getResources().getDisplayMetrics();
48-
System.out.println("DisplayMetrics: " + metrics.xdpi + ", " + metrics.ydpi);
4944
brush.setAntiAlias(true);
5045
brush.setColor(Color.BLACK);
5146
brush.setStyle(Paint.Style.STROKE);
@@ -81,7 +76,6 @@ protected NoteTaker doInBackground(NoteTaker... params) {
8176
NoteTaker noteTaker = params[0];
8277
try {
8378
if (noteTaker.strokes.size() != 0) {
84-
System.out.println();
8579
Mono<Response<InkRecognitionRoot>> response = noteTaker.inkRecognizerAsyncClient.recognizeInk(noteTaker.strokes);
8680
response.subscribe(r -> showResults(r), e -> e.printStackTrace());
8781
}
@@ -99,6 +93,7 @@ protected void onPostExecute(NoteTaker noteTaker) {
9993
}
10094

10195
private void showResults(Response<InkRecognitionRoot> response) {
96+
10297
if (response.status == 200) {
10398

10499
InkRecognitionRoot root = response.root;
@@ -117,6 +112,7 @@ private void showResults(Response<InkRecognitionRoot> response) {
117112
}
118113

119114
}
115+
120116
}
121117

122118
}
-192 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)