0

Trying to use node to run a label detection with the vision api:

'use strict';
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');

// Creates a client
const client = new ImageAnnotatorClient({
projectId: 'my-project-xxx',
 keyFilename: 'Users/xxx/Downloads/xxx.json',
});

// Performs label detection on the image file
client
 .labelDetection('.//Users/xxx/Downloads/menu.jpg')
 .then(results => {
   const labels = results[0].labelAnnotations;

console.log('Labels:');
labels.forEach(label => console.log(label.description));
})
.catch(err => {
  console.error('ERROR:', err);
 });

Continuously receiving error: "ImageAnnotatorClient is not defined" Any reason for this?

R. Haber
  • 1
  • 1

1 Answers1

2

Can you try modifying the line:

const client = new ImageAnnotatorClient({

for:

const client = new vision.ImageAnnotatorClient({

The ImageAnnotatorClient method is extracted from the Cloud Vision API, which you imported as the vision variable.

dsesto
  • 7,864
  • 2
  • 33
  • 50