Cloud Vision V1 Client - Class ImageAnnotatorClient (1.10.2)

Reference documentation and code samples for the Cloud Vision V1 Client class ImageAnnotatorClient.

Service Description: 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.

Namespace

Google \ Cloud \ Vision \ V1

Methods

createImageObject

Creates an Image object that can be used as part of an image annotation request.

Example:

$imageResource = fopen('path/to/image.jpg', 'r');
$image = $imageAnnotatorClient->createImageObject($imageResource);
$response = $imageAnnotatorClient->faceDetection($image);
$imageData = file_get_contents('path/to/image.jpg');
$image = $imageAnnotatorClient->createImageObject($imageData);
$response = $imageAnnotatorClient->faceDetection($image);
$imageUri = "gs://my-bucket/image.jpg";
$image = $imageAnnotatorClient->createImageObject($imageUri);
$response = $imageAnnotatorClient->faceDetection($image);
Parameter
Name Description
imageInput resource|string

An image to configure with the given settings. This parameter will accept a resource, a string of bytes, or the URI of an image in a publicly-accessible web location.

Returns
Type Description
Image

annotateImage

Run image detection and annotation for an image.

Example:

use Google\Cloud\Vision\V1\Feature;
use Google\Cloud\Vision\V1\Feature\Type;

$imageResource = fopen('path/to/image.jpg', 'r');
$features = [Type::FACE_DETECTION];
$response = $imageAnnotatorClient->annotateImage($imageResource, $features);
Parameters
Name Description
image resource|string|Image

The image to be processed.

features array<Feature>|int[]

Requested features.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

faceDetection

Run face detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->faceDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

landmarkDetection

Run landmark detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->landmarkDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

logoDetection

Run logo detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->logoDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

labelDetection

Run label detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->labelDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

textDetection

Run text detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->textDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

documentTextDetection

Run document text detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->documentTextDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

safeSearchDetection

Run safe search detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->safeSearchDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

imagePropertiesDetection

Run image properties detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->imagePropertiesDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

cropHintsDetection

Run crop hints detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->cropHintsDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

webDetection

Run web detection for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->webDetection($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

objectLocalization

Run object localization for an image.

Example:

$imageContent = file_get_contents('path/to/image.jpg');
$response = $imageAnnotatorClient->objectLocalization($imageContent);
Parameters
Name Description
image resource|string|Image

The image to be processed.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse

productSearch

Run product search for an image.

Example:

use Google\Cloud\Vision\V1\ProductSearchClient;
use Google\Cloud\Vision\V1\ProductSearchParams;

$imageContent = file_get_contents('path/to/image.jpg');
$productSetName = ProductSearchClient::productSetName('PROJECT_ID', 'LOC_ID', 'PRODUCT_SET_ID');
$productSearchParams = (new ProductSearchParams)
    ->setProductSet($productSetName);
$response = $imageAnnotatorClient->productSearch(
    $imageContent,
    $productSearchParams
);
Parameters
Name Description
image resource|string|Image

The image to be processed.

productSearchParams ProductSearchParams

Parameters for a product search request. Please note, this value will override the ProductSearchParams in the ImageContext instance if provided.

optionalArgs array

Configuration Options.

↳ imageContext ImageContext

Additional context that may accompany the image.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
AnnotateImageResponse