Google云视觉api10个极限结果(nodejs)

Google cloud vision api 10 Limit results (nodejs)

我读到结果限制默认设置为 10,但我不确定在 google 提供的教程代码中在哪里更改它。

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

尝试以下操作:

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);
    });

Ref: maxResults