File tree 2 files changed +12
-6
lines changed
ml-functions/app/src/main/java/devrel/firebase/google/com/mlfunctions 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,11 @@ private void getRecognizedLandmarks(Task<JsonElement> task) {
222
222
private void getRecognizedTexts (Task <JsonElement > task ) {
223
223
// [START function_getRecognizedTexts]
224
224
JsonObject annotation = task .getResult ().getAsJsonArray ().get (0 ).getAsJsonObject ().get ("fullTextAnnotation" ).getAsJsonObject ();
225
+ System .out .format ("%nComplete annotation:%n" );
226
+ System .out .format ("%s%n" , annotation .get ("text" ).getAsString ());
227
+ // [END function_getRecognizedTexts]
228
+
229
+ // [START function_getRecognizedTexts_details]
225
230
for (JsonElement page : annotation .get ("pages" ).getAsJsonArray ()) {
226
231
StringBuilder pageText = new StringBuilder ();
227
232
for (JsonElement block : page .getAsJsonObject ().get ("blocks" ).getAsJsonArray ()) {
@@ -246,8 +251,6 @@ private void getRecognizedTexts(Task<JsonElement> task) {
246
251
pageText .append (blockText );
247
252
}
248
253
}
249
- System .out .format ("%nComplete annotation:%n" );
250
- System .out .format ("%s%n" , annotation .get ("text" ).getAsString ());
254
+ // [END function_getRecognizedTexts_details]
251
255
}
252
- // [END function_getRecognizedTexts]
253
256
}
Original file line number Diff line number Diff line change @@ -189,6 +189,11 @@ class MainActivity : AppCompatActivity() {
189
189
private fun getRecognizedTexts (task : Task <JsonElement ?>) {
190
190
// [START function_getRecognizedTexts]
191
191
val annotation = task.result!! .asJsonArray[0 ].asJsonObject[" fullTextAnnotation" ].asJsonObject
192
+ System .out .format(" %nComplete annotation:" )
193
+ System .out .format(" %n%s" , annotation[" text" ].asString)
194
+ // [END function_getRecognizedTexts]
195
+
196
+ // [START function_getRecognizedTexts_details]
192
197
for (page in annotation[" pages" ].asJsonArray) {
193
198
var pageText = " "
194
199
for (block in page.asJsonObject[" blocks" ].asJsonArray) {
@@ -215,8 +220,6 @@ class MainActivity : AppCompatActivity() {
215
220
pageText + = blockText
216
221
}
217
222
}
218
- System .out .format(" %nComplete annotation:" )
219
- System .out .format(" %n%s" , annotation[" text" ].asString)
223
+ // [END function_getRecognizedTexts_details]
220
224
}
221
- // [END function_getRecognizedTexts]
222
225
}
You can’t perform that action at this time.
0 commit comments