首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google云视觉api 10限制结果(nodejs)

Google云视觉api 10限制结果(nodejs)
EN

Stack Overflow用户
提问于 2017-11-02 11:49:47
回答 1查看 471关注 0票数 0

我已经读到,结果限制在默认情况下设置为10,但我不知道在google提供的教程代码中应该在哪里更改这个限制。

代码语言:javascript
复制
vision.webDetection({ source: { filename: fileName } })
  .then((results) => {
    const webDetection = results[0].webDetection;
    if (webDetection.fullMatchingImages.length) {
      console.log(`Full matches found: ${webDetection.fullMatchingImages.length}`);
      webDetection.fullMatchingImages.forEach((image) => {
        console.log(`  URL: ${image.url}`);
        console.log(`  Score: ${image.score}`);
      });
    }
  })
  .catch((err) => {
    console.error('ERROR:', err);
  });

https://cloud.google.com/vision/docs/detecting-web

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-11 08:01:28

尝试以下几点:

代码语言:javascript
复制
const bucketName = 'Bucket where the file resides, e.g. my-bucket';
const fileName = 'Path to file within bucket, e.g. path/to/image.png';

const request = {
    source: {
        imageUri: `gs://${bucketName}/${fileName}`
    },
    features: [{
        maxResults: 10 // change this result
    }]
};
vision.webDetection(request)
    .then((results) => {
        const webDetection = results[0].webDetection;
        if (webDetection.fullMatchingImages.length) {
            console.log(`Full matches found: ${webDetection.fullMatchingImages.length}`);
            webDetection.fullMatchingImages.forEach((image) => {
                console.log(`  URL: ${image.url}`);
                console.log(`  Score: ${image.score}`);
            });
        }
    })
    .catch((err) => {
        console.error('ERROR:', err);
    });

参考文献:maxResults

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47074577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档