尝试使用节点通过视觉 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);
});
不断收到错误:“ImageAnnotatorClient 未定义”有什么原因吗?