|
28 | 28 | import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig; |
29 | 29 | import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; |
30 | 30 | import com.google.protobuf.ByteString; |
| 31 | +import io.grpc.StatusRuntimeException; |
| 32 | +import java.io.IOException; |
31 | 33 | import java.nio.file.Files; |
32 | 34 | import java.nio.file.Path; |
33 | 35 | import java.nio.file.Paths; |
|
36 | 38 | class StreamingAutoMlClassification { |
37 | 39 |
|
38 | 40 | // Perform streaming video classification with an AutoML Model |
39 | | - static void streamingAutoMlClassification(String filePath, String projectId, String modelId) { |
| 41 | + static void streamingAutoMlClassification(String filePath, String projectId, String modelId) |
| 42 | + throws StatusRuntimeException, IOException { |
40 | 43 | // String filePath = "path_to_your_video_file"; |
41 | 44 | // String projectId = "YOUR_GCP_PROJECT_ID"; |
42 | 45 | // String modelId = "YOUR_AUTO_ML_CLASSIFICATION_MODEL_ID"; |
@@ -102,12 +105,10 @@ static void streamingAutoMlClassification(String filePath, String projectId, Str |
102 | 105 | labelFrame.getTimeOffset().getSeconds() + labelFrame.getTimeOffset().getNanos() / 1e9; |
103 | 106 | float confidence = labelFrame.getConfidence(); |
104 | 107 |
|
105 | | - System.out.format("%fs: %s (%f)\n", offset, entity, confidence); |
| 108 | + System.out.format("At %fs segment: %s (%f)\n", offset, entity, confidence); |
106 | 109 | } |
107 | 110 | } |
108 | 111 | System.out.println("Video streamed successfully."); |
109 | | - } catch (Exception e) { |
110 | | - e.printStackTrace(); |
111 | 112 | } |
112 | 113 | } |
113 | 114 | } |
|
0 commit comments