我尝试在 Vuejs 中实现 google vision API ,但出现此错误:
[Vue warn]: Error in created hook: "Error: {"clientConfig":{},"port":443,"servicePath":"vision.googleapis.com","scopes":["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloud-vision"]}You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library."
我从图片中读取文字的代码:
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
// Performs label detection on the image file
client
.textDetection('./myimage.png')
.then(result => {
const texts = result[0].textAnnotations;
console.log('Text:');
texts.forEach(text => console.log(text.description));
})
.catch(err => {
console.error('ERROR:', err);
});
任何想法如何解决?