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.
Implements
IMessage<BatchAnnotateImagesResponse>, IEquatable<BatchAnnotateImagesResponse>, IDeepCloneable<BatchAnnotateImagesResponse>, IBufferMessage, IMessageNamespace
Google.Cloud.Vision.V1Assembly
Google.Cloud.Vision.V1.dll
Constructors
BatchAnnotateImagesResponse()
public BatchAnnotateImagesResponse()
BatchAnnotateImagesResponse(BatchAnnotateImagesResponse)
public BatchAnnotateImagesResponse(BatchAnnotateImagesResponse other)
Parameter | |
---|---|
Name | Description |
other | BatchAnnotateImagesResponse |
Properties
Responses
public RepeatedField<AnnotateImageResponse> Responses { get; }
Individual responses to image annotation requests within the batch.
Property Value | |
---|---|
Type | Description |
RepeatedField<AnnotateImageResponse> |
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 | |
---|---|
Type | Description |
BatchAnnotateImagesResponse |
|
// 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 | |
---|---|
Type | Description |
AggregateException | The Error property is non-null on one or more element of Responses. |