@@ -105,11 +105,15 @@ public static void analyzeFaces(String gcsUri) throws ExecutionException,
105105 VideoIntelligenceServiceSettings .defaultBuilder ().build ();
106106 VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient .create (settings );
107107
108+
108109 // Create an operation that will contain the response when the operation completes.
109- ArrayList <Feature > detectFeatures = new ArrayList <Feature >();
110- detectFeatures .add (Feature .FACE_DETECTION );
110+ AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
111+ .setInputUri (gcsUri )
112+ .addFeatures (Feature .FACE_DETECTION )
113+ .build ();
114+
111115 OperationFuture <AnnotateVideoResponse > operation =
112- client .annotateVideoAsync (gcsUri , detectFeatures );
116+ client .annotateVideoAsync (request );
113117
114118 System .out .println ("Waiting for operation to complete..." );
115119 for (VideoAnnotationResults result : operation .get ().getAnnotationResultsList ()) {
@@ -143,10 +147,13 @@ public static void analyzeLabels(String gcsUri) throws
143147 VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient .create (settings );
144148
145149 // Create an operation that will contain the response when the operation completes.
146- ArrayList <Feature > detectFeatures = new ArrayList <Feature >();
147- detectFeatures .add (Feature .LABEL_DETECTION );
150+ AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
151+ .setInputUri (gcsUri )
152+ .addFeatures (Feature .LABEL_DETECTION )
153+ .build ();
154+
148155 OperationFuture <AnnotateVideoResponse > operation =
149- client .annotateVideoAsync (gcsUri , detectFeatures );
156+ client .annotateVideoAsync (request );
150157
151158 System .out .println ("Waiting for operation to complete..." );
152159 for (VideoAnnotationResults result : operation .get ().getAnnotationResultsList ()) {
@@ -233,10 +240,13 @@ public static void analyzeShots(String gcsUri)
233240 VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient .create (settings );
234241
235242 // Create an operation that will contain the response when the operation completes.
236- ArrayList <Feature > detectFeatures = new ArrayList <Feature >();
237- detectFeatures .add (Feature .SHOT_CHANGE_DETECTION );
243+ AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
244+ .setInputUri (gcsUri )
245+ .addFeatures (Feature .SHOT_CHANGE_DETECTION )
246+ .build ();
247+
238248 OperationFuture <AnnotateVideoResponse > operation =
239- client .annotateVideoAsync (gcsUri , detectFeatures );
249+ client .annotateVideoAsync (request );
240250
241251 System .out .println ("Waiting for operation to complete..." );
242252
@@ -270,10 +280,13 @@ public static void analyzeSafeSearch(String gcsUri)
270280 VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient .create (settings );
271281
272282 // Create an operation that will contain the response when the operation completes.
273- ArrayList <Feature > detectFeatures = new ArrayList <Feature >();
274- detectFeatures .add (Feature .SAFE_SEARCH_DETECTION );
283+ AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
284+ .setInputUri (gcsUri )
285+ .addFeatures (Feature .SAFE_SEARCH_DETECTION )
286+ .build ();
287+
275288 OperationFuture <AnnotateVideoResponse > operation =
276- client .annotateVideoAsync (gcsUri , detectFeatures );
289+ client .annotateVideoAsync (request );
277290
278291 System .out .println ("Waiting for operation to complete..." );
279292
0 commit comments