@Generated(value="by gapic-generator") @BetaApi public class ImageAnnotatorClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests);
}
Note: close() needs to be called on the imageAnnotatorClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ImageAnnotatorSettings to create(). For example:
To customize credentials:
ImageAnnotatorSettings imageAnnotatorSettings =
ImageAnnotatorSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ImageAnnotatorClient imageAnnotatorClient =
ImageAnnotatorClient.create(imageAnnotatorSettings);
To customize the endpoint:
ImageAnnotatorSettings imageAnnotatorSettings =
ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build();
ImageAnnotatorClient imageAnnotatorClient =
ImageAnnotatorClient.create(imageAnnotatorSettings);
Modifier | Constructor and Description |
---|---|
protected |
ImageAnnotatorClient(ImageAnnotatorSettings settings)
Constructs an instance of ImageAnnotatorClient, using the given settings.
|
protected |
ImageAnnotatorClient(ImageAnnotatorStub stub) |
Modifier and Type | Method and Description |
---|---|
OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateFilesAsync(com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest request)
Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
which may contain multiple pages and multiple images per page.
|
OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateFilesAsync(List<com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest> requests)
Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
which may contain multiple pages and multiple images per page.
|
UnaryCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest,Operation> |
asyncBatchAnnotateFilesCallable()
Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
which may contain multiple pages and multiple images per page.
|
OperationCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest,com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateFilesOperationCallable()
Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
which may contain multiple pages and multiple images per page.
|
OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateImagesAsync(com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest request)
Run asynchronous image detection and annotation for a list of images.
|
OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateImagesAsync(List<com.google.cloud.vision.v1p4beta1.AnnotateImageRequest> requests,
com.google.cloud.vision.v1p4beta1.OutputConfig outputConfig)
Run asynchronous image detection and annotation for a list of images.
|
UnaryCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest,Operation> |
asyncBatchAnnotateImagesCallable()
Run asynchronous image detection and annotation for a list of images.
|
OperationCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest,com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> |
asyncBatchAnnotateImagesOperationCallable()
Run asynchronous image detection and annotation for a list of images.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse |
batchAnnotateFiles(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest request)
Service that performs image detection and annotation for a batch of files.
|
com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse |
batchAnnotateFiles(List<com.google.cloud.vision.v1p4beta1.AnnotateFileRequest> requests)
Service that performs image detection and annotation for a batch of files.
|
UnaryCallable<com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest,com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse> |
batchAnnotateFilesCallable()
Service that performs image detection and annotation for a batch of files.
|
com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse |
batchAnnotateImages(com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest request)
Run image detection and annotation for a batch of images.
|
com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse |
batchAnnotateImages(List<com.google.cloud.vision.v1p4beta1.AnnotateImageRequest> requests)
Run image detection and annotation for a batch of images.
|
UnaryCallable<com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest,com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse> |
batchAnnotateImagesCallable()
Run image detection and annotation for a batch of images.
|
void |
close() |
static ImageAnnotatorClient |
create()
Constructs an instance of ImageAnnotatorClient with default settings.
|
static ImageAnnotatorClient |
create(ImageAnnotatorSettings settings)
Constructs an instance of ImageAnnotatorClient, using the given settings.
|
static ImageAnnotatorClient |
create(ImageAnnotatorStub stub)
Constructs an instance of ImageAnnotatorClient, using the given stub for making calls.
|
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
ImageAnnotatorSettings |
getSettings() |
ImageAnnotatorStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
void |
shutdownNow() |
protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub)
public static final ImageAnnotatorClient create() throws IOException
IOException
public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub)
public final ImageAnnotatorSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
public final com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse batchAnnotateImages(List<com.google.cloud.vision.v1p4beta1.AnnotateImageRequest> requests)
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests);
}
requests
- Individual image annotation requests for this batch.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse batchAnnotateImages(com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest request)
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
BatchAnnotateImagesRequest request = BatchAnnotateImagesRequest.newBuilder()
.addAllRequests(requests)
.build();
BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest,com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse> batchAnnotateImagesCallable()
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
BatchAnnotateImagesRequest request = BatchAnnotateImagesRequest.newBuilder()
.addAllRequests(requests)
.build();
ApiFuture<BatchAnnotateImagesResponse> future = imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request);
// Do something
BatchAnnotateImagesResponse response = future.get();
}
public final com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse batchAnnotateFiles(List<com.google.cloud.vision.v1p4beta1.AnnotateFileRequest> requests)
This service will extract at most the first 10 frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateFileRequest> requests = new ArrayList<>();
BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(requests);
}
requests
- The list of file annotation requests. Right now we support only one
AnnotateFileRequest in BatchAnnotateFilesRequest.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse batchAnnotateFiles(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest request)
This service will extract at most the first 10 frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateFileRequest> requests = new ArrayList<>();
BatchAnnotateFilesRequest request = BatchAnnotateFilesRequest.newBuilder()
.addAllRequests(requests)
.build();
BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest,com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse> batchAnnotateFilesCallable()
This service will extract at most the first 10 frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateFileRequest> requests = new ArrayList<>();
BatchAnnotateFilesRequest request = BatchAnnotateFilesRequest.newBuilder()
.addAllRequests(requests)
.build();
ApiFuture<BatchAnnotateFilesResponse> future = imageAnnotatorClient.batchAnnotateFilesCallable().futureCall(request);
// Do something
BatchAnnotateFilesResponse response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateImagesAsync(List<com.google.cloud.vision.v1p4beta1.AnnotateImageRequest> requests, com.google.cloud.vision.v1p4beta1.OutputConfig outputConfig)
Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
OutputConfig outputConfig = OutputConfig.newBuilder().build();
AsyncBatchAnnotateImagesResponse response = imageAnnotatorClient.asyncBatchAnnotateImagesAsync(requests, outputConfig).get();
}
requests
- Individual image annotation requests for this batch.outputConfig
- Required. The desired output location and metadata (e.g. format).ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateImagesAsync(com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest request)
Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
OutputConfig outputConfig = OutputConfig.newBuilder().build();
AsyncBatchAnnotateImagesRequest request = AsyncBatchAnnotateImagesRequest.newBuilder()
.addAllRequests(requests)
.setOutputConfig(outputConfig)
.build();
AsyncBatchAnnotateImagesResponse response = imageAnnotatorClient.asyncBatchAnnotateImagesAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest,com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateImagesOperationCallable()
Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
OutputConfig outputConfig = OutputConfig.newBuilder().build();
AsyncBatchAnnotateImagesRequest request = AsyncBatchAnnotateImagesRequest.newBuilder()
.addAllRequests(requests)
.setOutputConfig(outputConfig)
.build();
OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata> future = imageAnnotatorClient.asyncBatchAnnotateImagesOperationCallable().futureCall(request);
// Do something
AsyncBatchAnnotateImagesResponse response = future.get();
}
public final UnaryCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest,Operation> asyncBatchAnnotateImagesCallable()
Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AnnotateImageRequest> requests = new ArrayList<>();
OutputConfig outputConfig = OutputConfig.newBuilder().build();
AsyncBatchAnnotateImagesRequest request = AsyncBatchAnnotateImagesRequest.newBuilder()
.addAllRequests(requests)
.setOutputConfig(outputConfig)
.build();
ApiFuture<Operation> future = imageAnnotatorClient.asyncBatchAnnotateImagesCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateFilesAsync(List<com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest> requests)
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
AsyncBatchAnnotateFilesResponse response = imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get();
}
requests
- Individual async file annotation requests for this batch.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateFilesAsync(com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest request)
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
AsyncBatchAnnotateFilesRequest request = AsyncBatchAnnotateFilesRequest.newBuilder()
.addAllRequests(requests)
.build();
AsyncBatchAnnotateFilesResponse response = imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest,com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse,com.google.cloud.vision.v1p4beta1.OperationMetadata> asyncBatchAnnotateFilesOperationCallable()
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
AsyncBatchAnnotateFilesRequest request = AsyncBatchAnnotateFilesRequest.newBuilder()
.addAllRequests(requests)
.build();
OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata> future = imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request);
// Do something
AsyncBatchAnnotateFilesResponse response = future.get();
}
public final UnaryCallable<com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest,Operation> asyncBatchAnnotateFilesCallable()
Sample code:
try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
AsyncBatchAnnotateFilesRequest request = AsyncBatchAnnotateFilesRequest.newBuilder()
.addAllRequests(requests)
.build();
ApiFuture<Operation> future = imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.