尝试使用node通过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);
});
连续收到错误:"ImageAnnotatorClient未定义“,这是什么原因?
发布于 2018-01-17 23:15:16
您是否可以尝试修改行:
const client = new ImageAnnotatorClient({
适用于:
const client = new vision.ImageAnnotatorClient({
从作为vision
变量导入的Cloud Vision API中提取ImageAnnotatorClient方法。
https://stackoverflow.com/questions/48304246
复制相似问题