Google cloud platform ImageAnnotatorClient谷歌视觉API
正在尝试使用节点通过vision api运行标签检测:Google cloud platform ImageAnnotatorClient谷歌视觉API,google-cloud-platform,vision-api,Google Cloud Platform,Vision Api,正在尝试使用节点通过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/
'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”
有什么原因吗?能否尝试修改行:
const client = new ImageAnnotatorClient({
用于:
ImageAnnotatorClient方法是从Cloud Vision API中提取的,您将其作为
Vision
变量导入。是否可以尝试修改该行:
const client = new ImageAnnotatorClient({
用于:
ImageAnnotatorClient方法是从Cloud Vision API中提取的,您将其作为
Vision
变量导入。我尝试了此操作,但返回了此错误:“TypeError:Vision.ImageAnnotatorClient不是构造函数”您正在运行哪个版本的库?(npm ls@google cloud/vision
)将软件包升级到最新版本(0.14.0):npm安装--save@google cloud/vision
我尝试了这个方法,但返回了这个错误:“TypeError:vision.ImageAnnotatorClient不是构造函数”您正在运行哪个版本的库?(npm-ls@google-cloud/vision
)将软件包升级至最新版本(0.14.0):npm-install-save@google-cloud/vision