Google Cloud Video Intelligence v1 API - Class VideoIntelligenceServiceClient (3.3.0)

public abstract class VideoIntelligenceServiceClient

Reference documentation and code samples for the Google Cloud Video Intelligence v1 API class VideoIntelligenceServiceClient.

VideoIntelligenceService client wrapper, for convenient use.

Inheritance

object > VideoIntelligenceServiceClient

Namespace

Google.Cloud.VideoIntelligence.V1

Assembly

Google.Cloud.VideoIntelligence.V1.dll

Remarks

Service that implements the Video Intelligence API.

Properties

AnnotateVideoOperationsClient

public virtual OperationsClient AnnotateVideoOperationsClient { get; }

The long-running operations client for AnnotateVideo.

Property Value
Type Description
OperationsClient

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the VideoIntelligenceService service, which is a host of "videointelligence.googleapis.com" and a port of 443.

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default VideoIntelligenceService scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default VideoIntelligenceService scopes are:

GrpcClient

public virtual VideoIntelligenceService.VideoIntelligenceServiceClient GrpcClient { get; }

The underlying gRPC VideoIntelligenceService client

Property Value
Type Description
VideoIntelligenceServiceVideoIntelligenceServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

AnnotateVideo(AnnotateVideoRequest, CallSettings)

public virtual Operation<AnnotateVideoResponse, AnnotateVideoProgress> AnnotateVideo(AnnotateVideoRequest request, CallSettings callSettings = null)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
request AnnotateVideoRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationAnnotateVideoResponseAnnotateVideoProgress

The RPC response.

Example
// Create client
VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create();
// Initialize request argument(s)
AnnotateVideoRequest request = new AnnotateVideoRequest
{
    InputUri = "",
    Features =
    {
        Feature.Unspecified,
    },
    VideoContext = new VideoContext(),
    OutputUri = "",
    LocationId = "",
    InputContent = ByteString.Empty,
};
// 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;
}

AnnotateVideo(string, IEnumerable<Feature>, CallSettings)

public virtual Operation<AnnotateVideoResponse, AnnotateVideoProgress> AnnotateVideo(string inputUri, IEnumerable<Feature> features, CallSettings callSettings = null)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
inputUri string

Input video location. Currently, only Cloud Storage URIs are supported. URIs must be specified in the following format: gs://bucket-id/object-id (other URI formats return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see Request URIs. To identify multiple videos, a video URI may include wildcards in the object-id. Supported wildcards: '*' to match 0 or more characters; '?' to match 1 character. If unset, the input video should be embedded in the request as input_content. If set, input_content must be unset.

features IEnumerableFeature

Required. Requested video annotation features.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationAnnotateVideoResponseAnnotateVideoProgress

The RPC response.

Example
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}");
    }
}

AnnotateVideoAsync(AnnotateVideoRequest, CallSettings)

public virtual Task<Operation<AnnotateVideoResponse, AnnotateVideoProgress>> AnnotateVideoAsync(AnnotateVideoRequest request, CallSettings callSettings = null)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
request AnnotateVideoRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationAnnotateVideoResponseAnnotateVideoProgress

A Task containing the RPC response.

Example
// Create client
VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync();
// Initialize request argument(s)
AnnotateVideoRequest request = new AnnotateVideoRequest
{
    InputUri = "",
    Features =
    {
        Feature.Unspecified,
    },
    VideoContext = new VideoContext(),
    OutputUri = "",
    LocationId = "",
    InputContent = ByteString.Empty,
};
// Make the request
Operation<AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(request);

// Poll until the returned long-running operation is complete
Operation<AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync();
// 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 = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(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;
}

AnnotateVideoAsync(AnnotateVideoRequest, CancellationToken)

public virtual Task<Operation<AnnotateVideoResponse, AnnotateVideoProgress>> AnnotateVideoAsync(AnnotateVideoRequest request, CancellationToken cancellationToken)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
request AnnotateVideoRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationAnnotateVideoResponseAnnotateVideoProgress

A Task containing the RPC response.

