Constructor

ImageAnnotatorClient

new ImageAnnotatorClient(options)

Construct an instance of ImageAnnotatorClient.

Parameter

options

Optional

object

The configuration object. See the subsequent parameters for more details.

Properties

port

static

The port for this API service.

scopes

static

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static

The DNS address for this API service.

Methods

annotateImage

annotateImage(request, callOptions, callback) returns Promise

Annotate a single image with the requested features.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

const request = {
  image: {source: {imageUri: 'gs://path/to/image.jpg'}},
  features: [],
};
client
  .annotateImage(request)
  .then(response => {
    // doThingsWith(response);
  })
  .catch(err => {
    console.error(err);
  });

batchAnnotateImages

batchAnnotateImages(request, options, callback) returns Promise

Run image detection and annotation for a batch of images.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing BatchAnnotateImagesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1.ImageAnnotatorClient({
  // optional auth parameters.
});

var requests = [];
client.batchAnnotateImages({requests: requests})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

cropHints

cropHints(request, callOptions, callback) returns Promise

Annotate a single image with crop hints.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.cropHints(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

documentTextDetection

documentTextDetection(request, callOptions, callback) returns Promise

Annotate a single image with document text detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.documentTextDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

faceDetection

faceDetection(request, callOptions, callback) returns Promise

Annotate a single image with face detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

const request = {
  image: {
    source: {imageUri: 'gs://path/to/image.jpg'}
  }
};

client
  .faceDetection(request)
  .then(response => {
    // doThingsWith(response);
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

imageProperties

imageProperties(request, callOptions, callback) returns Promise

Annotate a single image with image properties.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.imageProperties(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

labelDetection

labelDetection(request, callOptions, callback) returns Promise

Annotate a single image with label detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.labelDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

landmarkDetection

landmarkDetection(request, callOptions, callback) returns Promise

Annotate a single image with landmark detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

const request = {
  image: {
    source: {imageUri: 'gs://path/to/image.jpg'}
  }
};

client
  .landmarkDetection(request)
  .then(response => {
    // doThingsWith(response);
  })
  .catch(err => {
    console.error(err);
  });

logoDetection

logoDetection(request, callOptions, callback) returns Promise

Annotate a single image with logo detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.logoDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

safeSearchDetection

safeSearchDetection(request, callOptions, callback) returns Promise

Annotate a single image with safe search detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.safeSearchDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

textDetection

textDetection(request, callOptions, callback) returns Promise

Annotate a single image with text detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.textDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});

webDetection

webDetection(request, callOptions, callback) returns Promise

Annotate a single image with web detection.

Parameter

request

(object, string, or Buffer)

A representation of the request being sent to the Vision API. This is an AnnotateImageRequest. For simple cases, you may also send a string (the URL or filename of the image) or a buffer (the image itself).

callOptions

Optional

object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing
BatchAnnotateImagesResponse.
See also
v1.ImageAnnotatorClient#batchAnnotateImages
google.cloud.vision.v1.AnnotateImageRequest
Returns

Promise 

The promise which resolves to an array. The first element of the array is an object representing BatchAnnotateImagesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

var image = {
  source: {imageUri: 'gs://path/to/image.jpg'}
};
vision.webDetection(image).then(response => {
  // doThingsWith(response);
}).catch(err => {
  console.error(err);
});