ImageAnnotatorClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service returns detected entities from the images.
Inheritance
builtins.object > google.cloud.vision_helpers.VisionHelpers > builtins.object > google.cloud.vision_v1p2beta1.gapic.image_annotator_client.ImageAnnotatorClient > ImageAnnotatorClientMethods
ImageAnnotatorClient
ImageAnnotatorClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
annotate_image
annotate_image(request, retry=None, timeout=None)
Run image detection and annotation for an image.
.. rubric:: Example
from google.cloud.vision_v1 import ImageAnnotatorClient client = ImageAnnotatorClient() request = { ... 'image': { ... 'source': {'image_uri': 'https://foo.com/image.jpg'}, ... }, ... } response = client.annotate_image(request)
Name | Description |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
async_batch_annotate_files
async_batch_annotate_files(requests, retry=<object object>, timeout=<object object>, metadata=None)
Run async image detection and annotation for a list of generic files
(e.g. PDF) which may contain multiple pages and multiple images per
page. Progress and results can be retrieved through the
google.longrunning.Operations
interface. Operation.metadata
contains OperationMetadata
(metadata). Operation.response
contains AsyncBatchAnnotateFilesResponse
(results).
.. rubric:: Example
from google.cloud import vision_v1p2beta1
client = vision_v1p2beta1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
response = client.async_batch_annotate_files(requests)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
requests |
list[Union[dict, AsyncAnnotateFileRequest]]
Individual async file annotation requests for this batch. If a dict is provided, it must be of the same form as the protobuf message AsyncAnnotateFileRequest |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
batch_annotate_images
batch_annotate_images(requests, retry=<object object>, timeout=<object object>, metadata=None)
Run image detection and annotation for a batch of images.
.. rubric:: Example
from google.cloud import vision_v1p2beta1
client = vision_v1p2beta1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
response = client.batch_annotate_images(requests)
Name | Description |
requests |
list[Union[dict, AnnotateImageRequest]]
Individual image annotation requests for this batch. If a dict is provided, it must be of the same form as the protobuf message AnnotateImageRequest |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
crop_hints
crop_hints(image, max_results=None, retry=None, timeout=None, **kwargs)
Return crop hints information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
document_text_detection
document_text_detection(
image, max_results=None, retry=None, timeout=None, **kwargs
)
Perform document text detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
face_detection
face_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform face detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
ImageAnnotatorClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
ImageAnnotatorClient | The constructed client. |
image_properties
image_properties(image, max_results=None, retry=None, timeout=None, **kwargs)
Return image properties information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
label_detection
label_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform label detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
landmark_detection
landmark_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform landmark detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
logo_detection
logo_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform logo detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
safe_search_detection
safe_search_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform safe search detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
text_detection
text_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform text detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
web_detection
web_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform web detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |