Skip to content

Commit 224a4cd

Browse files
alixhamichingor13
authored andcommitted
samples: Vision region tag update (#1182)
* updates region tags for detecting-crop-hints page * updates region tags for detecting-faces page * updates region tags for detecting-fulltext page * updates region tags for detecting-labels page * updates region tags for detecting-landmarks page * update region tags for detect-logos page * update region tags for detecting-properties page * update region tags for detecting-safe-search page * update region tags for detecting-text page * update region tags for detecting-web page * update beta tags to standard * update PDF detection region tags to standard * updates product search region tags to standard * fix label detection tag * remove region tags from imports * updates to mirror python files * Fix indentation
1 parent 5ddaadc commit 224a4cd

File tree

1 file changed

+47
-19
lines changed
  • vision/snippets/src/main/java/com/example/vision

1 file changed

+47
-19
lines changed

vision/snippets/src/main/java/com/example/vision/Detect.java

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception,
201201
* @throws Exception on errors while closing the client.
202202
* @throws IOException on Input/Output errors.
203203
*/
204+
// [START vision_face_detection]
204205
public static void detectFaces(String filePath, PrintStream out) throws Exception, IOException {
205206
List<AnnotateImageRequest> requests = new ArrayList<>();
206207

@@ -234,6 +235,7 @@ public static void detectFaces(String filePath, PrintStream out) throws Exceptio
234235
}
235236
}
236237
}
238+
// [END vision_face_detection]
237239

238240
/**
239241
* Detects faces in the specified remote image on Google Cloud Storage.
@@ -244,6 +246,7 @@ public static void detectFaces(String filePath, PrintStream out) throws Exceptio
244246
* @throws Exception on errors while closing the client.
245247
* @throws IOException on Input/Output errors.
246248
*/
249+
// [START vision_face_detection_gcs]
247250
public static void detectFacesGcs(String gcsPath, PrintStream out) throws Exception,
248251
IOException {
249252
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -278,6 +281,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws Except
278281
}
279282
}
280283
}
284+
// [END vision_face_detection_gcs]
281285

282286
/**
283287
* Detects labels in the specified local image.
@@ -287,6 +291,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws Except
287291
* @throws Exception on errors while closing the client.
288292
* @throws IOException on Input/Output errors.
289293
*/
294+
// [START vision_label_detection]
290295
public static void detectLabels(String filePath, PrintStream out) throws Exception, IOException {
291296
List<AnnotateImageRequest> requests = new ArrayList<>();
292297

@@ -315,6 +320,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti
315320
}
316321
}
317322
}
323+
// [END vision_label_detection]
318324

319325
/**
320326
* Detects labels in the specified remote image on Google Cloud Storage.
@@ -325,6 +331,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti
325331
* @throws Exception on errors while closing the client.
326332
* @throws IOException on Input/Output errors.
327333
*/
334+
// [START vision_label_detection_gcs]
328335
public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Exception,
329336
IOException {
330337
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -354,6 +361,7 @@ public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Excep
354361
}
355362
}
356363
}
364+
// [END vision_label_detection_gcs]
357365

358366
/**
359367
* Detects landmarks in the specified local image.
@@ -363,6 +371,7 @@ public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Excep
363371
* @throws Exception on errors while closing the client.
364372
* @throws IOException on Input/Output errors.
365373
*/
374+
// [START vision_landmark_detection]
366375
public static void detectLandmarks(String filePath, PrintStream out) throws Exception,
367376
IOException {
368377
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -392,6 +401,7 @@ public static void detectLandmarks(String filePath, PrintStream out) throws Exce
392401
}
393402
}
394403
}
404+
// [END vision_landmark_detection]
395405

396406
/**
397407
* Detects landmarks in the specified URI.
@@ -440,6 +450,7 @@ public static void detectLandmarksUrl(String uri, PrintStream out) throws Except
440450
* @throws Exception on errors while closing the client.
441451
* @throws IOException on Input/Output errors.
442452
*/
453+
// [START vision_landmark_detection_gcs]
443454
public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Exception,
444455
IOException {
445456
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -469,6 +480,7 @@ public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Ex
469480
}
470481
}
471482
}
483+
// [END vision_landmark_detection_gcs]
472484

473485
/**
474486
* Detects logos in the specified local image.
@@ -478,6 +490,7 @@ public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Ex
478490
* @throws Exception on errors while closing the client.
479491
* @throws IOException on Input/Output errors.
480492
*/
493+
// [START vision_logo_detection]
481494
public static void detectLogos(String filePath, PrintStream out) throws Exception, IOException {
482495
List<AnnotateImageRequest> requests = new ArrayList<>();
483496

@@ -506,6 +519,7 @@ public static void detectLogos(String filePath, PrintStream out) throws Exceptio
506519
}
507520
}
508521
}
522+
// [END vision_logo_detection]
509523

