private async Task <T> AnnotateSingleSingularFeatureTypeAsync <T>( Feature.Types.Type featureType, Func <AnnotateImageResponse, T> annotationExtractor, Image image, ImageContext context, CallSettings callSettings) { GaxPreconditions.CheckNotNull(image, nameof(image)); var request = new AnnotateImageRequest { Image = image, ImageContext = context, Features = { new Feature { Type = featureType } } }; // This will throw on error. var response = await AnnotateAsync(request, callSettings).ConfigureAwait(false); return(annotationExtractor(response)); }
private async Task <IReadOnlyList <T> > AnnotateSingleFeatureTypeAsync <T>( Feature.Types.Type featureType, Func <AnnotateImageResponse, RepeatedField <T> > annotationExtractor, Image image, ImageContext context, int maxResults, CallSettings callSettings) { GaxPreconditions.CheckNotNull(image, nameof(image)); GaxPreconditions.CheckArgumentRange(maxResults, nameof(maxResults), 0, int.MaxValue); var request = new AnnotateImageRequest { Image = image, ImageContext = context, Features = { new Feature { Type = featureType, MaxResults = maxResults } } }; // This will throw on error. var response = await AnnotateAsync(request, callSettings).ConfigureAwait(false); return(annotationExtractor(response)); }