如何在Node.js中将CallOptions传递给Google API ImageAnnotatorClient?

问题描述

我正在尝试从Google视觉API中突出显示ImageAnnotatorClient。 这是sample code,可以正常工作

const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

const request = {
  image: {source: {imageUri: 'gs://path/to/image.jpg'}},features: [],};
client
  .annotateImage(request)
  .then(response => {
    // doThingsWith(response);
  })
  .catch(err => {
    console.error(err);
  });

例如,我无法通过maxResults option。这是我的尝试(在client.annotateImage(request,callOptions)中传递callOptions),但是都失败了。

    const request = {
        image: {
            //source: {
            //    imageUri: 'https://www.izsvepets.it/wp-content/uploads/2020/04/parvovirosi-eneterite-cuccioli-cane-diarrea.jpg'
            //}
            content: base64img
        }/*,features: [{
            maxResults: 20
        }]*/
    };
    /*const callOptions = {
            //maxResults: 20,//type: 'WEB_DETECTION'
            features: [{
            maxResults: 20
        }]
    };*/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)