Google Cloud Vision v1 API - Class BatchAnnotateImagesResponse (3.4.0)

public sealed class BatchAnnotateImagesResponse : IMessage<BatchAnnotateImagesResponse>, IEquatable<BatchAnnotateImagesResponse>, IDeepCloneable<BatchAnnotateImagesResponse>, IBufferMessage, IMessage

Reference documentation and code samples for the Google Cloud Vision v1 API class BatchAnnotateImagesResponse.

Response to a batch image annotation request.

Inheritance

object > BatchAnnotateImagesResponse

Namespace

Google.Cloud.Vision.V1

Assembly

Google.Cloud.Vision.V1.dll

Constructors

BatchAnnotateImagesResponse()

public BatchAnnotateImagesResponse()

BatchAnnotateImagesResponse(BatchAnnotateImagesResponse)

public BatchAnnotateImagesResponse(BatchAnnotateImagesResponse other)
Parameter
NameDescription
otherBatchAnnotateImagesResponse

Properties

Responses

public RepeatedField<AnnotateImageResponse> Responses { get; }

Individual responses to image annotation requests within the batch.

Property Value
TypeDescription
RepeatedFieldAnnotateImageResponse

Methods

ThrowOnAnyError()

public BatchAnnotateImagesResponse ThrowOnAnyError()

If the Error property is non-null for any response within Responses, throws an AggregateException, containing one AnnotateImageException for each failed response. Otherwise, returns this (so that the method can be called in a fluent manner).

Returns
TypeDescription
BatchAnnotateImagesResponse

this if no responses contain errors.

Example
// We create a request which passes simple validation, but isn't a valid image.
Image image = Image.FromBytes(new byte[10]);
// Just a single request in this example, but usually BatchAnnotateImages would be
// used with multiple requests.
var request = new AnnotateImageRequest
{
    Image = image,
    Features = { new Feature { Type = Feature.Types.Type.SafeSearchDetection } }
};
ImageAnnotatorClient client = ImageAnnotatorClient.Create();
try
{
    BatchAnnotateImagesResponse response = client.BatchAnnotateImages(new[] { request });
    // ThrowOnAnyError will throw if any individual response in response.Responses
    // contains an error. Other responses may still have useful results.
    // Errors can be detected manually by checking the Error property in each
    // individual response.
    response.ThrowOnAnyError();
}
catch (AggregateException e)
{
    // Because a batch can have multiple errors, the exception thrown is AggregateException.
    // Each inner exception is an AnnotateImageException
    foreach (AnnotateImageException innerException in e.InnerExceptions)
    {
        Console.WriteLine(innerException.Response.Error);
    }
}
Exceptions
TypeDescription
AggregateException

The Error property is non-null on one or more element of Responses.