Example
// Create client
VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync();
// Initialize request argument(s)
AnnotateVideoRequest request = new AnnotateVideoRequest
{
    InputUri = "",
    Features =
    {
        Feature.Unspecified,
    },
    VideoContext = new VideoContext(),
    OutputUri = "",
    LocationId = "",
    InputContent = ByteString.Empty,
};
// Make the request
Operation<AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(request);

// Poll until the returned long-running operation is complete
Operation<AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync();
// 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 = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(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;
}

AnnotateVideoAsync(string, IEnumerable<Feature>, CallSettings)

public virtual Task<Operation<AnnotateVideoResponse, AnnotateVideoProgress>> AnnotateVideoAsync(string inputUri, IEnumerable<Feature> features, CallSettings callSettings = null)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
inputUri string

Input video location. Currently, only Cloud Storage URIs are supported. URIs must be specified in the following format: gs://bucket-id/object-id (other URI formats return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see Request URIs. To identify multiple videos, a video URI may include wildcards in the object-id. Supported wildcards: '*' to match 0 or more characters; '?' to match 1 character. If unset, the input video should be embedded in the request as input_content. If set, input_content must be unset.

features IEnumerableFeature

Required. Requested video annotation features.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationAnnotateVideoResponseAnnotateVideoProgress

A Task containing the RPC response.

Example
// Create client
VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync();
// Initialize request argument(s)
string inputUri = "";
IEnumerable<Feature> features = new Feature[]
{
    Feature.Unspecified,
};
// Make the request
Operation<AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(inputUri, features);

// Poll until the returned long-running operation is complete
Operation<AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync();
// 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 = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(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;
}

AnnotateVideoAsync(string, IEnumerable<Feature>, CancellationToken)

public virtual Task<Operation<AnnotateVideoResponse, AnnotateVideoProgress>> AnnotateVideoAsync(string inputUri, IEnumerable<Feature> features, CancellationToken cancellationToken)

Performs asynchronous video annotation. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains AnnotateVideoProgress (progress). Operation.response contains AnnotateVideoResponse (results).

Parameters
Name Description
inputUri string

Input video location. Currently, only Cloud Storage URIs are supported. URIs must be specified in the following format: gs://bucket-id/object-id (other URI formats return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see Request URIs. To identify multiple videos, a video URI may include wildcards in the object-id. Supported wildcards: '*' to match 0 or more characters; '?' to match 1 character. If unset, the input video should be embedded in the request as input_content. If set, input_content must be unset.

features IEnumerableFeature

Required. Requested video annotation features.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationAnnotateVideoResponseAnnotateVideoProgress

A Task containing the RPC response.

Example
// Create client
VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync();
// Initialize request argument(s)
string inputUri = "";
IEnumerable<Feature> features = new Feature[]
{
    Feature.Unspecified,
};
// Make the request
Operation<AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(inputUri, features);

// Poll until the returned long-running operation is complete
Operation<AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync();
// 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 = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(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;
}

Create()

public static VideoIntelligenceServiceClient Create()

Synchronously creates a VideoIntelligenceServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use VideoIntelligenceServiceClientBuilder.

Returns
Type Description
VideoIntelligenceServiceClient

The created VideoIntelligenceServiceClient.

CreateAsync(CancellationToken)

public static Task<VideoIntelligenceServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a VideoIntelligenceServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use VideoIntelligenceServiceClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskVideoIntelligenceServiceClient

The task representing the created VideoIntelligenceServiceClient.

PollOnceAnnotateVideo(string, CallSettings)

public virtual Operation<AnnotateVideoResponse, AnnotateVideoProgress> PollOnceAnnotateVideo(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of AnnotateVideo.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationAnnotateVideoResponseAnnotateVideoProgress

The result of polling the operation.

PollOnceAnnotateVideoAsync(string, CallSettings)

public virtual Task<Operation<AnnotateVideoResponse, AnnotateVideoProgress>> PollOnceAnnotateVideoAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of AnnotateVideo.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationAnnotateVideoResponseAnnotateVideoProgress

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.