public void AnnotateVideo() { // Sample: AnnotateVideo // Additional: AnnotateVideo(string, IEnumerable<Feature>, CallSettings) VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.Create(); Operation <AnnotateVideoResponse, AnnotateVideoProgress> operation = client.AnnotateVideo( "gs://cloud-samples-data/video/gbikes_dinosaur.mp4", new[] { Feature.LabelDetection }); Operation <AnnotateVideoResponse, AnnotateVideoProgress> resultOperation = operation.PollUntilCompleted(); VideoAnnotationResults result = resultOperation.Result.AnnotationResults[0]; foreach (LabelAnnotation label in result.ShotLabelAnnotations) { Console.WriteLine($"Label entity: {label.Entity.Description}"); Console.WriteLine("Frames:"); foreach (LabelSegment segment in label.Segments) { Console.WriteLine($" {segment.Segment.StartTimeOffset}-{segment.Segment.EndTimeOffset}: {segment.Confidence}"); } } // End sample Assert.Contains(result.ShotLabelAnnotations, lab => lab.Entity.Description == "dinosaur"); }
/// <summary>Snippet for AnnotateVideo</summary> public void AnnotateVideo() { // Snippet: AnnotateVideo(string, IEnumerable<Feature>, CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) string inputUri = ""; IEnumerable <Feature> features = new Feature[] { Feature.Unspecified, }; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = videoIntelligenceServiceClient.AnnotateVideo(inputUri, features); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for AnnotateVideo</summary> public void AnnotateVideo_RequestObject() { // Snippet: AnnotateVideo(AnnotateVideoRequest,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) AnnotateVideoRequest request = new AnnotateVideoRequest(); // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = videoIntelligenceServiceClient.AnnotateVideo(request); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public void AnnotateVideo() { // Snippet: AnnotateVideo(string,IEnumerable<Feature>,ByteString,VideoContext,string,string,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) string inputUri = ""; IEnumerable <Feature> features = new List <Feature>(); ByteString inputContent = ByteString.CopyFromUtf8(""); VideoContext videoContext = new VideoContext(); string outputUri = ""; string locationId = ""; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = videoIntelligenceServiceClient.AnnotateVideo(inputUri, features, inputContent, videoContext, outputUri, locationId); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public void SpeechTranscription() { // Sample: SpeechTranscription VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.Create(); AnnotateVideoRequest request = new AnnotateVideoRequest { InputUri = "gs://cloud-samples-data/video/googlework_short.mp4", Features = { Feature.SpeechTranscription }, VideoContext = new VideoContext { SpeechTranscriptionConfig = new SpeechTranscriptionConfig { LanguageCode = "en-US", EnableAutomaticPunctuation = true } } }; Operation <AnnotateVideoResponse, AnnotateVideoProgress> operation = client.AnnotateVideo(request); Operation <AnnotateVideoResponse, AnnotateVideoProgress> resultOperation = operation.PollUntilCompleted(); VideoAnnotationResults result = resultOperation.Result.AnnotationResults[0]; foreach (SpeechTranscription transcription in result.SpeechTranscriptions) { Console.WriteLine($"Language code: {transcription.LanguageCode}"); Console.WriteLine("Alternatives:"); foreach (SpeechRecognitionAlternative alternative in transcription.Alternatives) { Console.WriteLine($"({alternative.Confidence}) {alternative.Transcript}"); } } // End sample IEnumerable <string> allTranscripts = result.SpeechTranscriptions .SelectMany(st => st.Alternatives) .Select(alt => alt.Transcript); Assert.Contains(allTranscripts, t => t.Contains("Paris is special because")); }
public static int Main(string[] args) { // Create client VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) string inputUri = "gs://demomaker/cat.mp4"; IEnumerable <Feature> features = new[] { Feature.LabelDetection, }; // Call API method Operation <AnnotateVideoResponse, AnnotateVideoProgress> operationResponse = client.AnnotateVideo(inputUri, features); // Poll the operation until it's complete. // This returns a new operation containing the result (or error). operationResponse = operationResponse.PollUntilCompleted(); // Show the result Console.WriteLine(operationResponse.Result); // Success Console.WriteLine("Smoke test passed OK"); return(0); }