File tree 3 files changed +13
-5
lines changed
main/java/com/example/video
test/java/com/example/video
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 {
179
179
// Read file and encode into Base64
180
180
Path path = Paths .get (filePath );
181
181
byte [] data = Files .readAllBytes (path );
182
- byte [] encodedBytes = Base64 .encodeBase64 (data );
183
182
184
183
AnnotateVideoRequest request = AnnotateVideoRequest .newBuilder ()
185
- .setInputContent (ByteString .copyFrom (encodedBytes ))
184
+ .setInputContent (ByteString .copyFrom (data ))
186
185
.addFeatures (Feature .LABEL_DETECTION )
187
186
.build ();
188
-
189
187
// Create an operation that will contain the response when the operation completes.
190
188
OperationFuture <AnnotateVideoResponse , AnnotateVideoProgress > response =
191
189
client .annotateVideoAsync (request );
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ public class DetectIT {
33
33
private ByteArrayOutputStream bout ;
34
34
private PrintStream out ;
35
35
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" ;
37
38
static final String SHOTS_FILE_LOCATION = "gs://demomaker/gbikes_dinosaur.mp4" ;
38
39
static final String EXPLICIT_CONTENT_LOCATION = "gs://demomaker/cat.mp4" ;
39
40
@@ -51,7 +52,16 @@ public void tearDown() {
51
52
52
53
@ Test
53
54
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 };
55
65
Detect .argsHelper (args );
56
66
String got = bout .toString ();
57
67
// 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