510524
/**
511525
* Detects logos in the specified remote image on Google Cloud Storage.
@@ -516,6 +530,7 @@ public static void detectLogos(String filePath, PrintStream out) throws Exceptio
516530
* @throws Exception on errors while closing the client.
517531
* @throws IOException on Input/Output errors.
518532
*/
533+
// [START vision_logo_detection_gcs]
519534
public static void detectLogosGcs(String gcsPath, PrintStream out) throws Exception,
520535
IOException {
521536
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -544,6 +559,7 @@ public static void detectLogosGcs(String gcsPath, PrintStream out) throws Except
544559
}
545560
}
546561
}
562+
// [END vision_logo_detection_gcs]
547563

548564
/**
549565
* Detects text in the specified image.
@@ -553,6 +569,7 @@ public static void detectLogosGcs(String gcsPath, PrintStream out) throws Except
553569
* @throws Exception on errors while closing the client.
554570
* @throws IOException on Input/Output errors.
555571
*/
572+
// [START vision_text_detection]
556573
public static void detectText(String filePath, PrintStream out) throws Exception, IOException {
557574
List<AnnotateImageRequest> requests = new ArrayList<>();
558575

@@ -582,6 +599,7 @@ public static void detectText(String filePath, PrintStream out) throws Exception
582599
}
583600
}
584601
}
602+
// [END vision_text_detection]
585603

586604
/**
587605
* Detects text in the specified remote image on Google Cloud Storage.
@@ -591,6 +609,7 @@ public static void detectText(String filePath, PrintStream out) throws Exception
591609
* @throws Exception on errors while closing the client.
592610
* @throws IOException on Input/Output errors.
593611
*/
612+
// [START vision_text_detection_gcs]
594613
public static void detectTextGcs(String gcsPath, PrintStream out) throws Exception, IOException {
595614
List<AnnotateImageRequest> requests = new ArrayList<>();
596615

@@ -619,6 +638,7 @@ public static void detectTextGcs(String gcsPath, PrintStream out) throws Excepti
619638
}
620639
}
621640
}
641+
// [END vision_text_detection_gcs]
622642

623643
/**
624644
* Detects image properties such as color frequency from the specified local image.
@@ -628,6 +648,7 @@ public static void detectTextGcs(String gcsPath, PrintStream out) throws Excepti
628648
* @throws Exception on errors while closing the client.
629649
* @throws IOException on Input/Output errors.
630650
*/
651+
// [START vision_image_property_detection]
631652
public static void detectProperties(String filePath, PrintStream out) throws Exception,
632653
IOException {
633654
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -663,6 +684,7 @@ public static void detectProperties(String filePath, PrintStream out) throws Exc
663684
}
664685
}
665686
}
687+
// [END vision_image_property_detection]
666688

667689
/**
668690
* Detects image properties such as color frequency from the specified remote image on Google
@@ -673,6 +695,7 @@ public static void detectProperties(String filePath, PrintStream out) throws Exc
673695
* @throws Exception on errors while closing the client.
674696
* @throws IOException on Input/Output errors.
675697
*/
698+
// [START vision_image_property_detection_gcs]
676699
public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws Exception,
677700
IOException {
678701
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -707,8 +730,8 @@ public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws E
707730
}
708731
}
709732
}
733+
// [END vision_image_property_detection_gcs]
710734

711-
// [START vision_detect_safe_search]
712735
/**
713736
* Detects whether the specified image has features you would want to moderate.
714737
*
@@ -717,6 +740,7 @@ public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws E
717740
* @throws Exception on errors while closing the client.
718741
* @throws IOException on Input/Output errors.
719742
*/
743+
// [START vision_safe_search_detection]
720744
public static void detectSafeSearch(String filePath, PrintStream out) throws Exception,
721745
IOException {
722746
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -751,9 +775,8 @@ public static void detectSafeSearch(String filePath, PrintStream out) throws Exc
751775
}
752776
}
753777
}
754-
// [END vision_detect_safe_search]
778+
// [END vision_safe_search_detection]
755779

756-
// [START vision_detect_safe_search_uri]
757780
/**
758781
* Detects whether the specified image on Google Cloud Storage has features you would want
759782
* to moderate.
@@ -763,6 +786,7 @@ public static void detectSafeSearch(String filePath, PrintStream out) throws Exc
763786
* @throws Exception on errors while closing the client.
764787
* @throws IOException on Input/Output errors.
765788
*/
789+
// [START vision_safe_search_detection_gcs]
766790
public static void detectSafeSearchGcs(String gcsPath, PrintStream out) throws Exception,
767791
IOException {
768792
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -796,9 +820,9 @@ public static void detectSafeSearchGcs(String gcsPath, PrintStream out) throws E
796820
}
797821
}
798822
}
799-
// [END vision_detect_safe_search_uri]
823+
// [END vision_safe_search_detection_gcs]
800824

