File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
main/java/com/example/video
test/java/com/example/video Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -179,13 +179,11 @@ public static void analyzeLabelsFile(String filePath) throws Exception {
179179 // Read file and encode into Base64
180180 Path path = Paths .get (filePath );
181181 byte [] data = Files .readAllBytes (path );
182- byte [] encodedBytes = Base64 .encodeBase64 (data );
183182
184183 AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
185- .setInputContent (ByteString .copyFrom (encodedBytes ))
184+ .setInputContent (ByteString .copyFrom (data ))
186185 .addFeatures (Feature .LABEL_DETECTION )
187186 .build ();
188-
189187 // Create an operation that will contain the response when the operation completes.
190188 OperationFuture <AnnotateVideoResponse , AnnotateVideoProgress > response =
191189 client .annotateVideoAsync (request );
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ public class DetectIT {
3333 private ByteArrayOutputStream bout ;
3434 private PrintStream out ;
3535
36- static final String LABEL_FILE_LOCATION = "gs://demomaker/cat.mp4" ;
36+ static final String LABEL_GCS_LOCATION = "gs://demomaker/cat.mp4" ;
37+ static final String LABEL_FILE_LOCATION = "./resources/cat.mp4" ;
3738 static final String SHOTS_FILE_LOCATION = "gs://demomaker/gbikes_dinosaur.mp4" ;
3839 static final String EXPLICIT_CONTENT_LOCATION = "gs://demomaker/cat.mp4" ;
3940
@@ -51,7 +52,16 @@ public void tearDown() {
5152
5253 @ Test
5354 public void testLabels () throws Exception {
54- String [] args = {"labels" , LABEL_FILE_LOCATION };
55+ String [] args = {"labels" , LABEL_GCS_LOCATION };
56+ Detect .argsHelper (args );
57+ String got = bout .toString ();
58+ // Test that the video with a cat has the whiskers label (may change).
59+ assertThat (got .toUpperCase ()).contains ("WHISKERS" );
60+ }
61+
62+ @ Test
63+ public void testLabelsFile () throws Exception {
64+ String [] args = {"labels-file" , LABEL_FILE_LOCATION };
5565 Detect .argsHelper (args );
5666 String got = bout .toString ();
5767 // Test that the video with a cat has the whiskers label (may change).
You can’t perform that action at this time.
0 commit comments