1616
1717package com .google .cloud .vision .samples .facedetect ;
1818
19- // [BEGIN import_libraries]
20-
19+ // [START vision_face_detection_tutorial_imports]
2120import com .google .api .client .googleapis .auth .oauth2 .GoogleCredential ;
2221import com .google .api .client .googleapis .javanet .GoogleNetHttpTransport ;
2322import com .google .api .client .json .JsonFactory ;
4544import java .security .GeneralSecurityException ;
4645import java .util .List ;
4746import javax .imageio .ImageIO ;
48- // [END import_libraries ]
47+ // [END vision_face_detection_tutorial_imports ]
4948
5049/**
5150 * A sample application that uses the Vision API to detect faces in an image.
@@ -60,7 +59,7 @@ public class FaceDetectApp {
6059
6160 private static final int MAX_RESULTS = 4 ;
6261
63- // [START main ]
62+ // [START vision_face_detection_tutorial_run_application ]
6463 /**
6564 * Annotates an image using the Vision API.
6665 */
@@ -85,9 +84,9 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept
8584 System .out .printf ("Writing to file %s\n " , outputPath );
8685 app .writeWithFaces (inputPath , outputPath , faces );
8786 }
88- // [END main ]
87+ // [END vision_face_detection_tutorial_run_application ]
8988
90- // [START get_vision_service ]
89+ // [START vision_face_detection_tutorial_client ]
9190 /**
9291 * Connects to the Vision API using Application Default Credentials.
9392 */
@@ -99,7 +98,7 @@ public static Vision getVisionService() throws IOException, GeneralSecurityExcep
9998 .setApplicationName (APPLICATION_NAME )
10099 .build ();
101100 }
102- // [END get_vision_service ]
101+ // [END vision_face_detection_tutorial_client ]
103102
104103 private final Vision vision ;
105104
@@ -110,7 +109,7 @@ public FaceDetectApp(Vision vision) {
110109 this .vision = vision ;
111110 }
112111
113- // [START detect_face ]
112+ // [START vision_face_detection_tutorial_send_request ]
114113 /**
115114 * Gets up to {@code maxResults} faces for an image stored at {@code path}.
116115 */
@@ -141,9 +140,9 @@ public List<FaceAnnotation> detectFaces(Path path, int maxResults) throws IOExce
141140 }
142141 return response .getFaceAnnotations ();
143142 }
144- // [END detect_face ]
143+ // [END vision_face_detection_tutorial_send_request ]
145144
146- // [START highlight_faces ]
145+ // [START vision_face_detection_tutorial_process_response ]
147146 /**
148147 * Reads image {@code inputPath} and writes {@code outputPath} with {@code faces} outlined.
149148 */
@@ -176,5 +175,5 @@ private static void annotateWithFace(BufferedImage img, FaceAnnotation face) {
176175 gfx .setColor (new Color (0x00ff00 ));
177176 gfx .draw (poly );
178177 }
179- // [END highlight_faces ]
178+ // [END vision_face_detection_tutorial_process_response ]
180179}
0 commit comments