16
16
17
17
package com .google .cloud .vision .samples .facedetect ;
18
18
19
- // [BEGIN import_libraries]
20
-
19
+ // [START vision_face_detection_tutorial_imports]
21
20
import com .google .api .client .googleapis .auth .oauth2 .GoogleCredential ;
22
21
import com .google .api .client .googleapis .javanet .GoogleNetHttpTransport ;
23
22
import com .google .api .client .json .JsonFactory ;
45
44
import java .security .GeneralSecurityException ;
46
45
import java .util .List ;
47
46
import javax .imageio .ImageIO ;
48
- // [END import_libraries ]
47
+ // [END vision_face_detection_tutorial_imports ]
49
48
50
49
/**
51
50
* A sample application that uses the Vision API to detect faces in an image.
@@ -60,7 +59,7 @@ public class FaceDetectApp {
60
59
61
60
private static final int MAX_RESULTS = 4 ;
62
61
63
- // [START main ]
62
+ // [START vision_face_detection_tutorial_run_application ]
64
63
/**
65
64
* Annotates an image using the Vision API.
66
65
*/
@@ -85,9 +84,9 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept
85
84
System .out .printf ("Writing to file %s\n " , outputPath );
86
85
app .writeWithFaces (inputPath , outputPath , faces );
87
86
}
88
- // [END main ]
87
+ // [END vision_face_detection_tutorial_run_application ]
89
88
90
- // [START get_vision_service ]
89
+ // [START vision_face_detection_tutorial_client ]
91
90
/**
92
91
* Connects to the Vision API using Application Default Credentials.
93
92
*/
@@ -99,7 +98,7 @@ public static Vision getVisionService() throws IOException, GeneralSecurityExcep
99
98
.setApplicationName (APPLICATION_NAME )
100
99
.build ();
101
100
}
102
- // [END get_vision_service ]
101
+ // [END vision_face_detection_tutorial_client ]
103
102
104
103
private final Vision vision ;
105
104
@@ -110,7 +109,7 @@ public FaceDetectApp(Vision vision) {
110
109
this .vision = vision ;
111
110
}
112
111
113
- // [START detect_face ]
112
+ // [START vision_face_detection_tutorial_send_request ]
114
113
/**
115
114
* Gets up to {@code maxResults} faces for an image stored at {@code path}.
116
115
*/
@@ -141,9 +140,9 @@ public List<FaceAnnotation> detectFaces(Path path, int maxResults) throws IOExce
141
140
}
142
141
return response .getFaceAnnotations ();
143
142
}
144
- // [END detect_face ]
143
+ // [END vision_face_detection_tutorial_send_request ]
145
144
146
- // [START highlight_faces ]
145
+ // [START vision_face_detection_tutorial_process_response ]
147
146
/**
148
147
* Reads image {@code inputPath} and writes {@code outputPath} with {@code faces} outlined.
149
148
*/
@@ -176,5 +175,5 @@ private static void annotateWithFace(BufferedImage img, FaceAnnotation face) {
176
175
gfx .setColor (new Color (0x00ff00 ));
177
176
gfx .draw (poly );
178
177
}
179
- // [END highlight_faces ]
178
+ // [END vision_face_detection_tutorial_process_response ]
180
179
}
0 commit comments