801-
// [START vision_detect_web]
825+
// [START vision_web_detection]
802826
/**
803827
* Finds references to the specified image on the web.
804828
*
@@ -861,9 +885,9 @@ public static void detectWebDetections(String filePath, PrintStream out) throws
861885
}
862886
}
863887
}
864-
// [END vision_detect_web]
888+
// [END vision_web_detection]
865889

866-
// [START vision_detect_web_uri]
890+
// [START vision_web_detection_gcs]
867891
/**
868892
* Detects whether the remote image on Google Cloud Storage has features you would want to
869893
* moderate.
@@ -926,7 +950,7 @@ public static void detectWebDetectionsGcs(String gcsPath, PrintStream out) throw
926950
}
927951
}
928952
}
929-
// [END vision_detect_web_uri]
953+
// [END vision_web_detection_gcs]
930954

931955
/**
932956
* Find web entities given a local image.
@@ -1001,7 +1025,7 @@ public static void detectWebEntitiesGcs(String gcsPath, PrintStream out) throws
10011025
}
10021026
}
10031027

1004-
// [START vision_web_entities_include_geo_results]
1028+
// [START vision_web_detection_include_geo]
10051029
/**
10061030
* Find web entities given a local image.
10071031
* @param filePath The path of the image to detect.
@@ -1048,9 +1072,9 @@ public static void detectWebEntitiesIncludeGeoResults(String filePath, PrintStre
10481072
}));
10491073
}
10501074
}
1051-
// [END vision_web_entities_include_geo_results]
1075+
// [END vision_web_detection_include_geo]
10521076

1053-
// [START vision_web_entities_include_geo_results_uri]
1077+
// [START vision_web_detection_include_geo_gcs]
10541078
/**
10551079
* Find web entities given the remote image on Google Cloud Storage.
10561080
* @param gcsPath The path to the remote file on Google Cloud Storage to detect web entities with
@@ -1099,7 +1123,7 @@ public static void detectWebEntitiesIncludeGeoResultsGcs(String gcsPath, PrintSt
10991123
}));
11001124
}
11011125
}
1102-
// [END vision_web_entities_include_geo_results_uri]
1126+
// [END vision_web_detection_include_geo_gcs]
11031127

11041128
/**
11051129
* Suggests a region to crop to for a local file.
@@ -1109,6 +1133,7 @@ public static void detectWebEntitiesIncludeGeoResultsGcs(String gcsPath, PrintSt
11091133
* @throws Exception on errors while closing the client.
11101134
* @throws IOException on Input/Output errors.
11111135
*/
1136+
// [START vision_crop_hint_detection]
11121137
public static void detectCropHints(String filePath, PrintStream out) throws Exception,
11131138
IOException {
11141139
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -1139,6 +1164,7 @@ public static void detectCropHints(String filePath, PrintStream out) throws Exce
11391164
}
11401165
}
11411166
}
1167+
// [END vision_crop_hint_detection]
11421168

11431169
/**
11441170
* Suggests a region to crop to for a remote file on Google Cloud Storage.
@@ -1148,6 +1174,7 @@ public static void detectCropHints(String filePath, PrintStream out) throws Exce
11481174
* @throws Exception on errors while closing the client.
11491175
* @throws IOException on Input/Output errors.
11501176
*/
1177+
// [START vision_crop_hint_detection_gcs]
11511178
public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Exception,
11521179
IOException {
11531180
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -1177,8 +1204,8 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex
11771204
}
11781205
}
11791206
}
1207+
// [END vision_crop_hint_detection_gcs]
11801208

1181-
// [START vision_detect_document]
11821209
/**
11831210
* Performs document text detection on a local image file.
11841211
*
@@ -1187,8 +1214,9 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex
11871214
* @throws Exception on errors while closing the client.
11881215
* @throws IOException on Input/Output errors.
11891216
*/
1217+
// [START vision_fulltext_detection]
11901218
public static void detectDocumentText(String filePath, PrintStream out) throws Exception,
1191-
IOException {
1219+
IOException {
11921220
List<AnnotateImageRequest> requests = new ArrayList<>();
11931221

11941222
ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath));
@@ -1241,9 +1269,8 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E
12411269
}
12421270
}
12431271
}
1244-
// [END vision_detect_document]
1272+
// [END vision_fulltext_detection]
12451273

1246-
// [START vision_detect_document_uri]
12471274
/**
12481275
* Performs document text detection on a remote image on Google Cloud Storage.
12491276
*
@@ -1252,6 +1279,7 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E
12521279
* @throws Exception on errors while closing the client.
12531280
* @throws IOException on Input/Output errors.
12541281
*/
1282+
// [START vision_fulltext_detection_gcs]
12551283
public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception,
12561284
IOException {
12571285
List<AnnotateImageRequest> requests = new ArrayList<>();
@@ -1304,9 +1332,9 @@ public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws
13041332
}
13051333
}
13061334
}
1307-
// [END vision_detect_document_uri]
1335+
// [END vision_fulltext_detection_gcs]
13081336

1309-
// [START vision_async_detect_document_ocr]
1337+
// [START vision_text_detection_pdf_gcs]
13101338
/**
13111339
* Performs document text OCR with PDF/TIFF as source files on Google Cloud Storage.
13121340
*
@@ -1423,5 +1451,5 @@ public static void detectDocumentsGcs(String gcsSourcePath, String gcsDestinatio
14231451
}
14241452
}
14251453
}
1426-
// [END vision_async_detect_document_ocr]
1454+
// [END vision_text_detection_pdf_gcs]
14271455
}

0 commit comments

Comments
 (0)